Allow to have "separate block" serialized properly

This commit is contained in:
Felix Cravic 2020-05-03 14:46:44 +02:00
parent 7fd8362d6c
commit df1653b0f6
2 changed files with 7 additions and 8 deletions

View File

@ -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);

View File

@ -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);
}