Skip to content

Commit 6032043

Browse files
committed
Tentative fix for #560
1 parent 5ddf614 commit 6032043

File tree

1 file changed

+4
-4
lines changed
  • BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/region

1 file changed

+4
-4
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/region/MCARegion.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ public Chunk loadChunk(int chunkX, int chunkZ) throws IOException {
9292
channel.position(xzChunk * 4);
9393
readFully(channel, header, 0, 4);
9494

95-
int offset = header[0] << 16;
95+
int offset = (header[0] & 0xFF) << 16;
9696
offset |= (header[1] & 0xFF) << 8;
9797
offset |= header[2] & 0xFF;
9898
offset *= 4096;
99-
int size = header[3] * 4096;
99+
int size = (header[3] & 0xFF) * 4096;
100100

101101
if (size == 0) return Chunk.EMPTY_CHUNK;
102102

@@ -131,7 +131,7 @@ public void iterateAllChunks(ChunkConsumer consumer) throws IOException {
131131
for (int z = 0; z < 32; z++) {
132132
int xzChunk = (z & 0b11111) << 5 | (x & 0b11111);
133133

134-
int size = header[xzChunk * 4 + 3] * 4096;
134+
int size = (header[xzChunk * 4 + 3] & 0xFF) * 4096;
135135
if (size == 0) continue;
136136

137137
int chunkX = chunkStartX + x;
@@ -146,7 +146,7 @@ public void iterateAllChunks(ChunkConsumer consumer) throws IOException {
146146
// load chunk only if consumers filter returns true
147147
if (consumer.filter(chunkX, chunkZ, timestamp)) {
148148
i = xzChunk * 4;
149-
int offset = header[i++] << 16;
149+
int offset = (header[i++] & 0xFF) << 16;
150150
offset |= (header[i++] & 0xFF) << 8;
151151
offset |= header[i] & 0xFF;
152152
offset *= 4096;

0 commit comments

Comments
 (0)