mirror of https://github.com/Minestom/Minestom.git
Allow to have "separate block" serialized properly
This commit is contained in:
parent
7fd8362d6c
commit
df1653b0f6
|
@ -291,10 +291,8 @@ public class Chunk implements Viewable {
|
|||
|
||||
short blockId = getBlockId(x, y, z);
|
||||
short customBlockId = getCustomBlockId(x, y, z);
|
||||
boolean isCustomBlock = customBlockId != 0;
|
||||
short id = isCustomBlock ? customBlockId : blockId;
|
||||
|
||||
if (id == 0)
|
||||
if (blockId == 0 && customBlockId == 0)
|
||||
continue;
|
||||
|
||||
Data data = blocksData.get(index);
|
||||
|
@ -305,8 +303,8 @@ public class Chunk implements Viewable {
|
|||
dos.writeInt(y);
|
||||
dos.writeInt(z);
|
||||
|
||||
dos.writeBoolean(isCustomBlock); // Determine the type of the ID
|
||||
dos.writeShort(id);
|
||||
dos.writeShort(blockId);
|
||||
dos.writeShort(customBlockId);
|
||||
|
||||
hasData = (data != null && (data instanceof SerializableData)) && hasData;
|
||||
dos.writeBoolean(hasData);
|
||||
|
|
|
@ -33,8 +33,9 @@ public class ChunkReader {
|
|||
int y = stream.readInt();
|
||||
int z = stream.readInt();
|
||||
|
||||
boolean isCustomBlock = stream.readBoolean();
|
||||
short blockId = stream.readShort();
|
||||
short customBlockId = stream.readShort();
|
||||
|
||||
boolean hasData = stream.readBoolean();
|
||||
Data data = null;
|
||||
|
||||
|
@ -45,8 +46,8 @@ public class ChunkReader {
|
|||
data = DataReader.readData(Unpooled.wrappedBuffer(dataArray));
|
||||
}
|
||||
|
||||
if (isCustomBlock) {
|
||||
chunkBatch.setCustomBlock(x, y, z, blockId, data);
|
||||
if (customBlockId != 0) {
|
||||
chunkBatch.setSeparateBlocks(x, y, z, blockId, customBlockId, data);
|
||||
} else {
|
||||
chunkBatch.setBlock(x, y, z, blockId, data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue