Class ChunkBatch
java.lang.Object
net.minestom.server.instance.batch.ChunkBatch
- All Implemented Interfaces:
Batch<ChunkCallback>
,Block.Setter
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 Summary
Fields inherited from interface net.minestom.server.instance.batch.Batch
BLOCK_BATCH_POOL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(@NotNull Instance instance, int chunkX, int chunkZ, @Nullable ChunkCallback callback) Apply this batch to the given chunk.apply
(@NotNull Instance instance, @NotNull Chunk chunk, @Nullable ChunkCallback callback) Apply this batch to the given chunk.protected ChunkBatch
apply
(@NotNull Instance instance, @NotNull Chunk chunk, @Nullable ChunkCallback callback, boolean safeCallback) Apply this batch to the given chunk, and execute the callback depending on safeCallback.apply
(@NotNull Instance instance, @Nullable ChunkCallback callback) Apply this batch to chunk (0, 0).void
Blocks the current thread until the batch is ready to be applied.void
clear()
Removes all block data from this batch.boolean
isReady()
Gets if the batch is ready to be applied to an instance.void
unsafeApply
(@NotNull Instance instance, @NotNull Chunk chunk, @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.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.block.Block.Setter
setBlock
-
Field Details
-
readyLatch
-
-
Constructor Details
-
ChunkBatch
public ChunkBatch() -
ChunkBatch
-
-
Method Details
-
setBlock
- Specified by:
setBlock
in interfaceBlock.Setter
-
clear
public void clear()Description copied from interface:Batch
Removes all block data from this batch.- Specified by:
clear
in interfaceBatch<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 interfaceBatch<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 interfaceBatch<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 interfaceBatch<ChunkCallback>
- Parameters:
instance
- The instance in which the batch should be appliedcallback
- 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 appliedchunkX
- The x chunk coordinate of the target chunkchunkZ
- The z chunk coordinate of the target chunkcallback
- 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 appliedchunk
- The target chunkcallback
- 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 appliedchunk
- The target chunkcallback
- 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 appliedchunk
- The target chunkcallback
- The callback to be executed when the batch is appliedsafeCallback
- 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
-