mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
fix: correct biome data array length calculation for 1.21.5+ terrain parsing
The biome PalettedContainer data array length was calculated as ceil(64 * bitsPerEntry / 64) which is incorrect for non-power-of-2 bit widths. The correct calculation uses SimpleBitStorage's formula: valuesPerLong = 64 / bitsPerEntry, then ceil(64 / valuesPerLong). For example, with bitsPerEntry=3: old formula gave 3 longs but the actual data contains 4 longs (valuesPerLong=21, ceil(64/21)=4). This bug was masked in 1.21.5 by excess padding bytes in chunk buffers (due to PalettedContainer.Data.getSerializedSize over-counting). MC 1.21.6 fixed the size calculation server-side, removing the padding and exposing this pre-existing MCC bug. Made-with: Cursor
This commit is contained in:
parent
1b0e27fde7
commit
067395ab2a
1 changed files with 3 additions and 1 deletions
|
|
@ -213,7 +213,9 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
// 1.21.5: No VarInt length prefix; calculate from bits per entry
|
||||
// Biome container has 64 entries (4x4x4)
|
||||
int dataArrayLength = (64 * bitsPerEntryBiome + 63) / 64;
|
||||
// Uses SimpleBitStorage: valuesPerLong = 64/bitsPerEntry, longs = ceil(64/valuesPerLong)
|
||||
int valuesPerLong = 64 / bitsPerEntryBiome;
|
||||
int dataArrayLength = (64 + valuesPerLong - 1) / valuesPerLong;
|
||||
dataTypes.DropData(dataArrayLength * 8, cache);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue