From 2446577188aba0bbd57da053072cbbbc6eb3d2e3 Mon Sep 17 00:00:00 2001 From: Matsv Date: Thu, 8 Jun 2017 12:11:44 +0200 Subject: [PATCH] Read all the remaining bytes fixes #681 --- .../protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java index ca8f23115..dc3239f30 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java @@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.minecraft.Environment; import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; @@ -61,6 +62,13 @@ public class Chunk1_9_3_4Type extends PartialType { List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + // Read all the remaining bytes (workaround for #681) + if (input.readableBytes() > 0) { + byte[] array = Type.REMAINING_BYTES.read(input); + if (Via.getManager().isDebug()) + System.out.println("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ); + } + return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData); }