Skip to content

Commit c5a9143

Browse files
committed
Improve chunk palette-reading if the palette has only one entry
1 parent 9bc77c7 commit c5a9143

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public int getSectionY() {
231231

232232
public BlockState getBlockState(int x, int y, int z) {
233233
if (blocks.length == 0) return BlockState.AIR;
234+
if (palette.length == 1) return palette[0];
234235

235236
x &= 0xF; y &= 0xF; z &= 0xF; // Math.floorMod(pos.getX(), 16)
236237

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil118.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public Section(CompoundTag sectionData) {
210210
if (skyLight.length < 2048 && skyLight.length > 0) skyLight = Arrays.copyOf(skyLight, 2048);
211211

212212
this.bitsPerBlock = this.blocks.length >> 6; // available longs * 64 (bits per long) / 4096 (blocks per section) (floored result)
213-
this.bitsPerBiome = Math.max(1, Integer.SIZE - Integer.numberOfLeadingZeros(this.biomePalette.length - 1));
213+
this.bitsPerBiome = Integer.SIZE - Integer.numberOfLeadingZeros(this.biomePalette.length - 1);
214214
}
215215

216216
private BlockState readBlockStatePaletteEntry(CompoundTag paletteEntry) {
@@ -235,6 +235,7 @@ public int getSectionY() {
235235

236236
public BlockState getBlockState(int x, int y, int z) {
237237
if (blocks.length == 0) return BlockState.AIR;
238+
if (blockPalette.length == 1) return blockPalette[0];
238239

239240
x &= 0xF; y &= 0xF; z &= 0xF; // Math.floorMod(pos.getX(), 16)
240241

@@ -266,7 +267,7 @@ public LightData getLightData(int x, int y, int z, LightData target) {
266267

267268
public String getBiome(int x, int y, int z) {
268269
if (biomePalette.length == 0) return Biome.DEFAULT.getValue();
269-
if (biomes.length == 0) return biomePalette[0];
270+
if (biomePalette.length == 1 || biomes.length == 0) return biomePalette[0];
270271

271272
x = (x & 0xF) / 4; // Math.floorMod(pos.getX(), 16) / 4
272273
z = (z & 0xF) / 4;

0 commit comments

Comments
 (0)