Merge commit 'ca705be2649a205caac2a449704b55dd029ea13b' into pullstream

This commit is contained in:
Rebekah 2024-02-14 06:40:56 -05:00
commit 6491d718d2
Signed by: oneechanhax
GPG Key ID: 183EB7902964DAE5
2 changed files with 20 additions and 2 deletions

View File

@ -76,6 +76,7 @@ rs2k
SamJBarney
Schwertspize
Seadragon91 (Lukas Pioch)
sleirsgoevy (Sergey Lisov)
Sofapriester
Spekdrum (Pablo Beltran)
SphinxC0re

View File

@ -212,12 +212,16 @@ inline void cChunkDataSerializer::Serialize47(const int a_ChunkX, const int a_Ch
m_Packet.WriteBEInt32(a_ChunkX);
m_Packet.WriteBEInt32(a_ChunkZ);
m_Packet.WriteBool(true); // "Ground-up continuous", or rather, "biome data present" flag
m_Packet.WriteBEUInt16(Bitmask.first);
// Minecraft 1.8 does not like completely empty packets
// Send one completely empty chunk section if this is the case
m_Packet.WriteBEUInt16(Bitmask.first ? Bitmask.first : 1);
// Write the chunk size:
// Account for the single empty section if sending an empty chunk
const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
const size_t ChunkSize = (
Bitmask.second * (ChunkBlockData::SectionBlockCount * 2 + ChunkLightData::SectionLightCount * 2) + // Blocks and lighting
(Bitmask.second ? Bitmask.second : 1) * (ChunkBlockData::SectionBlockCount * 2 + ChunkLightData::SectionLightCount * 2) + // Blocks and lighting
BiomeDataSize // Biome data
);
m_Packet.WriteVarInt32(static_cast<UInt32>(ChunkSize));
@ -266,6 +270,19 @@ inline void cChunkDataSerializer::Serialize47(const int a_ChunkX, const int a_Ch
}
});
// Serialize a single empty section if sending an empty chunk
if (!Bitmask.first)
{
// Block data (all air)
for (size_t i = 0; i < ChunkBlockData::SectionBlockCount * 2; i++)
{
m_Packet.WriteBEUInt8(0);
}
// Light data (XXX: sky light is not sent if in the nether)
m_Packet.WriteBuf(ChunkLightData::SectionLightCount, ChunkLightData::DefaultSkyLightValue);
m_Packet.WriteBuf(ChunkLightData::SectionLightCount, ChunkLightData::DefaultSkyLightValue);
}
// Write the biome data:
m_Packet.WriteBuf(a_BiomeMap, BiomeDataSize);
}