Class ChunkHolder<T extends Future<T>>
java.lang.Object
com.fastasyncworldedit.core.queue.implementation.chunk.ChunkHolder<T>
- All Implemented Interfaces:
IBlocks
,IChunk
,IChunkGet
,IChunkSet
,IQueueChunk<T>
,ITileInput
,Trimable
,InputExtent
,OutputExtent
,Callable<T>
An abstract
IChunk
class that implements basic get/set blocks.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptioncall()
Apply the queued changes to the world containing this chunk.<U extends Future<U>>
Ucall
(IQueueExtent<? extends IChunk> owner, IChunkSet set, Runnable finalize) This method should never be called from outside ChunkHolderentities()
void
entity
(FaweCompoundTag tag) Returns the compound tag describing the entity with the given UUID, if any.void
filterBlocks
(Filter filter, ChunkFilterBlock block, Region region, boolean full) Filter through all the blocks in the chunkvoid
BiomeType[][]
This will return only biomes SET to the EXTENT or QUEUE.getBiomeType
(int x, int y, int z) int
getBlock
(int x, int y, int z) int
getBrightness
(int x, int y, int z) final IChunkSet
int
getEmittedLight
(int x, int y, int z) IQueueExtent
<? extends IChunk> Get the extent this chunk is in.getFullBlock
(int x, int y, int z) Get the entities in the chunk as "full" entities.int[]
getHeightMap
(HeightMapType type) char[][]
getLight()
int
Get the highest layer position stored in the internal chunk.int
getMaxY()
Max y value for the chunk's world (inclusive)int
Get the lowest layer position stored in the internal chunk.int
getMinY()
Min y value for the chunk's world (inclusive)int
getOpacity
(int x, int y, int z) final IChunkGet
Get or create the existing part of this chunk.final IChunkSet
Get or create the settable part of this chunk.int
Get the number of stored sectionsGet the side effects to be used when settings these blockschar[][]
int
getSkyLight
(int x, int y, int z) int
getX()
Get chunkXint
getZ()
Get chunkZboolean
hasBiomes
(int layer) If the given layer has biomes stored to be set to the world.boolean
hasNonEmptySection
(int layer) Returns whether the chunk has a section that has any non-air/reserved blocks.boolean
hasSection
(int layer) Returns if the chunk has a BLOCKS section at the given layer.void
init
(ChunkHolder.IBlockDelegate delegate) <V extends IChunk>
voidinit
(IQueueExtent<V> extent, int chunkX, int chunkZ) Initialize at the location (allows for reuse) - It's expected initialization will clear any set fieldslong
initAge()
boolean
boolean
isEmpty()
boolean
boolean
isInit()
char[]
load
(int layer) Obtain the specified chunk section stored as an array of ordinals.char[]
loadIfPresent
(int layer) Obtain the specified chunk section stored as an array of ordinals if present or null.static ChunkHolder
void
recycle()
void
removeEntity
(UUID uuid) void
removeSectionLighting
(int layer, boolean sky) boolean
void
setBitMask
(int bitMask) <B extends BlockStateHolder<B>>
booleansetBlock
(int x, int y, int z, B block) void
setBlockLight
(int x, int y, int z, int value) void
setBlocks
(int layer, char[] data) int
setCreateCopy
(boolean createCopy) Not for external API use.void
setFastMode
(boolean fastmode) void
setFullBright
(int layer) void
setHeightMap
(HeightMapType type, int[] heightMap) void
setHeightmapToGet
(HeightMapType type, int[] data) void
setLightingToGet
(char[][] lighting, int minSectionPosition, int maxSectionPosition) Flush the block lighting array (section*blocks) to the chunk GET between the given section indices.void
setLightLayer
(int layer, char[] toSet) void
setSideEffectSet
(SideEffectSet sideEffectSet) Set the side effects to be used when settings these blocksvoid
setSkyLight
(int x, int y, int z, int value) void
setSkyLightingToGet
(char[][] lighting, int minSectionPosition, int maxSectionPosition) Flush the sky lighting array (section*blocks) to the chunk GET between the given section indices.void
setSkyLightLayer
(int layer, char[] toSet) tile
(int x, int y, int z) boolean
tile
(int x, int y, int z, FaweCompoundTag tag) Sets a tile/block entity at the given location.tiles()
boolean
trim
(boolean aggressive) Trims the object, reducing its memory footprint.boolean
trim
(boolean aggressive, int layer) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.fastasyncworldedit.core.queue.IBlocks
getEntities, getTiles, toByteArray, toByteArray
Methods inherited from interface com.fastasyncworldedit.core.queue.IChunk
getChunkBlockCoord, getRoot
Methods inherited from interface com.fastasyncworldedit.core.queue.IChunkGet
getBiome, getCopy, getEntity, getTile, lockCall, optimize, unlockCall
Methods inherited from interface com.fastasyncworldedit.core.queue.IChunkSet
commit, createCopy, getHeightMaps, hasBiomes, hasLight, setBiome, setEntity, setTile
Methods inherited from interface com.sk89q.worldedit.extent.InputExtent
getBiome, getBlock, getBrightness, getEmittedLight, getFullBlock, getOpacity, getSkyLight
Methods inherited from interface com.fastasyncworldedit.core.queue.IQueueChunk
hasRunning, join, lockSet, reset
Methods inherited from interface com.sk89q.worldedit.extent.OutputExtent
fullySupports3DBiomes, setBiome, setBlock, setBlockLight, setSkyLight
-
Method Details
-
newInstance
-
init
-
recycle
public void recycle() -
initAge
public long initAge() -
getDelegate
-
entity
-
removeEntity
- Specified by:
removeEntity
in interfaceIChunkSet
-
getEntityRemoves
- Specified by:
getEntityRemoves
in interfaceIChunkSet
-
getBiomes
Description copied from interface:IChunkSet
This will return only biomes SET to the EXTENT or QUEUE. This will NOT return the current biomes in the world. This is used for history purposes. -
getLight
public char[][] getLight() -
getSkyLight
public char[][] getSkyLight()- Specified by:
getSkyLight
in interfaceIChunkSet
-
setBlocks
public void setBlocks(int layer, char[] data) -
load
public char[] load(int layer) Description copied from interface:IBlocks
Obtain the specified chunk section stored as an array of ordinals. Uses normal minecraft chunk-section position indices (length 4096). Operations synchronises on the section and will load the section into memory if not present. For chunk GET operations, this will load the data from the world. For chunk SET, this will create a new empty array. -
loadIfPresent
@Nullable public char[] loadIfPresent(int layer) Description copied from interface:IBlocks
Obtain the specified chunk section stored as an array of ordinals if present or null. Uses normal minecraft chunk-section position indices (length 4096). Does not synchronise to the section layer as it will not attempt to load into memory.- Specified by:
loadIfPresent
in interfaceIBlocks
- Parameters:
layer
- chunk section layer (may be negative)- Returns:
- char array of ordinals of the chunk section if present
-
isFastMode
public boolean isFastMode()- Specified by:
isFastMode
in interfaceIChunkSet
-
setFastMode
public void setFastMode(boolean fastmode) - Specified by:
setFastMode
in interfaceIChunkSet
-
setBitMask
public void setBitMask(int bitMask) - Specified by:
setBitMask
in interfaceIChunkSet
-
getBitMask
public int getBitMask()- Specified by:
getBitMask
in interfaceIBlocks
- Specified by:
getBitMask
in interfaceIChunkSet
-
hasBiomes
public boolean hasBiomes(int layer) Description copied from interface:IChunkSet
If the given layer has biomes stored to be set to the world. Can be negative -
setSideEffectSet
Description copied from interface:IChunkSet
Set the side effects to be used when settings these blocks- Specified by:
setSideEffectSet
in interfaceIChunkSet
-
getSideEffectSet
Description copied from interface:IChunkSet
Get the side effects to be used when settings these blocks- Specified by:
getSideEffectSet
in interfaceIChunkSet
-
isInit
public boolean isInit() -
setCreateCopy
public int setCreateCopy(boolean createCopy) Description copied from interface:IChunkGet
Not for external API use. Internal use only.- Specified by:
setCreateCopy
in interfaceIChunkGet
-
isCreateCopy
public boolean isCreateCopy()- Specified by:
isCreateCopy
in interfaceIChunkGet
-
setLightingToGet
public void setLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) Description copied from interface:IChunkGet
Flush the block lighting array (section*blocks) to the chunk GET between the given section indices. Negative allowed.- Specified by:
setLightingToGet
in interfaceIChunkGet
- Parameters:
lighting
- lighting arrayminSectionPosition
- lowest section indexmaxSectionPosition
- highest section index
-
setSkyLightingToGet
public void setSkyLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) Description copied from interface:IChunkGet
Flush the sky lighting array (section*blocks) to the chunk GET between the given section indices. Negative allowed.- Specified by:
setSkyLightingToGet
in interfaceIChunkGet
- Parameters:
lighting
- sky lighting arrayminSectionPosition
- lowest section indexmaxSectionPosition
- highest section index
-
setHeightmapToGet
- Specified by:
setHeightmapToGet
in interfaceIChunkGet
-
getMaxY
public int getMaxY()Description copied from interface:IChunkGet
Max y value for the chunk's world (inclusive) -
getMinY
public int getMinY()Description copied from interface:IChunkGet
Min y value for the chunk's world (inclusive) -
getMaxSectionPosition
public int getMaxSectionPosition()Description copied from interface:IBlocks
Get the highest layer position stored in the internal chunk. For 1.16 and below, always returns 15. For 1.17 and above, may not return a value correct to the world if this is aIChunkSet
instance, which defaults to 15. For extended height worlds, this will only return over 15 if blocks are stored outside the default range.- Specified by:
getMaxSectionPosition
in interfaceIBlocks
-
getMinSectionPosition
public int getMinSectionPosition()Description copied from interface:IBlocks
Get the lowest layer position stored in the internal chunk. For 1.16 and below, always returns 0. For 1.17 and above, may not return a value correct to the world if this is aIChunkSet
instance, which defaults to 0. For extended height worlds, this will only return under 0 if blocks are stored outside the default range.- Specified by:
getMinSectionPosition
in interfaceIBlocks
-
flushLightToGet
public void flushLightToGet() -
hasSection
public boolean hasSection(int layer) Description copied from interface:IBlocks
Returns if the chunk has a BLOCKS section at the given layer. May not be indicative of presence of entities, tile entites, biomes, etc.- Specified by:
hasSection
in interfaceIBlocks
- Parameters:
layer
- chunk section layer- Returns:
- if blocks/a block section is present
-
hasNonEmptySection
public boolean hasNonEmptySection(int layer) Description copied from interface:IBlocks
Returns whether the chunk has a section that has any non-air/reserved blocks. This method might be conservative and returntrue
even if the section is empty.- Specified by:
hasNonEmptySection
in interfaceIBlocks
- Parameters:
layer
- the section's layer- Returns:
- whether the chunk has a section that has any non-air/reserved blocks
-
filterBlocks
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) Description copied from interface:IChunk
Filter through all the blocks in the chunk- Specified by:
filterBlocks
in interfaceIChunk
- Parameters:
filter
- the filterblock
- The filter blockregion
- The region allowed to filter (maybe null)
-
trim
public boolean trim(boolean aggressive) Description copied from interface:Trimable
Trims the object, reducing its memory footprint. -
trim
public boolean trim(boolean aggressive, int layer) -
getSectionCount
public int getSectionCount()Description copied from interface:IBlocks
Get the number of stored sections- Specified by:
getSectionCount
in interfaceIBlocks
-
isEmpty
public boolean isEmpty() -
tile
Description copied from interface:OutputExtent
Sets a tile/block entity at the given location.- Specified by:
tile
in interfaceIChunkSet
- Specified by:
tile
in interfaceOutputExtent
- Parameters:
x
- the x positiony
- the y positionz
- the z positiontag
- the tile/block entity to set- Returns:
true
if the tile/block entity was placed
-
getOrCreateGet
Get or create the existing part of this chunk. -
getOrCreateSet
Get or create the settable part of this chunk. -
getChunkSet
-
init
Description copied from interface:IChunk
Initialize at the location (allows for reuse) - It's expected initialization will clear any set fields -
call
Description copied from interface:IQueueChunk
Apply the queued changes to the world containing this chunk.The future returned may return another future. To ensure completion keep calling
Future.get()
on each result. -
call
public <U extends Future<U>> U call(IQueueExtent<? extends IChunk> owner, IChunkSet set, Runnable finalize) This method should never be called from outside ChunkHolder -
getExtent
Get the extent this chunk is in. -
getX
public int getX()Description copied from interface:IChunk
Get chunkX -
getZ
public int getZ()Description copied from interface:IChunk
Get chunkZ -
setBiome
- Specified by:
setBiome
in interfaceIChunkSet
- Specified by:
setBiome
in interfaceOutputExtent
-
setBlock
- Specified by:
setBlock
in interfaceIChunkSet
- Specified by:
setBlock
in interfaceOutputExtent
-
getBiomeType
- Specified by:
getBiomeType
in interfaceIBlocks
- Specified by:
getBiomeType
in interfaceIChunkGet
- Specified by:
getBiomeType
in interfaceInputExtent
-
getBlock
-
tiles
-
tile
-
entities
-
getFullEntities
Description copied from interface:IChunkGet
Get the entities in the chunk as "full" entities.- Specified by:
getFullEntities
in interfaceIChunkGet
-
getFullBlock
- Specified by:
getFullBlock
in interfaceIChunkGet
- Specified by:
getFullBlock
in interfaceInputExtent
-
setSkyLight
public void setSkyLight(int x, int y, int z, int value) - Specified by:
setSkyLight
in interfaceIChunkSet
- Specified by:
setSkyLight
in interfaceOutputExtent
-
setHeightMap
- Specified by:
setHeightMap
in interfaceIChunkSet
- Specified by:
setHeightMap
in interfaceOutputExtent
-
removeSectionLighting
public void removeSectionLighting(int layer, boolean sky) - Specified by:
removeSectionLighting
in interfaceIBlocks
-
setFullBright
public void setFullBright(int layer) - Specified by:
setFullBright
in interfaceIChunkSet
-
setBlockLight
public void setBlockLight(int x, int y, int z, int value) - Specified by:
setBlockLight
in interfaceIChunkSet
- Specified by:
setBlockLight
in interfaceOutputExtent
-
setLightLayer
public void setLightLayer(int layer, char[] toSet) - Specified by:
setLightLayer
in interfaceIChunkSet
-
setSkyLightLayer
public void setSkyLightLayer(int layer, char[] toSet) - Specified by:
setSkyLightLayer
in interfaceIChunkSet
-
getSkyLight
public int getSkyLight(int x, int y, int z) - Specified by:
getSkyLight
in interfaceIChunkGet
- Specified by:
getSkyLight
in interfaceInputExtent
-
getEmittedLight
public int getEmittedLight(int x, int y, int z) - Specified by:
getEmittedLight
in interfaceIChunkGet
- Specified by:
getEmittedLight
in interfaceInputExtent
-
getBrightness
public int getBrightness(int x, int y, int z) - Specified by:
getBrightness
in interfaceInputExtent
-
getOpacity
public int getOpacity(int x, int y, int z) - Specified by:
getOpacity
in interfaceInputExtent
-
getHeightMap
- Specified by:
getHeightMap
in interfaceIChunkGet
- Specified by:
getHeightMap
in interfaceInputExtent
-
entity
Description copied from interface:IChunkGet
Returns the compound tag describing the entity with the given UUID, if any.
-