Skip to content

Commit

Permalink
Tentative fix for #560
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Jun 22, 2024
1 parent 5ddf614 commit 6032043
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 6032043

Please sign in to comment.