исправление передачи данных о sky light
раньше считалось, что это проблема в block light
This commit is contained in:
@@ -8,7 +8,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import mc.core.network.NetOutputStream;
|
import mc.core.network.NetOutputStream;
|
||||||
import mc.core.network.SCPacket;
|
import mc.core.network.SCPacket;
|
||||||
import mc.core.network.proto_1_12_2.ByteArrayOutputNetStream;
|
import mc.core.network.proto_1_12_2.ByteArrayOutputNetStream;
|
||||||
|
import mc.core.utils.NibbleArray;
|
||||||
|
import mc.core.world.Biome;
|
||||||
import mc.core.world.block.Block;
|
import mc.core.world.block.Block;
|
||||||
|
import mc.core.world.block.BlockLocation;
|
||||||
import mc.core.world.block.BlockType;
|
import mc.core.world.block.BlockType;
|
||||||
import mc.core.world.chunk.Chunk;
|
import mc.core.world.chunk.Chunk;
|
||||||
import mc.core.world.chunk.ChunkSection;
|
import mc.core.world.chunk.ChunkSection;
|
||||||
@@ -151,7 +154,7 @@ public class ChunkDataPacket implements SCPacket {
|
|||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int x = 15; x >= 0; x--) {
|
for (int x = 15; x >= 0; x--) {
|
||||||
palettedChunkSection.addBlock(chunkSection.getBlockLocal(x, y, z));
|
palettedChunkSection.addBlock(chunkSection.getBlockLocal(x, y, z));
|
||||||
palettedChunkSection.addSkyLight(chunkSection.getSkyLightLocal(x, y, z));
|
palettedChunkSection.addSkyLight(15-x, y, z, chunkSection.getSkyLightLocal(15-x, y, z));
|
||||||
|
|
||||||
if (biomeWrite) {
|
if (biomeWrite) {
|
||||||
biomes.writeByte(chunkSection.getBiomeLocal(x, z).getId());
|
biomes.writeByte(chunkSection.getBiomeLocal(x, z).getId());
|
||||||
@@ -182,15 +185,13 @@ public class ChunkDataPacket implements SCPacket {
|
|||||||
private int dataItems = 0;
|
private int dataItems = 0;
|
||||||
private ByteArrayOutputNetStream dataArray = new ByteArrayOutputNetStream();
|
private ByteArrayOutputNetStream dataArray = new ByteArrayOutputNetStream();
|
||||||
private ByteArrayOutputNetStream blockLight = new ByteArrayOutputNetStream();
|
private ByteArrayOutputNetStream blockLight = new ByteArrayOutputNetStream();
|
||||||
private ByteArrayOutputNetStream skyLight = new ByteArrayOutputNetStream();
|
private NibbleArray skyLight = new NibbleArray();
|
||||||
|
|
||||||
private int idxHalfLong = 0;
|
private int idxHalfLong = 0;
|
||||||
private int idxHalfByte1 = 0;
|
private int idxHalfByte1 = 0;
|
||||||
private int idxHalfByte2 = 0;
|
|
||||||
|
|
||||||
private long dataValueCompacted = 0;
|
private long dataValueCompacted = 0;
|
||||||
private int blockLightCompacted = 0;
|
private int blockLightCompacted = 0;
|
||||||
private int skyLightCompacted = 0;
|
|
||||||
|
|
||||||
private int serializeBlockState(BlockType blockType) {
|
private int serializeBlockState(BlockType blockType) {
|
||||||
return (blockType.getId() << 4) | blockType.getMeta();
|
return (blockType.getId() << 4) | blockType.getMeta();
|
||||||
@@ -239,16 +240,9 @@ public class ChunkDataPacket implements SCPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSkyLight(int value) {
|
void addSkyLight(int x, int y, int z, int value) {
|
||||||
// sky light data
|
// sky light data
|
||||||
if (idxHalfByte2 == 0) {
|
skyLight.set(x, y, z, value);
|
||||||
skyLightCompacted = value;
|
|
||||||
idxHalfByte2++;
|
|
||||||
} else {
|
|
||||||
skyLightCompacted = (skyLightCompacted << 4) | value;
|
|
||||||
skyLight.writeByte(skyLightCompacted);
|
|
||||||
idxHalfByte2 = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeToNetStream(final NetOutputStream netOutputStream) {
|
void writeToNetStream(final NetOutputStream netOutputStream) {
|
||||||
@@ -265,7 +259,7 @@ public class ChunkDataPacket implements SCPacket {
|
|||||||
netOutputStream.writeBytes(blockLight.toByteArray());
|
netOutputStream.writeBytes(blockLight.toByteArray());
|
||||||
// </Block Light>
|
// </Block Light>
|
||||||
// <Sky Light>
|
// <Sky Light>
|
||||||
netOutputStream.writeBytes(skyLight.toByteArray());
|
netOutputStream.writeBytes(skyLight.getRawData());
|
||||||
// </Sky Light>
|
// </Sky Light>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user