From d70ec58fca997463e5f2281aab74c3b4f2035365 Mon Sep 17 00:00:00 2001 From: Valaphee Date: Sat, 17 Dec 2022 00:22:36 +0100 Subject: [PATCH] Use sub chunk request system --- .../geyser/network/LoggingPacketHandler.java | 5 +++++ .../BedrockSubChunkRequestTranslator.java | 18 ++---------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/network/LoggingPacketHandler.java b/core/src/main/java/org/geysermc/geyser/network/LoggingPacketHandler.java index 8d2db081aca..fcec20b7a5f 100644 --- a/core/src/main/java/org/geysermc/geyser/network/LoggingPacketHandler.java +++ b/core/src/main/java/org/geysermc/geyser/network/LoggingPacketHandler.java @@ -870,4 +870,9 @@ public boolean handle(RequestAbilityPacket packet) { public boolean handle(RequestNetworkSettingsPacket packet) { return defaultHandler(packet); } + + @Override + public boolean handle(SubChunkRequestPacket packet) { + return defaultHandler(packet); + } } \ No newline at end of file diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSubChunkRequestTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSubChunkRequestTranslator.java index fa2811c7418..f3fcdabf152 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSubChunkRequestTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSubChunkRequestTranslator.java @@ -77,7 +77,7 @@ public void translate(GeyserSession session, SubChunkRequestPacket packet) { int bedrockSubChunkMinY = bedrockDimension.minY() >> 4; int bedrockSubChunkMaxY = bedrockSubChunkMinY + (bedrockDimension.height() >> 4); - ByteBuf byteBuf = null, blobByteBuf = null; + ByteBuf byteBuf = null; try { for (Vector3i positionOffset : packet.getPositionOffsets()) { @@ -255,22 +255,11 @@ public void translate(GeyserSession session, SubChunkRequestPacket packet) { if (byteBuf == null) { byteBuf = ByteBufAllocator.DEFAULT.buffer(section.estimateNetworkSize() + bedrockBlockEntities.size() * 64); - if (!subChunkPacket.isCacheEnabled()) { - blobByteBuf = byteBuf; - } } else { byteBuf.clear(); } - if (subChunkPacket.isCacheEnabled()) { - if (blobByteBuf != null) { - blobByteBuf.clear(); - } else { - blobByteBuf = ByteBufAllocator.DEFAULT.buffer(section.estimateNetworkSize()); - } - } - - section.writeToNetwork(blobByteBuf); + section.writeToNetwork(byteBuf); NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(new ByteBufOutputStream(byteBuf)); for (NbtMap blockEntity : bedrockBlockEntities) { nbtStream.writeTag(blockEntity); @@ -288,9 +277,6 @@ public void translate(GeyserSession session, SubChunkRequestPacket packet) { if (byteBuf != null) { byteBuf.release(); } - if (subChunkPacket.isCacheEnabled() && blobByteBuf != null) { - blobByteBuf.release(); - } } } }