Interface Batch<C>
- Type Parameters:
C
- The callback function type.
- All Superinterfaces:
Block.Setter
- All Known Implementing Classes:
AbsoluteBlockBatch
,ChunkBatch
,RelativeBlockBatch
Batches offer a performance benefit because clients are not notified of any change until all of the blocks have been placed, and because changes can happen with less synchronization.
All batches may be rotated using {link}, however rotate operations do not mutate the batch, so the result should be cached if used multiple times.
If reversal is a desired behavior, batches may be applied in "reversal mode" using {link}. This operation will return a new batch with the blocks set to whatever they were before the batch was applied.
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionCalled to apply the batch to the given instance.default void
Blocks the current thread until the batch is ready to be applied.void
clear()
Removes all block data from this batch.default boolean
isReady()
Gets if the batch is ready to be applied to an instance.Methods inherited from interface net.minestom.server.instance.block.Block.Setter
setBlock, setBlock
-
Field Details
-
BLOCK_BATCH_POOL
-
-
Method Details
-
isReady
default boolean isReady()Gets if the batch is ready to be applied to an instance.- Returns:
- true if the batch is ready to apply
-
awaitReady
default void awaitReady()Blocks the current thread until the batch is ready to be applied.- See Also:
-
clear
void clear()Removes all block data from this batch. -
apply
Called to apply the batch to the given instance.The implementation for all current batches executes the block updates in a dedicated pool, and runs the callback on the next instance update after block placement is complete. This means that the callback can be called up to 50ms after the blocks have been placed, however, it will be called in a determinable thread. If immediate execution of the callback is needed, see the unsafeApply method in each implementation.
See the specific batch classes for alternative application methods.
- 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
-