mojira.dev
MC-296121

ClientboundLevelChunkPacketData buffer size is too big

The Issue

In 25w07a (1.21.5 snapshot), the length prefix for the storage network serialization of PalettedContainer has been removed. Despite this, the method to pre-calculate the serialized size of a PalettedContainer (getSerializedSize) hasn’t been updated. I’ve attached a screenshot of the relevant Mojang-mapped decompiled code snippet in PalettedContainer.

Because the size of the buffer array in ClientboundLevelChunkPacketData is pre-calculated before being written, this now has the issue of being larger than actually needed. This doesn’t cause any real problems, but wastes network traffic and seems unintentional.

The Solution

Simply remove + VarInt.getByteSize(this.storage.getRaw().length) from PalettedContainer#getSerializedSize().

Environment

OS: Ubuntu 22.04.5 LTS
Java: OpenJDK Runtime Environment Temurin-21.0.4+7 (build 21.0.4+7-LTS)
(Doesn't matter)

Attachments

Comments 2

What’s the ingame impact of this? How can this issue be reproduced ingame?

In 25w07a, a “useless” field was removed from the network protocol related to chunks, but the space for this field is still “reserved”.

This issue isn’t really relevant ingame - it is relevant when looking at the network protocol sent between client and server. To reproduce this issue, you have to look at the bytes sent from the Minecraft server to the Minecraft client. But, you can quickly see the issue by looking at the (decompiled) code - as long as you know how to read it.

I know this is a technical issue rather than a problem with gameplay, but technical problems have been solved in the past, and this is a fairly simple one.

booky10

gegy

Plausible

Platform

Low

Networking

1.21.5

25w16a

Retrieved