From 4c7b50d6fbac1fcdbb46815efa7e32dc0b726635 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 13 Apr 2016 15:05:50 +0100 Subject: [PATCH] Fix chunk sending order, Fixes #338, #292 (I believe.) --- .../protocol1_9to1_8/packets/WorldPackets.java | 11 +++-------- .../protocols/protocol1_9to1_8/types/ChunkType.java | 6 +++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index ef5464a53..58a679ce5 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -115,14 +115,9 @@ public class WorldPackets { @Override public void handle(PacketWrapper wrapper) throws Exception { ClientChunks clientChunks = wrapper.user().get(ClientChunks.class); - Chunk chunk = wrapper.passthrough(new ChunkType(clientChunks)); - if (chunk.isUnloadPacket()) { - PacketWrapper unload = wrapper.create(0x1D); - unload.write(Type.INT, chunk.getX()); - unload.write(Type.INT, chunk.getZ()); - unload.send(); - wrapper.cancel(); - } + wrapper.passthrough(new ChunkType(clientChunks)); + // eat any other data (Usually happens with unload packets) + wrapper.read(Type.REMAINING_BYTES); } }); } diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/ChunkType.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/ChunkType.java index fdba18e23..230ad6f8d 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/ChunkType.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/ChunkType.java @@ -128,11 +128,15 @@ public class ChunkType extends PartialType { @Override public void write(ByteBuf output, ClientChunks param, Chunk chunk) throws Exception { - if (chunk.isUnloadPacket()) return; + if (chunk.isUnloadPacket()) { + output.clear(); + Type.VAR_INT.write(output, 0x1D); // Unload packet ID + } // Write primary info output.writeInt(chunk.getX()); output.writeInt(chunk.getZ()); + if (chunk.isUnloadPacket()) return; output.writeByte(chunk.isGroundUp() ? 0x01 : 0x00); Type.VAR_INT.write(output, chunk.getPrimaryBitmask());