Skip to main content

Module wire

Module wire 

Source
Expand description

Minecraft Java Edition framing for the Server List Ping and the front of login: VarInt length-prefixed packets, the handshake, status JSON, ping/pong, Login Start, the login Disconnect, and the pre-1.7 legacy ping (0xFE) with its 0xFF kick reply.

Shared by the server and the client. Every length the peer announces is checked against a bound before anything is allocated for it.

Structs§

Handshake
LegacyPing
What a legacy (0xFE) ping carried.
Reader
A cursor over one packet’s body.

Constants§

DEFAULT_PROTOCOL
DEFAULT_VERSION_NAME
The version reported when the handler names none: 1.21.1.
IO_TIMEOUT
Deadline for each read and write, as the vanilla server’s read timeout.
LEGACY_PING_PROTOCOL
Protocol a 1.6 legacy ping carries.
LEGACY_TAIL_WAIT
How long the legacy ping’s optional tail (01, then FA + MC|PingHost) is waited for.
MAX_ADDRESS_CHARS
Handshake server address, in characters.
MAX_CLIENTBOUND_PACKET
Largest packet the client accepts: a status response is one String of at most 32767 chars.
MAX_JSON_CHARS
A Java String field holds at most 32767 UTF-16 units; the status JSON and a disconnect reason are both bounded by it.
MAX_LEGACY_PAYLOAD
Bytes of a 1.6 MC|PingHost payload accepted.
MAX_SAMPLE
Players listed in a status sample.
MAX_SERVERBOUND_PACKET
Largest packet a client may send the server (handshake, Login Start, ping are all tiny).
MAX_USERNAME_CHARS
Login Start player name, in characters.
STATE_LOGIN
STATE_STATUS
STATE_TRANSFER

Functions§

decode_legacy_reply
Decode a 0xFF kick reply (after the 0xFF and the u16 length) into status fields.
disconnect_json
A login Disconnect reason as the JSON text component the client renders.
encode_handshake
encode_legacy_ping
The 1.6 client’s legacy ping: FE 01 FA + MC|PingHost naming host:port.
encode_legacy_reply
The 0xFF kick packet answering a legacy ping. 1.4+ clients get §1\0protocol\0version\0motd\0online\0max; a bare 0xFE gets motd§online§max, where § is the separator and is therefore removed from the MOTD.
encode_login_start
Login Start as a client of protocol sends it.
format_uuid
frame
A complete packet (length prefix included) from an id and body.
get_varint
Decode a VarInt from the front of buf: (value, bytes used).
parse_handshake
parse_login_start
Login Start: the name, and the UUID when the version’s layout carries one. The layout changed four times; the trailing bytes are read by shape rather than by version number.
parse_uuid
plain_text
Flatten a chat component (a string, an object with text/translate/extra, or an array) to plain text. Nesting beyond 32 levels is cut off rather than followed.
put_string
put_varint
read_legacy_ping
Read the rest of a legacy ping after its 0xFE: the optional 0x01, then the optional 1.6 0xFA MC|PingHost plugin message. Each tail is waited for briefly, as the vanilla server does, because older clients send nothing more.
read_packet
Read one uncompressed packet’s id and body. None on a clean EOF between packets.
read_raw
Read one packet’s bytes after its length prefix; the announced length is checked against max before any of it is read. None on a clean EOF between packets.
split_id
Split an uncompressed packet into its id and body.
status_json
The status JSON for a minecraft_status action; client_protocol is unused unless the handler asks to echo it (protocol: "echo").