Jump to content

Template:Packet: Difference between revisions

From WikiVG
imported>SirCmpwn
No edit summary
imported>Fenhl
changed to single field per template
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>
<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}}}
= Usage Example =
  |Chat=[[Chat]]
{{Packet|Keep Alive|0x00}}
  |Metadata=[[Entities#Entity Metadata Format|Metadata]]
</noinclude>
  |NBT Tag=[[NBT|NBT Tag]]
<h3><span id="{{{2}}}" class="mw-headline">{{{1}}} ({{{2}}})</span></h3>
  |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.
 
== Usage ==
 
Each instance of the table stands for one packet field (one row of the table).
 
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 ==
 
<pre>{{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
}}</pre>
 
{{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
}}
 
 
[[Category:Templates]]

Latest revision as of 22:03, 21 January 2015

Creates a packet table. For use on Protocol etc.

Usage[edit]

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[edit]

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

}}

}}