Difference between revisions of "Template:Packet"

From wiki.vg
Jump to navigation Jump to search
(updated for current packet tables)
(changed to single field per template)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<includeonly><table class="wikitable"><thead><tr><th>Packet ID</th><th>State</th><th>Bound to</th><th>Field name</th><th>Field type</th><th>Notes</th></tr></thead><!--
+
<includeonly>{{#ifeq:{{{head|0}}}|1|<table class="wikitable"><tr><th>Packet ID</th><th>State</th><th>Bound to</th><th>Field name</th><th>Field type</th><th>Notes</th></tr>}}<tr>{{#ifeq:{{{head|0}}}|1|<td rowspan="{{{rowspan|1}}}"><code>0x{{{id}}}</code></td><td rowspan="{{{rowspan|1}}}">{{{state}}}</td><td rowspan="{{{rowspan|1}}}">{{{bound}}}</td>}}<td>{{{1}}}</td><td>{{#switch:{{{2}}}
 +
  |Chat=[[Chat]]
 +
  |Metadata=[[Entities#Entity Metadata Format|Metadata]]
 +
  |NBT Tag=[[NBT|NBT Tag]]
 +
  |Object Data=[[Object Data]]
 +
  |Slot=[[Slot Data|Slot]]
 +
  |#default={{{2}}}
 +
}}</td><td>{{{3|}}}</td></tr>{{#ifeq:{{{foot|0}}}|1|</table>}}</includeonly><noinclude>Creates a packet table. For use on [[Protocol]] etc.
  
--><tbody><tr><td rowspan="{{{rowspan|{{#if:{{{5|}}}|{{#if:{{{8|}}}|{{#if:{{{11|}}}|{{#if:{{{14|}}}|{{#if:{{{17|}}}|{{#if:{{{20|}}}|{{#if:{{{23|}}}|{{#if:{{{26|}}}|{{#if:{{{29|}}}|{{#if:{{{32|}}}|{{#if:{{{35|}}}|12|11}}|10}}|9}}|8}}|7}}|6}}|5}}|4}}|3}}|2}}|1}}}}}"><code>0x{{{id}}}</code></td><td rowspan="{{{rowspan|{{#if:{{{5|}}}|{{#if:{{{8|}}}|{{#if:{{{11|}}}|{{#if:{{{14|}}}|{{#if:{{{17|}}}|{{#if:{{{20|}}}|{{#if:{{{23|}}}|{{#if:{{{26|}}}|{{#if:{{{29|}}}|{{#if:{{{32|}}}|{{#if:{{{35|}}}|12|11}}|10}}|9}}|8}}|7}}|6}}|5}}|4}}|3}}|2}}|1}}}}}">{{{state}}}</td><td rowspan="{{{rowspan|{{#if:{{{5|}}}|{{#if:{{{8|}}}|{{#if:{{{11|}}}|{{#if:{{{14|}}}|{{#if:{{{17|}}}|{{#if:{{{20|}}}|{{#if:{{{23|}}}|{{#if:{{{26|}}}|{{#if:{{{29|}}}|{{#if:{{{32|}}}|{{#if:{{{35|}}}|12|11}}|10}}|9}}|8}}|7}}|6}}|5}}|4}}|3}}|2}}|1}}}}}">{{{bound}}}</td><td>{{{1}}}</td><td>{{{2}}}</td><td>{{{3|}}}</td></tr><!--
+
== Usage ==
  
-->{{#if:{{{5|}}}|<tr><td>{{{4}}}</td><td>{{{5}}}</td><td>{{{6|}}}</td></tr>}}<!--
+
Each instance of the table stands for one packet field (one row of the table).
-->{{#if:{{{8|}}}|<tr><td>{{{7}}}</td><td>{{{8}}}</td><td>{{{9|}}}</td></tr>}}<!--
 
-->{{#if:{{{11|}}}|<tr><td>{{{10}}}</td><td>{{{11}}}</td><td>{{{12|}}}</td></tr>}}<!--
 
-->{{#if:{{{14|}}}|<tr><td>{{{13}}}</td><td>{{{14}}}</td><td>{{{15|}}}</td></tr>}}<!--
 
-->{{#if:{{{17|}}}|<tr><td>{{{16}}}</td><td>{{{17}}}</td><td>{{{18|}}}</td></tr>}}<!--
 
-->{{#if:{{{20|}}}|<tr><td>{{{19}}}</td><td>{{{20}}}</td><td>{{{21|}}}</td></tr>}}<!--
 
-->{{#if:{{{23|}}}|<tr><td>{{{22}}}</td><td>{{{23}}}</td><td>{{{24|}}}</td></tr>}}<!--
 
-->{{#if:{{{26|}}}|<tr><td>{{{25}}}</td><td>{{{26}}}</td><td>{{{27|}}}</td></tr>}}<!--
 
-->{{#if:{{{29|}}}|<tr><td>{{{28}}}</td><td>{{{29}}}</td><td>{{{30|}}}</td></tr>}}<!--
 
-->{{#if:{{{32|}}}|<tr><td>{{{31}}}</td><td>{{{32}}}</td><td>{{{33|}}}</td></tr>}}<!--
 
-->{{#if:{{{35|}}}|<tr><td>{{{34}}}</td><td>{{{35}}}</td><td>{{{36|}}}</td></tr>}}<!--
 
  
--></table></includeonly><noinclude>Creates a packet table. For use on [[Protocol]] etc. Currently supports up to 12 fields.
+
The first field of the packet must have <code><nowiki>{{{head=1}}}</nowiki></code> and include the following named parameters:
 +
 
 +
* <code><nowiki>{{{id}}}</nowiki></code>: the packet ID, in hexadecimal, two digits, no <code>0x</code> prefix.
 +
* <code><nowiki>{{{state}}}</nowiki></code>: the connection state in which the packet occurs, one of [[Protocol#Handshaking|Handshaking]], [[Protocol#Play|Play]], [[Protocol#Status|Status]], or [[Protocol#Login|Login]].
 +
* <code><nowiki>{{{bound}}}</nowiki></code>: the direction of the packet: <code>Server</code> for client to server (serverbound), or <code>Client</code> for server to client (clientbound).
 +
* <code><nowiki>{{{rows}}}</nowiki></code>: 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:
 +
 
 +
# The name of the field (should be in title case).
 +
# The field type (one of the [[Data Types]] or “Array of Type”). Some types are automatically linkified:
 +
#* [[Chat]]
 +
#* [[Entities#Entity Metadata Format|Metadata]]
 +
#* [[NBT|NBT Tag]]
 +
#* [[Object Data]]
 +
#* [[Slot Data|Slot]]
 +
# Optionally, some explaining notes.
 +
 
 +
The last field of the packet must have <code><nowiki>{{{foot=1}}}</nowiki></code> to close the table.
  
 
== Example ==
 
== Example ==
  
<pre>{{Packet|id=07|state=Play|bound=Client
+
<pre>{{Packet|head=1|id=01|state=Play|bound=Client|rows=7
  |Dimension|Int|-1: The Nether, 0: The Overworld, 1: The End
+
|Entity ID
  |Difficulty|Unsigned Byte|0: Peaceful, 1: Easy, 2: Normal, 3: Hard
+
|Int
  |Gamemode|Unsigned Byte|0: survival, 1: creative, 2: adventure. The hardcore flag is not included
+
|The player's Entity ID (EID)
  |Level Type|String|Same as [[Protocol#Join Game|Join Game]]
+
}}
 +
{{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
 
}}</pre>
 
}}</pre>
  
{{Packet|id=07|state=Play|bound=Client
+
{{Packet|head=1|id=01|state=Play|bound=Client|rows=7
  |Dimension|Int|-1: The Nether, 0: The Overworld, 1: The End
+
|Entity ID
  |Difficulty|Unsigned Byte|0: Peaceful, 1: Easy, 2: Normal, 3: Hard
+
|Int
  |Gamemode|Unsigned Byte|0: survival, 1: creative, 2: adventure. The hardcore flag is not included
+
|The player's Entity ID (EID)
  |Level Type|String|Same as [[Protocol#Join Game|Join Game]]
+
}}
 +
{{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
 
}}
 
}}
 +
  
 
[[Category:Templates]]
 
[[Category:Templates]]

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