Skip to content

Packet handling

This page describes packet-handling behavior, aka how data is sent, received and parsed.

Generally, unless a packet is too large, such as a poorly compressed Chunk packet, one TCP Packet only contains one Minecraft Packet. So for a server/client that only ever interacts with a Vanilla server/client, this approach is sufficient.

However, in practice, it's fully supported for Minecraft packets to be split across multiple TCP packets. While this is normally reserved to the aforementioned Chunk packet, it can theoretically be done to any packet and still be understood by a vanilla server/client. As such a true vanilla-compliant server/client should be able to handle this as well.

An example

TCP Packet IdRaw DataDecoded data
#10x0DPacket Id for Player Position and Rotation
#20xC0, 0x21, 0x00, 0x00, 0x00, 0x00, (...)x=-8.50; y=66.00; cameraY=67.62; z=-4.50; Yaw=0.00; Pitch=0.00; OnGround=0;

A naive implementation would've just assumed the packet ended prematurely and was invalid, then tried to make sense of the non-existent, invalid packet 0xC0.