Class RelativeBlockBatch
java.lang.Object
net.minestom.server.instance.batch.RelativeBlockBatch
- All Implemented Interfaces:
Batch<Runnable>
,Block.Setter
A
Batch
which can be used when changes are required across chunk borders, and
are going to be reused in different places. If translation is not required, AbsoluteBlockBatch
should be used instead for efficiency purposes.
Coordinates are relative to (0, 0, 0) with some limitations. All coordinates must
fit within a 16 bit integer of the first coordinate (32,767 blocks). If blocks must
be spread out over a larger area, an AbsoluteBlockBatch
should be used.
All inverses are AbsoluteBlockBatch
s and represent the inverse of the application
at the position which it was applied.
If a batch will be used multiple times at the same coordinate, it is suggested
to convert it to an AbsoluteBlockBatch
and cache the result. Application
of absolute batches (currently) is significantly faster than their relative counterpart.
- See Also:
-
Field Summary
Fields inherited from interface net.minestom.server.instance.batch.Batch
BLOCK_BATCH_POOL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionApplies this batch to the given instance at the given position.protected AbsoluteBlockBatch
apply
(@NotNull Instance instance, int x, int y, int z, @Nullable Runnable callback, boolean safeCallback) Applies this batch to the given instance at the given position, execute the callback depending on safeCallback.Applies this batch to the given instance at the origin (0, 0, 0) of the instance.Applies this batch to the given instance at the given block position.applyUnsafe
(@NotNull Instance instance, int x, int y, int z, @Nullable Runnable callback) Applies this batch to the given instance at the given position, and execute the callback immediately when the blocks have been applied, int an unknown thread.void
clear()
Removes all block data from this batch.void
@NotNull AbsoluteBlockBatch
Converts this batch to an absolute batch at the origin (0, 0, 0).@NotNull AbsoluteBlockBatch
toAbsoluteBatch
(int x, int y, int z) Converts this batch to an absolute batch at the given coordinates.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.batch.Batch
awaitReady, isReady
Methods inherited from interface net.minestom.server.instance.block.Block.Setter
setBlock
-
Constructor Details
-
RelativeBlockBatch
public RelativeBlockBatch() -
RelativeBlockBatch
-
-
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. -
apply
public AbsoluteBlockBatch apply(@NotNull @NotNull Instance instance, @Nullable @Nullable Runnable callback) Applies this batch to the given instance at the origin (0, 0, 0) of the instance.- Specified by:
apply
in interfaceBatch<Runnable>
- 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 AbsoluteBlockBatch apply(@NotNull @NotNull Instance instance, @NotNull @NotNull Point position, @Nullable @Nullable Runnable callback) Applies this batch to the given instance at the given block position.- Parameters:
instance
- The instance in which the batch should be appliedposition
- The position to apply the batchcallback
- 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 AbsoluteBlockBatch apply(@NotNull @NotNull Instance instance, int x, int y, int z, @Nullable @Nullable Runnable callback) Applies this batch to the given instance at the given position.- Parameters:
instance
- The instance in which the batch should be appliedx
- The x position to apply the batchy
- The y position to apply the batchz
- The z position to apply the batchcallback
- The callback to be executed when the batch is applied- Returns:
- The inverse of this batch, if inverse is enabled in the
BatchOption
-
applyUnsafe
public AbsoluteBlockBatch applyUnsafe(@NotNull @NotNull Instance instance, int x, int y, int z, @Nullable @Nullable Runnable callback) Applies this batch to the given instance at the given position, and execute the callback immediately when the blocks have been applied, int an unknown thread.- Parameters:
instance
- The instance in which the batch should be appliedx
- The x position to apply the batchy
- The y position to apply the batchz
- The z position to apply the batchcallback
- 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 AbsoluteBlockBatch apply(@NotNull @NotNull Instance instance, int x, int y, int z, @Nullable @Nullable Runnable callback, boolean safeCallback) Applies this batch to the given instance at the given position, execute the callback depending on safeCallback.- Parameters:
instance
- The instance in which the batch should be appliedx
- The x position to apply the batchy
- The y position to apply the batchz
- The z position to apply the batchcallback
- 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
-
toAbsoluteBatch
Converts this batch to an absolute batch at the origin (0, 0, 0).- Returns:
- An absolute batch of this batch at the origin
-
toAbsoluteBatch
Converts this batch to an absolute batch at the given coordinates.- Parameters:
x
- The x position of the batch in the worldy
- The y position of the batch in the worldz
- The z position of the batch in the world- Returns:
- An absolute batch of this batch at (x, y, z)
-