From d36416cd2bcf2a138f6f7ca89646874e8448d94a Mon Sep 17 00:00:00 2001 From: p2r3 Date: Thu, 14 Aug 2025 14:44:48 +0300 Subject: [PATCH] limit world depth to y>0 --- src/packets.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/packets.c b/src/packets.c index 9b5b8dd..2deb04f 100644 --- a/src/packets.c +++ b/src/packets.c @@ -284,7 +284,7 @@ int sc_setCenterChunk (int client_fd, int x, int y) { // S->C Chunk Data and Update Light int sc_chunkDataAndUpdateLight (int client_fd, int _x, int _z) { - const int chunk_data_size = (4101 + sizeVarInt(256) + sizeof(network_block_palette)) * 24; + const int chunk_data_size = (4101 + sizeVarInt(256) + sizeof(network_block_palette)) * 20 + 6 * 4; writeVarInt(client_fd, 17 + sizeVarInt(chunk_data_size) + chunk_data_size); writeByte(client_fd, 0x27); @@ -298,8 +298,19 @@ int sc_chunkDataAndUpdateLight (int client_fd, int _x, int _z) { int x = _x * 16, z = _z * 16, y; + // send 4 chunk sections (up to Y=0) with no blocks + for (int i = 0; i < 4; i ++) { + writeUint16(client_fd, 4096); // block count + writeByte(client_fd, 0); // block bits + writeVarInt(client_fd, 85); // block palette (bedrock) + writeByte(client_fd, 0); // biome bits + writeByte(client_fd, 0); // biome palette + } + // reset watchdog and yield + wdt_reset(); + // send chunk sections - for (int i = 0; i < 24; i ++) { + for (int i = 4; i < 24; i ++) { y = i * 16 - 64; writeUint16(client_fd, 4096); // block count writeByte(client_fd, 8); // bits per entry