From 63d00073c5a9ea7c1278838593fd3afccb29be73 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Sun, 30 Aug 2020 00:56:54 +0200 Subject: [PATCH] Correctly calculate the number of bits-per block for 1.16-chunks --- .../java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java | 2 +- .../java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java | 2 +- .../java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java index 4871b80b..bb20ee98 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java @@ -184,7 +184,7 @@ public Section(CompoundTag sectionData) { this.palette = new BlockState[0]; } - this.bitsPerBlock = blocks.length * 64 / 4096; //64 bits per long and 4096 blocks per section + this.bitsPerBlock = this.blocks.length >> 6; // available longs * 64 (bits per long) / 4096 (blocks per section) (floored result) } public int getSectionY() { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java index c96b8932..5d0605ac 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java @@ -185,7 +185,7 @@ public Section(CompoundTag sectionData) { this.palette = new BlockState[0]; } - this.bitsPerBlock = blocks.length * 64 / 4096; //64 bits per long and 4096 blocks per section + this.bitsPerBlock = this.blocks.length >> 6; // available longs * 64 (bits per long) / 4096 (blocks per section) (floored result) } public int getSectionY() { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java index 637a467f..f3031763 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java @@ -185,9 +185,7 @@ public Section(CompoundTag sectionData) { this.palette = new BlockState[0]; } - - this.bitsPerBlock = 32 - Integer.numberOfLeadingZeros(palette.length - 1); - if (this.bitsPerBlock < 4) this.bitsPerBlock = 4; + this.bitsPerBlock = this.blocks.length >> 6; // available longs * 64 (bits per long) / 4096 (blocks per section) (floored result) } public int getSectionY() {