Class ChunkBatch
java.lang.Object
net.minestom.server.instance.batch.ChunkBatch
- All Implemented Interfaces:
InstanceBatch
,BlockModifier
public class ChunkBatch extends java.lang.Object implements InstanceBatch
Used when all the blocks you want to place can be contained within only one
Chunk
,
use a BlockBatch
instead otherwise.
Can be created using Instance.createChunkBatch(Chunk)
.
Use chunk coordinate (0-15) instead of world's.
- See Also:
InstanceBatch
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ChunkBatch(InstanceContainer instance, Chunk chunk)
-
Method Summary
Modifier and Type Method Description void
clearData()
Resets the chunk batch by removing all the entries.void
flush(ChunkCallback callback)
Executes the batch in the dedicated pool and run the callback during the next instance update when blocks are placed (which means that the callback can be called 50ms after, but in a determinable thread).void
flushChunkGenerator(ChunkGenerator chunkGenerator, ChunkCallback callback)
Called to fill the chunk batch.void
setBlockStateId(int x, int y, int z, short blockStateId, Data data)
Sets a block at a position.void
setCustomBlock(int x, int y, int z, short customBlockId, Data data)
Sets aCustomBlock
at a position.void
setSeparateBlocks(int x, int y, int z, short blockStateId, short customBlockId, Data data)
Sets aCustomBlock
at a position with a custom state id.void
unsafeFlush(ChunkCallback callback)
Executes the batch in the dedicated pool and run the callback once blocks are placed (in the block batch pool).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.instance.BlockModifier
setBlock, setBlock, setBlockStateId, setBlockStateId, setCustomBlock, setCustomBlock, setCustomBlock, setCustomBlock, setSeparateBlocks, setSeparateBlocks
-
Constructor Details
-
Method Details
-
setBlockStateId
Description copied from interface:BlockModifier
Sets a block at a position.You can use
BlockModifier.setBlock(int, int, int, Block)
if you want it to be more explicit.- Specified by:
setBlockStateId
in interfaceBlockModifier
- Parameters:
x
- the block Xy
- the block Yz
- the block ZblockStateId
- the block state iddata
- the blockData
, can be null
-
setCustomBlock
Description copied from interface:BlockModifier
Sets aCustomBlock
at a position.The custom block id should be the one returned by
CustomBlock.getCustomBlockId()
.- Specified by:
setCustomBlock
in interfaceBlockModifier
- Parameters:
x
- the block Xy
- the block Yz
- the block ZcustomBlockId
- the custom block iddata
- the blockData
, can be null
-
setSeparateBlocks
public void setSeparateBlocks(int x, int y, int z, short blockStateId, short customBlockId, @Nullable Data data)Description copied from interface:BlockModifier
Sets aCustomBlock
at a position with a custom state id.The custom block id should be the one returned by
CustomBlock.getCustomBlockId()
, and the block state id can be anything you want, state id can be retrieved usingBlock.getBlockId()
.- Specified by:
setSeparateBlocks
in interfaceBlockModifier
- Parameters:
x
- the block Xy
- the block Yz
- the block ZblockStateId
- the block state idcustomBlockId
- the custom block iddata
- the blockData
, can be null
-
flushChunkGenerator
public void flushChunkGenerator(@NotNull ChunkGenerator chunkGenerator, @Nullable ChunkCallback callback)Called to fill the chunk batch.- Parameters:
chunkGenerator
- the chunk generatorcallback
- the optional callback executed once the batch is done
-
flush
Executes the batch in the dedicated pool and run the callback during the next instance update when blocks are placed (which means that the callback can be called 50ms after, but in a determinable thread).- Parameters:
callback
- the callback to execute once the blocks are placed
-
unsafeFlush
Executes the batch in the dedicated pool and run the callback once blocks are placed (in the block batch pool).So the callback is executed in an unexpected thread, but you are sure that it will be called immediately.
- Parameters:
callback
- the callback to execute once the blocks are placed
-
clearData
public void clearData()Resets the chunk batch by removing all the entries.
-