Properly handle non-full chunks in QuickReplaySender
This commit is contained in:
@@ -404,11 +404,40 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
|||||||
}
|
}
|
||||||
} else if (packet instanceof ServerChunkDataPacket) {
|
} else if (packet instanceof ServerChunkDataPacket) {
|
||||||
Column column = ((ServerChunkDataPacket) packet).getColumn();
|
Column column = ((ServerChunkDataPacket) packet).getColumn();
|
||||||
Chunk chunk = new Chunk(column);
|
if (column.hasBiomeData()) {
|
||||||
chunk.spawnTime = time;
|
Chunk chunk = new Chunk(column);
|
||||||
Chunk prev = activeChunks.put(coordToLong(column.getX(), column.getZ()), chunk);
|
chunk.spawnTime = time;
|
||||||
if (prev != null) {
|
Chunk prev = activeChunks.put(coordToLong(column.getX(), column.getZ()), chunk);
|
||||||
index = prev.writeToCache(indexOut, out, time, index);
|
if (prev != null) {
|
||||||
|
index = prev.writeToCache(indexOut, out, time, index);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Chunk chunk = activeChunks.get(coordToLong(column.getX(), column.getZ()));
|
||||||
|
if (chunk != null) {
|
||||||
|
int sectionY = 0;
|
||||||
|
for (com.github.steveice10.mc.protocol.data.game.chunk.Chunk section : column.getChunks()) {
|
||||||
|
if (section == null) {
|
||||||
|
sectionY++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BlockStorage toBlocks = section.getBlocks();
|
||||||
|
BlockStorage fromBlocks = chunk.currentBlockState[sectionY];
|
||||||
|
for (int y = 0; y < 16; y++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
BlockState fromState = fromBlocks.get(x, y, z);
|
||||||
|
BlockState toState = toBlocks.get(x, y, z);
|
||||||
|
if (!fromState.equals(toState)) {
|
||||||
|
Position pos = new Position(column.getX() << 4 | x, sectionY << 4 | y, column.getZ() << 4 | z);
|
||||||
|
chunk.blocks.put(time, new BlockChange(pos, fromState, toState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chunk.currentBlockState[sectionY] = toBlocks;
|
||||||
|
sectionY++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (packet instanceof ServerUnloadChunkPacket) {
|
} else if (packet instanceof ServerUnloadChunkPacket) {
|
||||||
ServerUnloadChunkPacket p = (ServerUnloadChunkPacket) packet;
|
ServerUnloadChunkPacket p = (ServerUnloadChunkPacket) packet;
|
||||||
|
|||||||
Reference in New Issue
Block a user