Improve chunk palette-reading if the palette has only one entry

This commit is contained in:
Lukas Rieger (Blue) 2022-10-17 12:01:58 +02:00
parent 9bc77c7257
commit c5a91431cd
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
2 changed files with 4 additions and 2 deletions

View File

@ -231,6 +231,7 @@ public int getSectionY() {
public BlockState getBlockState(int x, int y, int z) {
if (blocks.length == 0) return BlockState.AIR;
if (palette.length == 1) return palette[0];
x &= 0xF; y &= 0xF; z &= 0xF; // Math.floorMod(pos.getX(), 16)

View File

@ -210,7 +210,7 @@ public Section(CompoundTag sectionData) {
if (skyLight.length < 2048 && skyLight.length > 0) skyLight = Arrays.copyOf(skyLight, 2048);
this.bitsPerBlock = this.blocks.length >> 6; // available longs * 64 (bits per long) / 4096 (blocks per section) (floored result)
this.bitsPerBiome = Math.max(1, Integer.SIZE - Integer.numberOfLeadingZeros(this.biomePalette.length - 1));
this.bitsPerBiome = Integer.SIZE - Integer.numberOfLeadingZeros(this.biomePalette.length - 1);
}
private BlockState readBlockStatePaletteEntry(CompoundTag paletteEntry) {
@ -235,6 +235,7 @@ public int getSectionY() {
public BlockState getBlockState(int x, int y, int z) {
if (blocks.length == 0) return BlockState.AIR;
if (blockPalette.length == 1) return blockPalette[0];
x &= 0xF; y &= 0xF; z &= 0xF; // Math.floorMod(pos.getX(), 16)
@ -266,7 +267,7 @@ public LightData getLightData(int x, int y, int z, LightData target) {
public String getBiome(int x, int y, int z) {
if (biomePalette.length == 0) return Biome.DEFAULT.getValue();
if (biomes.length == 0) return biomePalette[0];
if (biomePalette.length == 1 || biomes.length == 0) return biomePalette[0];
x = (x & 0xF) / 4; // Math.floorMod(pos.getX(), 16) / 4
z = (z & 0xF) / 4;