mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Add batch option to do not send chunk packet
This commit is contained in:
parent
10aeb32b45
commit
7fcd4039cb
@ -12,6 +12,7 @@ public class BatchOption {
|
||||
private boolean fullChunk = false;
|
||||
private boolean calculateInverse = false;
|
||||
private boolean unsafeApply = false;
|
||||
private boolean sendUpdate = true;
|
||||
|
||||
public BatchOption() {
|
||||
}
|
||||
@ -62,6 +63,10 @@ public class BatchOption {
|
||||
return this.unsafeApply;
|
||||
}
|
||||
|
||||
public boolean shouldSendUpdate() {
|
||||
return sendUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fullChunk true to make this batch composes the whole chunk
|
||||
* @return 'this' for chaining
|
||||
@ -98,4 +103,10 @@ public class BatchOption {
|
||||
this.unsafeApply = unsafeApply;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Contract("_ -> this")
|
||||
public BatchOption setSendUpdate(boolean sendUpdate) {
|
||||
this.sendUpdate = sendUpdate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -224,9 +224,11 @@ public class ChunkBatch implements Batch<ChunkCallback> {
|
||||
*/
|
||||
private void updateChunk(@NotNull Instance instance, Chunk chunk, IntSet updatedSections, @Nullable ChunkCallback callback, boolean safeCallback) {
|
||||
// Refresh chunk for viewers
|
||||
ChunkDataPacket chunkDataPacket = chunk.createChunkPacket();
|
||||
// TODO update all sections from `updatedSections`
|
||||
PacketUtils.sendGroupedPacket(chunk.getViewers(), chunkDataPacket);
|
||||
if (options.shouldSendUpdate()) {
|
||||
ChunkDataPacket chunkDataPacket = chunk.createChunkPacket();
|
||||
// TODO update all sections from `updatedSections`
|
||||
PacketUtils.sendGroupedPacket(chunk.getViewers(), chunkDataPacket);
|
||||
}
|
||||
|
||||
if (instance instanceof InstanceContainer) {
|
||||
// FIXME: put method in Instance instead
|
||||
|
Loading…
Reference in New Issue
Block a user