diff options
author | Alexander Harkness <me@bearbin.net> | 2024-07-01 00:27:51 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2024-11-04 10:09:54 +0100 |
commit | 416badb6b077321b73d4827b11077617d077adb8 (patch) | |
tree | d87af655c5da0c762db59c579d2a8697a401c27c | |
parent | Use named constant for section size rather than magic number. (diff) | |
download | cuberite-416badb6b077321b73d4827b11077617d077adb8.tar cuberite-416badb6b077321b73d4827b11077617d077adb8.tar.gz cuberite-416badb6b077321b73d4827b11077617d077adb8.tar.bz2 cuberite-416badb6b077321b73d4827b11077617d077adb8.tar.lz cuberite-416badb6b077321b73d4827b11077617d077adb8.tar.xz cuberite-416badb6b077321b73d4827b11077617d077adb8.tar.zst cuberite-416badb6b077321b73d4827b11077617d077adb8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Protocol/ChunkDataSerializer.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp index 6b5553ee7..6f95fb472 100644 --- a/src/Protocol/ChunkDataSerializer.cpp +++ b/src/Protocol/ChunkDataSerializer.cpp @@ -502,7 +502,21 @@ inline void cChunkDataSerializer::Serialize477(const int a_ChunkX, const int a_C // Write each chunk section... ChunkDef_ForEachSection(a_BlockData, a_LightData, { - m_Packet.WriteBEInt16(ChunkBlockData::SectionBlockCount); // a temp fix to make sure sections don't disappear + // Count non-air blocks. + int BlockCount = 0; + if (Blocks != nullptr) + { + for (size_t i = 0; i != ChunkBlockData::SectionBlockCount; i++) + { + const BLOCKTYPE BlockType = (*Blocks)[i]; + if (BlockType != E_BLOCK_AIR) + { + BlockCount++; + } + } + } + + m_Packet.WriteBEInt16(BlockCount); m_Packet.WriteBEUInt8(BitsPerEntry); m_Packet.WriteVarInt32(static_cast<UInt32>(ChunkSectionDataArraySize)); WriteBlockSectionSeamless<&Palette477>(Blocks, Metas, BitsPerEntry); |