First comes a VarInt of the packet's length (in bytes). Then there is the 1 byte packet ID, and finally the payload.
First of all, a handshake packet must be sent:
Field | Example | Field Type | Length |
---|---|---|---|
Packet ID | 0x00 | Byte | 1 byte |
Protocol Version | 47 | VarInt | Depends |
Server Address | localhost | String | Depends |
Server Port | 25565 | Unsigned Short | 2 bytes |
Next State | 1 | VarInt | Depends |
The "Next State" field comes in two forms: 1 is for status ping, 2 is for login.