Tentative fix for #560

This commit is contained in:
Lukas Rieger (Blue) 2024-06-22 15:48:57 +02:00
parent 5ddf614026
commit 6032043126
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -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;