mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +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 fullChunk = false;
|
||||||
private boolean calculateInverse = false;
|
private boolean calculateInverse = false;
|
||||||
private boolean unsafeApply = false;
|
private boolean unsafeApply = false;
|
||||||
|
private boolean sendUpdate = true;
|
||||||
|
|
||||||
public BatchOption() {
|
public BatchOption() {
|
||||||
}
|
}
|
||||||
@ -62,6 +63,10 @@ public class BatchOption {
|
|||||||
return this.unsafeApply;
|
return this.unsafeApply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldSendUpdate() {
|
||||||
|
return sendUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fullChunk true to make this batch composes the whole chunk
|
* @param fullChunk true to make this batch composes the whole chunk
|
||||||
* @return 'this' for chaining
|
* @return 'this' for chaining
|
||||||
@ -98,4 +103,10 @@ public class BatchOption {
|
|||||||
this.unsafeApply = unsafeApply;
|
this.unsafeApply = unsafeApply;
|
||||||
return this;
|
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) {
|
private void updateChunk(@NotNull Instance instance, Chunk chunk, IntSet updatedSections, @Nullable ChunkCallback callback, boolean safeCallback) {
|
||||||
// Refresh chunk for viewers
|
// Refresh chunk for viewers
|
||||||
ChunkDataPacket chunkDataPacket = chunk.createChunkPacket();
|
if (options.shouldSendUpdate()) {
|
||||||
// TODO update all sections from `updatedSections`
|
ChunkDataPacket chunkDataPacket = chunk.createChunkPacket();
|
||||||
PacketUtils.sendGroupedPacket(chunk.getViewers(), chunkDataPacket);
|
// TODO update all sections from `updatedSections`
|
||||||
|
PacketUtils.sendGroupedPacket(chunk.getViewers(), chunkDataPacket);
|
||||||
|
}
|
||||||
|
|
||||||
if (instance instanceof InstanceContainer) {
|
if (instance instanceof InstanceContainer) {
|
||||||
// FIXME: put method in Instance instead
|
// FIXME: put method in Instance instead
|
||||||
|
Loading…
Reference in New Issue
Block a user