Fix anvil saving (minimum 4 bits per entry in block_states palette) (#2450)

This commit is contained in:
Samuel 2024-10-24 17:34:22 -04:00 committed by GitHub
parent bcb0301fb1
commit dba90a461b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -464,7 +464,7 @@ public class AnvilLoader implements IChunkLoader {
blockStates.put("palette", ListBinaryTag.listBinaryTag(BinaryTagTypes.COMPOUND, blockPaletteEntries));
if (blockPaletteEntries.size() > 1) {
// If there is only one entry we do not need to write the packed indices
var bitsPerEntry = (int) Math.max(1, Math.ceil(Math.log(blockPaletteEntries.size()) / Math.log(2)));
var bitsPerEntry = (int) Math.max(4, Math.ceil(Math.log(blockPaletteEntries.size()) / Math.log(2)));
blockStates.putLongArray("data", ArrayUtils.pack(blockIndices, bitsPerEntry));
}
sectionData.put("block_states", blockStates.build());