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
  • Constructor Details

  • Method Details

    • setBlockStateId

      public void setBlockStateId​(int x, int y, int z, short blockStateId, @Nullable Data data)
      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 interface BlockModifier
      Parameters:
      x - the block X
      y - the block Y
      z - the block Z
      blockStateId - the block state id
      data - the block Data, can be null
    • setCustomBlock

      public void setCustomBlock​(int x, int y, int z, short customBlockId, @Nullable Data data)
      Description copied from interface: BlockModifier
      Sets a CustomBlock at a position.

      The custom block id should be the one returned by CustomBlock.getCustomBlockId().

      Specified by:
      setCustomBlock in interface BlockModifier
      Parameters:
      x - the block X
      y - the block Y
      z - the block Z
      customBlockId - the custom block id
      data - the block Data, 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 a CustomBlock 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 using Block.getBlockId().

      Specified by:
      setSeparateBlocks in interface BlockModifier
      Parameters:
      x - the block X
      y - the block Y
      z - the block Z
      blockStateId - the block state id
      customBlockId - the custom block id
      data - the block Data, can be null
    • flushChunkGenerator

      public void flushChunkGenerator​(@NotNull ChunkGenerator chunkGenerator, @Nullable ChunkCallback callback)
      Called to fill the chunk batch.
      Parameters:
      chunkGenerator - the chunk generator
      callback - the optional callback executed once the batch is done
    • flush

      public void flush​(@Nullable 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).
      Parameters:
      callback - the callback to execute once the blocks are placed
    • unsafeFlush

      public void unsafeFlush​(@Nullable ChunkCallback callback)
      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.