mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Fix chunk packet read
This commit is contained in:
parent
97d17f9b8b
commit
72bf894162
@ -39,8 +39,8 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
|||||||
public Biome[] biomes;
|
public Biome[] biomes;
|
||||||
public int chunkX, chunkZ;
|
public int chunkX, chunkZ;
|
||||||
|
|
||||||
public PaletteStorage paletteStorage;
|
public PaletteStorage paletteStorage = new PaletteStorage(8, 2);
|
||||||
public PaletteStorage customBlockPaletteStorage;
|
public PaletteStorage customBlockPaletteStorage = new PaletteStorage(8, 2);
|
||||||
|
|
||||||
public IntSet blockEntities;
|
public IntSet blockEntities;
|
||||||
public Int2ObjectMap<Data> blocksData;
|
public Int2ObjectMap<Data> blocksData;
|
||||||
@ -189,34 +189,36 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
|||||||
// Data
|
// Data
|
||||||
this.paletteStorage = new PaletteStorage(8, 1);
|
this.paletteStorage = new PaletteStorage(8, 1);
|
||||||
int blockArrayLength = reader.readVarInt();
|
int blockArrayLength = reader.readVarInt();
|
||||||
final long mask = masks[0]; // TODO support for variable size
|
if (maskCount > 0) {
|
||||||
for (int section = 0; section < CHUNK_SECTION_COUNT; section++) {
|
final long mask = masks[0]; // TODO support for variable size
|
||||||
boolean hasSection = (mask & 1 << section) != 0;
|
for (int section = 0; section < CHUNK_SECTION_COUNT; section++) {
|
||||||
if (!hasSection)
|
boolean hasSection = (mask & 1 << section) != 0;
|
||||||
continue;
|
if (!hasSection)
|
||||||
short blockCount = reader.readShort();
|
continue;
|
||||||
byte bitsPerEntry = reader.readByte();
|
short blockCount = reader.readShort();
|
||||||
|
byte bitsPerEntry = reader.readByte();
|
||||||
|
|
||||||
// Resize palette if necessary
|
// Resize palette if necessary
|
||||||
if (bitsPerEntry > paletteStorage.getSection(section).getBitsPerEntry()) {
|
if (bitsPerEntry > paletteStorage.getSection(section).getBitsPerEntry()) {
|
||||||
paletteStorage.getSection(section).resize(bitsPerEntry);
|
paletteStorage.getSection(section).resize(bitsPerEntry);
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve palette values
|
|
||||||
if (bitsPerEntry < 9) {
|
|
||||||
int paletteSize = reader.readVarInt();
|
|
||||||
for (int i = 0; i < paletteSize; i++) {
|
|
||||||
final int paletteValue = reader.readVarInt();
|
|
||||||
paletteStorage.getSection(section).getPaletteBlockMap().put((short) i, (short) paletteValue);
|
|
||||||
paletteStorage.getSection(section).getBlockPaletteMap().put((short) paletteValue, (short) i);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Read blocks
|
// Retrieve palette values
|
||||||
int dataLength = reader.readVarInt();
|
if (bitsPerEntry < 9) {
|
||||||
long[] data = paletteStorage.getSection(section).getBlocks();
|
int paletteSize = reader.readVarInt();
|
||||||
for (int i = 0; i < dataLength; i++) {
|
for (int i = 0; i < paletteSize; i++) {
|
||||||
data[i] = reader.readLong();
|
final int paletteValue = reader.readVarInt();
|
||||||
|
paletteStorage.getSection(section).getPaletteBlockMap().put((short) i, (short) paletteValue);
|
||||||
|
paletteStorage.getSection(section).getBlockPaletteMap().put((short) paletteValue, (short) i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read blocks
|
||||||
|
int dataLength = reader.readVarInt();
|
||||||
|
long[] data = paletteStorage.getSection(section).getBlocks();
|
||||||
|
for (int i = 0; i < dataLength; i++) {
|
||||||
|
data[i] = reader.readLong();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user