Expand description
Packet framing, compression, and high-level encode/decode functions.
The Minecraft wire format is:
- Without compression:
[VarInt: packet_length][VarInt: packet_id][payload] - With compression (below threshold):
[VarInt: packet_length][0x00][VarInt: packet_id][payload] - With compression (above threshold):
[VarInt: packet_length][VarInt: uncompressed_size][zlib(packet_id + payload)]
Constants§
- MAX_
UNCOMPRESSED_ SIZE - Maximum allowed uncompressed packet size (8 MiB).
Functions§
- encode_
packet_ data - Encode a typed packet into raw bytes (packet ID + fields), without framing.
- read_
compressed_ frame - Decode the inner frame data when compression is enabled.
- read_
packet_ id - Read a packet ID from frame data.
- try_
read_ frame - Try to extract a single frame from the given buffer.
- write_
compressed_ frame - Wrap packet data with the compression format.
- write_
frame - Write a frame (length-prefixed) into the destination buffer.
inneris the already-encoded packet data (packet ID + payload).