From 8712ca364b08a4f443919f9f95299ff7a805fd55 Mon Sep 17 00:00:00 2001 From: TheMode Date: Mon, 31 May 2021 20:39:54 +0200 Subject: [PATCH] WIP chunk packet support --- .../packet/server/play/ChunkDataPacket.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java index 1d281aafd..28d9b0482 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java @@ -81,8 +81,9 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket { int mask = 0; ByteBuf blocks = Unpooled.buffer(MAX_BUFFER_SIZE); + final boolean fullChunk = sections.length == 0; for (byte i = 0; i < CHUNK_SECTION_COUNT; i++) { - if (false || (sections.length == CHUNK_SECTION_COUNT && sections[i] != 0)) { + if (fullChunk || (sections.length == CHUNK_SECTION_COUNT && sections[i] != 0)) { final Section section = paletteStorage.getSections()[i]; if (section == null) { // Section not loaded @@ -95,7 +96,9 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket { } } - writer.writeVarInt(mask); + // TODO variable size + writer.writeVarInt(1); + writer.writeLong(mask); // TODO: don't hardcode heightmaps // Heightmap @@ -163,7 +166,11 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket { chunkX = reader.readInt(); chunkZ = reader.readInt(); - int mask = reader.readVarInt(); + int maskCount = reader.readVarInt(); + long[] masks = new long[maskCount]; + for(int i=0;i