diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/region/MCARegion.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/region/MCARegion.java index 69ec90f2b..e273d4c39 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/region/MCARegion.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/region/MCARegion.java @@ -92,11 +92,11 @@ public Chunk loadChunk(int chunkX, int chunkZ) throws IOException { channel.position(xzChunk * 4); readFully(channel, header, 0, 4); - int offset = header[0] << 16; + int offset = (header[0] & 0xFF) << 16; offset |= (header[1] & 0xFF) << 8; offset |= header[2] & 0xFF; offset *= 4096; - int size = header[3] * 4096; + int size = (header[3] & 0xFF) * 4096; if (size == 0) return Chunk.EMPTY_CHUNK; @@ -131,7 +131,7 @@ public void iterateAllChunks(ChunkConsumer consumer) throws IOException { for (int z = 0; z < 32; z++) { int xzChunk = (z & 0b11111) << 5 | (x & 0b11111); - int size = header[xzChunk * 4 + 3] * 4096; + int size = (header[xzChunk * 4 + 3] & 0xFF) * 4096; if (size == 0) continue; int chunkX = chunkStartX + x; @@ -146,7 +146,7 @@ public void iterateAllChunks(ChunkConsumer consumer) throws IOException { // load chunk only if consumers filter returns true if (consumer.filter(chunkX, chunkZ, timestamp)) { i = xzChunk * 4; - int offset = header[i++] << 16; + int offset = (header[i++] & 0xFF) << 16; offset |= (header[i++] & 0xFF) << 8; offset |= header[i] & 0xFF; offset *= 4096;