оптимизация передачи данных block light
This commit is contained in:
@@ -23,9 +23,17 @@ public class BlockLocation implements Cloneable {
|
||||
|
||||
public BlockLocation toGlobal(ChunkSection chunkSection) {
|
||||
return new BlockLocation(
|
||||
(chunkSection.getX() << 8) + x,
|
||||
(chunkSection.getY() << 8) + y,
|
||||
(chunkSection.getZ() << 8) + z
|
||||
(chunkSection.getX() << 4) + x,
|
||||
(chunkSection.getY() << 4) + y,
|
||||
(chunkSection.getZ() << 4) + z
|
||||
);
|
||||
}
|
||||
|
||||
public BlockLocation toLocal() {
|
||||
return new BlockLocation(
|
||||
x - (x >> 4 << 4),
|
||||
y - (y >> 4 << 4),
|
||||
z - (z >> 4 << 4)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -184,14 +184,12 @@ public class ChunkDataPacket implements SCPacket {
|
||||
private TIntList palette = new TIntArrayList();
|
||||
private int dataItems = 0;
|
||||
private ByteArrayOutputNetStream dataArray = new ByteArrayOutputNetStream();
|
||||
private ByteArrayOutputNetStream blockLight = new ByteArrayOutputNetStream();
|
||||
private NibbleArray blockLight = new NibbleArray();
|
||||
private NibbleArray skyLight = new NibbleArray();
|
||||
|
||||
private int idxHalfLong = 0;
|
||||
private int idxHalfByte1 = 0;
|
||||
|
||||
private long dataValueCompacted = 0;
|
||||
private int blockLightCompacted = 0;
|
||||
|
||||
private int serializeBlockState(BlockType blockType) {
|
||||
return (blockType.getId() << 4) | blockType.getMeta();
|
||||
@@ -230,14 +228,7 @@ public class ChunkDataPacket implements SCPacket {
|
||||
}
|
||||
|
||||
// block light data
|
||||
if (idxHalfByte1 == 0) {
|
||||
blockLightCompacted = block.getLight();
|
||||
idxHalfByte1++;
|
||||
} else {
|
||||
blockLightCompacted = (blockLightCompacted << 4) | block.getLight();
|
||||
blockLight.writeByte(blockLightCompacted);
|
||||
idxHalfByte1 = 0;
|
||||
}
|
||||
blockLight.set(block.getLocation().toLocal(), block.getLight());
|
||||
}
|
||||
|
||||
void addSkyLight(int x, int y, int z, int value) {
|
||||
@@ -256,7 +247,7 @@ public class ChunkDataPacket implements SCPacket {
|
||||
netOutputStream.writeBytes(dataArray.toByteArray()); // Data Array
|
||||
// </Data Array>
|
||||
// <Block Light>
|
||||
netOutputStream.writeBytes(blockLight.toByteArray());
|
||||
netOutputStream.writeBytes(blockLight.getRawData());
|
||||
// </Block Light>
|
||||
// <Sky Light>
|
||||
netOutputStream.writeBytes(skyLight.getRawData());
|
||||
|
||||
Reference in New Issue
Block a user