Class ChunkBatch

java.lang.Object
net.minestom.server.instance.batch.ChunkBatch
All Implemented Interfaces:
Batch<ChunkCallback>, Block.Setter

public class ChunkBatch extends Object implements Batch<ChunkCallback>
A Batch used when all of the block changed are contained inside a single chunk. If more than one chunk is needed, use an AbsoluteBlockBatch instead.

The batch can be placed in any chunk in any instance, however it will always remain aligned to a chunk border. If completely translatable block changes are needed, use a RelativeBlockBatch instead.

Coordinates are relative to the chunk (0-15) instead of world coordinates.

See Also:
  • Field Details

  • Constructor Details

    • ChunkBatch

      public ChunkBatch()
    • ChunkBatch

      public ChunkBatch(BatchOption options)
  • Method Details

    • setBlock

      public void setBlock(int x, int y, int z, @NotNull @NotNull Block block)
      Specified by:
      setBlock in interface Block.Setter
    • clear

      public void clear()
      Description copied from interface: Batch
      Removes all block data from this batch.
      Specified by:
      clear in interface Batch<ChunkCallback>
    • isReady

      public boolean isReady()
      Description copied from interface: Batch
      Gets if the batch is ready to be applied to an instance.
      Specified by:
      isReady in interface Batch<ChunkCallback>
      Returns:
      true if the batch is ready to apply
    • awaitReady

      public void awaitReady()
      Description copied from interface: Batch
      Blocks the current thread until the batch is ready to be applied.
      Specified by:
      awaitReady in interface Batch<ChunkCallback>
      See Also:
    • apply

      public ChunkBatch apply(@NotNull @NotNull Instance instance, @Nullable @Nullable ChunkCallback callback)
      Apply this batch to chunk (0, 0).
      Specified by:
      apply in interface Batch<ChunkCallback>
      Parameters:
      instance - The instance in which the batch should be applied
      callback - The callback to be executed when the batch is applied
      Returns:
      The inverse of this batch, if inverse is enabled in the BatchOption
    • apply

      public ChunkBatch apply(@NotNull @NotNull Instance instance, int chunkX, int chunkZ, @Nullable @Nullable ChunkCallback callback)
      Apply this batch to the given chunk.
      Parameters:
      instance - The instance in which the batch should be applied
      chunkX - The x chunk coordinate of the target chunk
      chunkZ - The z chunk coordinate of the target chunk
      callback - The callback to be executed when the batch is applied.
      Returns:
      The inverse of this batch, if inverse is enabled in the BatchOption
    • apply

      public ChunkBatch apply(@NotNull @NotNull Instance instance, @NotNull @NotNull Chunk chunk, @Nullable @Nullable ChunkCallback callback)
      Apply this batch to the given chunk.
      Parameters:
      instance - The instance in which the batch should be applied
      chunk - The target chunk
      callback - The callback to be executed when the batch is applied
      Returns:
      The inverse of this batch, if inverse is enabled in the BatchOption
    • unsafeApply

      public ChunkBatch unsafeApply(@NotNull @NotNull Instance instance, @NotNull @NotNull Chunk chunk, @Nullable @Nullable ChunkCallback callback)
      Apply this batch to the given chunk, and execute the callback immediately when the blocks have been applied, in an unknown thread.
      Parameters:
      instance - The instance in which the batch should be applied
      chunk - The target chunk
      callback - The callback to be executed when the batch is applied
      Returns:
      The inverse of this batch, if inverse is enabled in the BatchOption
    • apply

      protected ChunkBatch apply(@NotNull @NotNull Instance instance, @NotNull @NotNull Chunk chunk, @Nullable @Nullable ChunkCallback callback, boolean safeCallback)
      Apply this batch to the given chunk, and execute the callback depending on safeCallback.
      Parameters:
      instance - The instance in which the batch should be applied
      chunk - The target chunk
      callback - The callback to be executed when the batch is applied
      safeCallback - If true, the callback will be executed in the next instance update. Otherwise it will be executed immediately upon completion
      Returns:
      The inverse of this batch, if inverse is enabled in the BatchOption