From 6408e678ff44daa4a3548f6cd6e130f937a626c9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 26 Aug 2018 08:51:56 -0700 Subject: [PATCH] fix short int conversion --- src/main/java/baritone/chunk/CachedRegion.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/chunk/CachedRegion.java b/src/main/java/baritone/chunk/CachedRegion.java index d8484ecd..e6aa4198 100644 --- a/src/main/java/baritone/chunk/CachedRegion.java +++ b/src/main/java/baritone/chunk/CachedRegion.java @@ -232,12 +232,19 @@ public final class CachedRegion implements IBlockTypeAccess { // 16 * 16 * 256 = 65536 so a short is enough // ^ haha jokes on leijurv, java doesn't have unsigned types so that isn't correct // also why would you have more than 32767 special blocks in a chunk - short numSpecialBlockTypes = in.readShort(); + // haha double jokes on you now it works for 65535 not just 32767 + int numSpecialBlockTypes = in.readShort(); + if (numSpecialBlockTypes < 0) { + numSpecialBlockTypes += 65536; + } for (int i = 0; i < numSpecialBlockTypes; i++) { String blockName = in.readUTF(); List locs = new ArrayList<>(); location[x][z].put(blockName, locs); - short numLocations = in.readShort(); + int numLocations = in.readShort(); + if (numLocations < 0) { + numLocations += 65536; + } for (int j = 0; j < numLocations; j++) { byte xz = in.readByte(); int X = xz & 0x0f;