Template:Packet: Difference between revisions

From wiki.vg
Jump to navigation Jump to search
imported>Fenhl
(changed to single field per template)
imported>Fenhl
(changed to single field per template)
 
(3 intermediate revisions by the same user not shown)
(No difference)

Latest revision as of 22:03, 21 January 2015

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
}}

{{#ifeq:1|1|

}}{{#ifeq:1|1|}}{{#ifeq:0|1|
Packet IDStateBound toField nameField typeNotes
0x01PlayClientEntity ID {{#switch:Int
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=Int

}}
The player's Entity ID (EID)

}} {{#ifeq:0|1|

}}{{#ifeq:0|1|}}{{#ifeq:0|1|
Packet IDStateBound toField nameField typeNotes
0x{{{id}}}{{{state}}}{{{bound}}}Gamemode {{#switch:Unsigned Byte
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=Unsigned Byte

}}
0: Survival, 1: Creative, 2: Adventure, 3: Spectator. Bit 3 (0x08) is the hardcore flag.

}} {{#ifeq:0|1|

}}{{#ifeq:0|1|}}{{#ifeq:0|1|
Packet IDStateBound toField nameField typeNotes
0x{{{id}}}{{{state}}}{{{bound}}}Dimension {{#switch:Byte
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=Byte

}}
-1: Nether, 0: Overworld, 1: End

}} {{#ifeq:0|1|

}}{{#ifeq:0|1|}}{{#ifeq:0|1|
Packet IDStateBound toField nameField typeNotes
0x{{{id}}}{{{state}}}{{{bound}}}Difficulty {{#switch:Unsigned Byte
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=Unsigned Byte

}}
0: Peaceful, 1: Easy, 2: Normal, 3: Hard

}} {{#ifeq:0|1|

}}{{#ifeq:0|1|}}{{#ifeq:0|1|
Packet IDStateBound toField nameField typeNotes
0x{{{id}}}{{{state}}}{{{bound}}}Max Players {{#switch:Unsigned Byte
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=Unsigned Byte

}}
Used by the client to draw the player list

}} {{#ifeq:0|1|

}}{{#ifeq:0|1|}}{{#ifeq:0|1|
Packet IDStateBound toField nameField typeNotes
0x{{{id}}}{{{state}}}{{{bound}}}Level Type {{#switch:String
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=String

}}
default, flat, largeBiomes, amplified, default_1_1

}} {{#ifeq:0|1|

}}{{#ifeq:0|1|}}{{#ifeq:1|1|
Packet IDStateBound toField nameField typeNotes
0x{{{id}}}{{{state}}}{{{bound}}}Reduced Debug Info {{#switch:Boolean
 |Chat=Chat
 |Metadata=Metadata
 |NBT Tag=NBT Tag
 |Object Data=Object Data
 |Slot=Slot
 |#default=Boolean

}}

}}