mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-29 15:49:09 +01:00
Various chunk tweaks.
This commit is contained in:
parent
72589fabcd
commit
7a6d3f4604
3 changed files with 12 additions and 12 deletions
|
@ -21,17 +21,15 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||
try {
|
||||
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(packet.getColumn());
|
||||
ByteBuf byteBuf = Unpooled.buffer(32);
|
||||
int count = 0;
|
||||
ChunkSection[] sections = chunkData.sections;
|
||||
for (int i = sections.length - 1; i >= 0; i--) {
|
||||
if (sections[i].isEmpty())
|
||||
continue;
|
||||
|
||||
count = i + 1;
|
||||
break;
|
||||
int sectionCount = 16;
|
||||
while (sections[sectionCount].isEmpty()) {
|
||||
sectionCount--;
|
||||
}
|
||||
sectionCount++;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < sectionCount; i++) {
|
||||
ChunkSection section = chunkData.sections[i];
|
||||
section.writeToNetwork(byteBuf);
|
||||
}
|
||||
|
@ -44,7 +42,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||
byteBuf.readBytes(payload);
|
||||
|
||||
LevelChunkPacket levelChunkPacket = new LevelChunkPacket();
|
||||
levelChunkPacket.setSubChunksLength(count);
|
||||
levelChunkPacket.setSubChunksLength(sectionCount);
|
||||
levelChunkPacket.setCachingEnabled(false);
|
||||
levelChunkPacket.setChunkX(packet.getColumn().getX());
|
||||
levelChunkPacket.setChunkZ(packet.getColumn().getZ());
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
|||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||
import org.geysermc.connector.network.translators.item.BedrockItem;
|
||||
import org.geysermc.connector.world.chunk.ChunkSection;
|
||||
import org.geysermc.connector.world.chunk.bitarray.BitArrayVersion;
|
||||
|
||||
public class ChunkUtils {
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class ChunkUtils {
|
|||
ChunkSection section = chunkData.sections[chunkY];
|
||||
|
||||
section.getBlockStorageArray()[0] = new org.geysermc.connector.world.chunk.BlockStorage();
|
||||
section.getBlockStorageArray()[1] = new org.geysermc.connector.world.chunk.BlockStorage();
|
||||
section.getBlockStorageArray()[1] = new org.geysermc.connector.world.chunk.BlockStorage(BitArrayVersion.V1);
|
||||
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
|
@ -77,7 +78,8 @@ public class ChunkUtils {
|
|||
BlockState block = storage.get(x, y, z);
|
||||
BedrockItem bedrockBlock = TranslatorsInit.getItemTranslator().getBedrockBlock(block);
|
||||
|
||||
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), bedrockBlock.getId() << 4 | bedrockBlock.getData());
|
||||
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
||||
bedrockBlock.getId() << 4 | bedrockBlock.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,9 @@ public class BlockStorage {
|
|||
buffer.writeIntLE(word);
|
||||
}
|
||||
|
||||
VarInts.writeUnsignedInt(buffer, palette.size());
|
||||
VarInts.writeInt(buffer, palette.size());
|
||||
palette.forEach(id -> {
|
||||
VarInts.writeUnsignedInt(buffer, id);
|
||||
VarInts.writeInt(buffer, id);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue