Difference between revisions of "Pre-release protocol"

From wiki.vg
Jump to navigation Jump to search
m
(14w02a)
Line 6: Line 6:
 
=== 14w02a ===
 
=== 14w02a ===
  
 +
* Added 'Unknown' to Chat Message Clientbound
 +
* Changed Player Position And Look's 'OnGround' type from boolean to byte
 +
* Changed Open Inventory's 'Inventory Type' type from byte to string
 +
* Added Packet 0x41
 +
* Removed Client Settings' 'Difficulty'
  
 
== Protocol Version ==
 
== Protocol Version ==
Line 14: Line 19:
 
| 14w02a ||  
 
| 14w02a ||  
 
|}
 
|}
 +
 +
== Play ==
 +
 +
=== Clientbound ===
 +
 +
==== Chat Message ====
 +
{| class="wikitable"
 +
! Packet ID !! Field Name !! Field Type !! Notes
 +
|-
 +
| rowspan=1 | 0x02
 +
| JSON Data || String || https://gist.github.com/thinkofdeath/e882ce057ed83bac0a1c , Limited to 32767 bytes
 +
|-
 +
| Unknown || Byte ||
 +
|}
 +
{{Warning|Malformed JSON will disconnect the client}}
 +
 +
==== Player Position And Look ====
 +
 +
Updates the players position on the server.
 +
If the distance between the last known position of the player on the server and the new position set by this packet is greater than 100 units will result in the client being kicked for "You moved too quickly :( (Hacking?)"
 +
Also if the fixed-point number of X or Z is set greater than <code>3.2E7D</code> the client will be kicked for "Illegal position"
 +
 +
Yaw is measured in degrees, and does not follow classical trigonometry rules. The unit circle of yaw on the XZ-plane starts at (0, 1) and turns counterclockwise, with 90 at (-1, 0), 180 at (0,-1) and 270 at (1, 0). Additionally, yaw is not clamped to between 0 and 360 degrees; any number is valid, including negative numbers and numbers greater than 360.
 +
 +
Pitch is measured in degrees, where 0 is looking straight ahead, -90 is looking straight up, and 90 is looking straight down.
 +
 +
The yaw of player (in degrees), standing at point (x0,z0) and looking towards point (x,z) one can be calculated with:
 +
  l = x-x0
 +
  w = z-z0
 +
  c = sqrt( l*l + w+w )
 +
  alpha1 = -arcsin(l/c)/PI*180
 +
  alpha2 =  arccos(w/c)/PI*180
 +
  if alpha2 > 90 then
 +
    yaw = 180 - alpha1
 +
  else
 +
    yaw = alpha1
 +
 +
You can get a unit vector from a given yaw/pitch via:
 +
  x = -cos(pitch) * sin(yaw)
 +
  y = -sin(pitch)
 +
  z =  cos(pitch) * cos(yaw)
 +
 +
{| class="wikitable"
 +
! Packet ID !! Field Name !! Field Type !! Notes
 +
|-
 +
| rowspan=6| 0x08
 +
| X || Double || Absolute position
 +
|-
 +
| Y || Double || Absolute position
 +
|-
 +
| Z || Double || Absolute position
 +
|-
 +
| Yaw || Float || Absolute rotation on the X Axis, in degrees
 +
|-
 +
| Pitch || Float || Absolute rotation on the Y Axis, in degrees
 +
|-
 +
| On Ground? || Byte ||
 +
|}
 +
 +
==== Open Window ====
 +
 +
This is sent to the client when it should open an inventory, such as a chest, workbench, or furnace. This message is not sent anywhere for clients opening their own inventory.
 +
 +
{| class="wikitable"
 +
! Packet ID !! Field Name !! Field Type !! Notes
 +
|-
 +
| rowspan="6" | 0x2D
 +
| Window id || Unsigned Byte || A unique id number for the window to be displayed.  Notchian server implementation is a counter, starting at 1.
 +
|-
 +
| Inventory Type || String || The window type to use for display.  Check below
 +
|-
 +
| Window title || String || The title of the window.
 +
|-
 +
| Number of Slots || Unsigned Byte || Number of slots in the window (excluding the number of slots in the player inventory).
 +
|-
 +
| Use provided window title || Bool || If false, the client will look up a string like "window.minecart". If true, the client uses what the server provides.
 +
|-
 +
| Entity ID || Int || EntityHorse's entityId. Only sent when window type is equal to "EntityHorse".
 +
|}
 +
 +
See [[Inventory#Windows|inventory windows]] for further information.
 +
 +
==== Packet 0x41 ====
 +
 +
{| class="wikitable"
 +
! Packet ID !! Field Name !! Field Type !! Notes
 +
|-
 +
| rowspan="1" | 0x41
 +
| Unknown || Unsigned Byte ||
 +
|}
 +
 +
=== Serverbound ===
 +
 +
==== Client Settings ====
 +
 +
Sent when the player connects, or when settings are changed.
 +
 +
{| class="wikitable"
 +
! Packet ID !! Field Name !! Field Type !! Notes
 +
|-
 +
| rowspan="6" | 0x15
 +
| Locale || String || en_GB
 +
|-
 +
| View distance || Byte || 0-3 for 'far', 'normal', 'short', 'tiny'.
 +
|-
 +
| Chat flags || Byte || Chat settings. See notes below.
 +
|-
 +
| Chat colours || Bool || "Colours" multiplayer setting
 +
|-
 +
| Show Cape || Bool || Client-side "show cape" option
 +
|}
 +
 +
Chat flags has several values packed into one byte.
 +
 +
'''Chat Enabled:''' Bits 0-1. 00: Enabled.  01: Commands only.  10: Hidden.

Revision as of 16:07, 9 January 2014

This page documents the changes from the last stable Minecraft release (currently 1.7.4, protocol 4) to the current pre-release. Note that this page contains bleeding-edge information that may not be completely or correctly documented. He who wishes to commandeer the merging of this into Protocol when an update is made must be sure to respect any changes that may have occured to the respective packets there.

Protocol History

14w02a

  • Added 'Unknown' to Chat Message Clientbound
  • Changed Player Position And Look's 'OnGround' type from boolean to byte
  • Changed Open Inventory's 'Inventory Type' type from byte to string
  • Added Packet 0x41
  • Removed Client Settings' 'Difficulty'

Protocol Version

Version Protocol
14w02a

Play

Clientbound

Chat Message

Packet ID Field Name Field Type Notes
0x02 JSON Data String https://gist.github.com/thinkofdeath/e882ce057ed83bac0a1c , Limited to 32767 bytes
Unknown Byte

Warning.png Malformed JSON will disconnect the client

Player Position And Look

Updates the players position on the server. If the distance between the last known position of the player on the server and the new position set by this packet is greater than 100 units will result in the client being kicked for "You moved too quickly :( (Hacking?)" Also if the fixed-point number of X or Z is set greater than 3.2E7D the client will be kicked for "Illegal position"

Yaw is measured in degrees, and does not follow classical trigonometry rules. The unit circle of yaw on the XZ-plane starts at (0, 1) and turns counterclockwise, with 90 at (-1, 0), 180 at (0,-1) and 270 at (1, 0). Additionally, yaw is not clamped to between 0 and 360 degrees; any number is valid, including negative numbers and numbers greater than 360.

Pitch is measured in degrees, where 0 is looking straight ahead, -90 is looking straight up, and 90 is looking straight down.

The yaw of player (in degrees), standing at point (x0,z0) and looking towards point (x,z) one can be calculated with:

 l = x-x0
 w = z-z0
 c = sqrt( l*l + w+w )
 alpha1 = -arcsin(l/c)/PI*180
 alpha2 =  arccos(w/c)/PI*180
 if alpha2 > 90 then
   yaw = 180 - alpha1
 else
   yaw = alpha1

You can get a unit vector from a given yaw/pitch via:

 x = -cos(pitch) * sin(yaw)
 y = -sin(pitch)
 z =  cos(pitch) * cos(yaw)
Packet ID Field Name Field Type Notes
0x08 X Double Absolute position
Y Double Absolute position
Z Double Absolute position
Yaw Float Absolute rotation on the X Axis, in degrees
Pitch Float Absolute rotation on the Y Axis, in degrees
On Ground? Byte

Open Window

This is sent to the client when it should open an inventory, such as a chest, workbench, or furnace. This message is not sent anywhere for clients opening their own inventory.

Packet ID Field Name Field Type Notes
0x2D Window id Unsigned Byte A unique id number for the window to be displayed. Notchian server implementation is a counter, starting at 1.
Inventory Type String The window type to use for display. Check below
Window title String The title of the window.
Number of Slots Unsigned Byte Number of slots in the window (excluding the number of slots in the player inventory).
Use provided window title Bool If false, the client will look up a string like "window.minecart". If true, the client uses what the server provides.
Entity ID Int EntityHorse's entityId. Only sent when window type is equal to "EntityHorse".

See inventory windows for further information.

Packet 0x41

Packet ID Field Name Field Type Notes
0x41 Unknown Unsigned Byte

Serverbound

Client Settings

Sent when the player connects, or when settings are changed.

Packet ID Field Name Field Type Notes
0x15 Locale String en_GB
View distance Byte 0-3 for 'far', 'normal', 'short', 'tiny'.
Chat flags Byte Chat settings. See notes below.
Chat colours Bool "Colours" multiplayer setting
Show Cape Bool Client-side "show cape" option

Chat flags has several values packed into one byte.

Chat Enabled: Bits 0-1. 00: Enabled. 01: Commands only. 10: Hidden.