Template:Packet

From wiki.vg
Jump to navigation Jump to search

Creates a packet table. For use on Protocol etc.

Usage

Each instance of the table stands for one packet field (one row of the table).

The first field of the packet must have {{{head=1}}} and include the following named parameters:

  • {{{id}}}: the packet ID, in hexadecimal, two digits, no 0x prefix.
  • {{{state}}}: the connection state in which the packet occurs, one of Handshaking, Play, Status, or Login.
  • {{{bound}}}: the direction of the packet: Server for client to server (serverbound), or Client for server to client (clientbound).
  • {{{rows}}}: the number of rows in the table body, a.k.a. the number of fields in the packet.

The positional parameters represent the field of the packet. They are:

  1. The name of the field (should be in title case).
  2. The field type (one of the Data Types or “Array of Type”). Some types are automatically linkified:
  3. Optionally, some explaining notes.

The last field of the packet must have {{{foot=1}}} to close the table.

Example

{{Packet|head=1|id=01|state=Play|bound=Client|rows=7
 |Entity ID
 |Int
 |The player's Entity ID (EID)
}}
{{Packet
 |Gamemode
 |Unsigned Byte
 |0: Survival, 1: Creative, 2: Adventure, 3: Spectator. Bit 3 (<code>0x08</code>) is the hardcore flag.
}}
{{Packet
 |Dimension
 |Byte
 |-1: Nether, 0: Overworld, 1: End
}}
{{Packet
 |Difficulty
 |Unsigned Byte
 |0: Peaceful, 1: Easy, 2: Normal, 3: Hard
}}
{{Packet
 |Max Players
 |Unsigned Byte
 |Used by the client to draw the player list
}}
{{Packet
 |Level Type
 |String
 |default, flat, largeBiomes, amplified, default_1_1
}}
{{Packet
 |Reduced Debug Info
 |Boolean
 |foot=1
}}
Packet IDStateBound toField nameField typeNotes
0x01PlayClientEntity ID IntThe player's Entity ID (EID)
Gamemode Unsigned Byte0: Survival, 1: Creative, 2: Adventure, 3: Spectator. Bit 3 (0x08) is the hardcore flag.
Dimension Byte-1: Nether, 0: Overworld, 1: End
Difficulty Unsigned Byte0: Peaceful, 1: Easy, 2: Normal, 3: Hard
Max Players Unsigned ByteUsed by the client to draw the player list
Level Type Stringdefault, flat, largeBiomes, amplified, default_1_1
Reduced Debug Info Boolean