Difference between revisions of "Pre-release protocol"

From wiki.vg
Jump to navigation Jump to search
Line 35: Line 35:
 
* Changed Update Score's Value type to VarInt
 
* Changed Update Score's Value type to VarInt
 
* Changed Teams' Player count type to VarInt
 
* Changed Teams' Player count type to VarInt
* New packet 'Combat State'
+
* New packet 'Combat Event'
 
==== Serverbound ====
 
==== Serverbound ====
 
* Changed Keep Alive's Keep Alive ID type to VarInt
 
* Changed Keep Alive's Keep Alive ID type to VarInt

Revision as of 21:51, 24 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

14w04b

  • Spawn Painting now uses the 'Position' data type
  • Changed Spawn Painting's Direction type to Unsigned Byte

14w04a

  • Encoding for 'Position' changed

Clientbound

  • Changed Entity Equipment's EntityId type to VarInt
  • Changed Update Health's Food type to VarInt
  • Changed Use Bed's EntityId type to VarInt
  • Added new fields to Spawn Player
  • Changed Collect Item's EntityId(s) types to VarInt
  • Changed Entity Velocity's EntityId type to VarInt
  • Changed Destroy Entities' Length type to VarInt
  • Changed Destroy Entities' EntityIds type to VarInt array
  • Changed Entity's EntityId type to VarInt
  • Changed Entity Teleport's EntityId type to VarInt
  • Changed Entity Head Look's EntityId type to VarInt
  • Changed Entity Metadata's EntityId type to Varint
  • Changed Entity Effect's EntityId type to VarInt
  • Changed Entity Effect's Duration type to VarInt
  • Changed Remove Entity Effect's EntityId type to VarInt
  • Changed Set Experience's Level type to VarInt
  • Changed Set Experience's Total Experience type to VarInt
  • Changed Entity Properties's EntityId type to VarInt
  • Changed Entity Properties's List Length type to VarInt
  • Changed Player List Item's Ping type to VarInt
  • Changed Update Score's Value type to VarInt
  • Changed Teams' Player count type to VarInt
  • New packet 'Combat Event'

Serverbound

  • Changed Keep Alive's Keep Alive ID type to VarInt
  • Changed Use Entity's Target type to VarInt
  • Changed Use Entity's Mouse type to Unsigned Byte
  • Removed everything from Animation
  • Changed Entity Action's EntityId type to VarInt
  • Changed Entity Action's Action ID type to Unsigned Byte
  • Changed Entity Action's Jump Boast type to VarInt
  • Merged Steer Vehicle's Jump and Unmount into a Bit Field
  • Changed Client Status's Action ID type to Unsigned Byte

14w03a

  • New data type 'Position'

Clientbound

  • Spawn Position now uses the 'Position' data type
  • Use Bed now uses the 'Position' data type
  • Block Change now uses the 'Position' data type
  • Block Action now uses the 'Position' data type
  • Block Break Animation now uses the 'Position' data type
  • Effect now uses the 'Position' data type
  • Sign Update now uses the 'Position' data type
  • Update Block Entity now uses the 'Position' data type
  • Sign Editor Open nows uses the 'Position' data type

Serverbound

  • Player Digging now uses the 'Position' data type
  • Player Block Placement now uses the 'Position' data type
  • Update Sign now uses the 'Position' data type
  • Client Settings 'show cape' type changed from boolean to unsigned byte

14w02a

  • Added 'Position' to Chat Message Clientbound
  • Remove Player Position And Look's 'OnGround' clientbound
  • Added 'Flags' to Player Position And Look clientbound
  • Changed Open Inventory's 'Inventory Type' type from byte to string
  • Added Server Difficulty
  • Removed Client Settings' 'Difficulty'

Protocol Version

Version Protocol
14w02a 5
14w03a 6
14w04a 7
14w04b 8

New data types

Position

A single long split up as followed:

0xFFFFFFF000000000 - X

0x0000000FF0000000 - Y

0x000000000FFFFFFF - Z

Play

Clientbound

Chat Message

Identifying the difference between Chat/System Message is important as it helps respect the user's chat visibility options. While position 2 accepts json formatting it will not display, old style formatting works

Packet ID Field Name Field Type Notes
0x02 JSON Data String https://gist.github.com/thinkofdeath/e882ce057ed83bac0a1c , Limited to 32767 bytes
Position Byte 0 - Chat (chat box) ,1 - System Message (chat box), 2 - Above action bar

Warning.png Malformed JSON will disconnect the client

Entity Equipment

Packet ID Field Name Field Type Notes
0x04 EntityID VarInt Entity's ID
Slot Short Equipment slot: 0=held, 1-4=armor slot (1 - boots, 2 - leggings, 3 - chestplate, 4 - helmet)
Item Slot Item in slot format

Spawn Position

Sent by the server after login to specify the coordinates of the spawn point (the point at which players spawn at, and which the compass points to). It can be sent at any time to update the point compasses point at.

Packet ID Field Name Field Type Notes
0x05 Location Position Spawn location

Update Health

Sent by the server to update/set the health of the player it is sent to.

Food saturation acts as a food "overcharge". Food values will not decrease while the saturation is over zero. Players logging in automatically get a saturation of 5.0. Eating food increases the saturation as well as the food bar.

Packet ID Field Name Field Type Notes
0x06 Health Float 0 or less = dead, 20 = full HP
Food VarInt 0 - 20
Food Saturation Float Seems to vary from 0.0 to 5.0 in integer increments


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)

About the flags field:

 <Dinnerbone> It's a bitfield, X/Y/Z/Y_ROT/X_ROT. If X is set, the x value is relative and not absolute.
Packet ID Field Name Field Type Notes
0x08 X Double Absolute/Relative position
Y Double Absolute/Relative position
Z Double Absolute/Relative position
Yaw Float Absolute/Relative rotation on the X Axis, in degrees
Pitch Float Absolute/Relative rotation on the Y Axis, in degrees
Flags Byte
X 0x01
Y 0x02
Z 0x04
Y_ROT 0x08
X_ROT 0x10

Use Bed

This packet tells that a player goes to bed.

The client with the matching Entity ID will go into bed mode.

This Packet is sent to all nearby players including the one sent to bed.

Packet ID Field Name Field Type Notes
0x0A Entity ID VarInt Player ID
Location Position Block location of the head part of the bed

Spawn Player

This packet is sent by the server when a player comes into visible range, not when a player joins.

Servers can, however, safely spawn player entities for players not in visible range. The client appears to handle it correctly.

Packet ID Field Name Field Type Notes
0x0C Entity ID VarInt Player's Entity ID
Player UUID String Player's UUID
Player Name String Player's Name
Data length VarInt
Data Name String Name of the property as return by the session server's /hasJoined. E.g: textures
Value String Value of the property (base64) as return by the session server's /hasJoined
Signature String Signature of the property (base64) as return by the session server's /hasJoined.
X Int Player X as a Fixed-Point number
Y Int Player X as a Fixed-Point number
Z Int Player X as a Fixed-Point number
Yaw Byte Player rotation as a packed byte
Pitch Byte Player rotation as a packet byte
Current Item Short The item the player is currently holding. Note that this should be 0 for "no item", unlike -1 used in other packets. A negative value crashes clients.
Metadata Metadata The client will crash if no metadata is sent

Warning.png The client will crash if no metadata is sent Warning.png The client will disconnect if both UUID and Name are empty

Collect Item

Sent by the server when someone picks up an item lying on the ground - its sole purpose appears to be the animation of the item flying towards you. It doesn't destroy the entity in the client memory, and it doesn't add it to your inventory. The server only checks for items to be picked up after each Player Position and [Player Position & Look packet sent by the client.

Packet ID Field Name Field Type Notes
0x0D Collected Entity ID VarInt
Collector Entity ID VarInt

Spawn Painting

This packet shows location, name, and type of painting.

Calculating the center of an image: given a (width x height) grid of cells, with (0, 0) being the top left corner, the center is (max(0, width / 2 - 1), height / 2). E.g.

2x1 (1, 0) 4x4 (1, 2)


Packet ID Field Name Field Type Notes
0x10 Entity ID VarInt Entity's ID
Title String Name of the painting. Max length 13
Location Position Center coordinates
Direction Unsigned Byte Direction the painting faces (0 -z, 1 -x, 2 +z, 3 +x)


Entity Velocity

Velocity is believed to be in units of 1/8000 of a block per server tick (50ms); for example, -1343 would move (-1343 / 8000) = −0.167875 blocks per tick (or −3,3575 blocks per second).

Packet ID Field Name Field Type Notes
0x12 Entity ID VarInt Entity's ID
Velocity X Short Velocity on the X axis
Velocity Y Short Velocity on the Y axis
Velocity Z Short Velocity on the Z axis

Destroy Entities

Sent by the server when an list of Entities is to be destroyed on the client.

Packet ID Field Name Field Type Notes
0x13 Count VarInt Length of following array
Entity IDs Array of VarInt The list of entities of destroy

Entity

Most entity-related packets are subclasses of this packet. When sent from the server to the client, it may initialize the entry.

For player entities, either this packet or any move/look packet is sent every game tick. So the meaning of this packet is basically that the entity did not move/look since the last such packet.

Packet ID Field Name Field Type Notes
0x14 Entity ID VarInt Entity's ID

Entity Teleport

This packet is sent by the server when an entity moves more than 4 blocks.

Packet ID Field Name Field Type Notes
0x18 Entity ID VarInt Entity's ID
X Int X position as a Fixed-Point number
Y Int Y position as a Fixed-Point number
Z Int Z position as a Fixed-Point number
Yaw Byte The X Axis rotation as a fraction of 360
Pitch Byte The Y Axis rotation as a fraction of 360

Entity Head Look

Changes the direction an entity's head is facing.

Packet ID Field Name Field Type Notes
0x19 Entity ID VarInt Entity's ID
Head Yaw Byte Head yaw in steps of 2p/256

Entity Metadata

Packet ID Field Name Field Type Notes
0x1C Entity ID VarInt Entity's ID
Metadata Metadata


Entity Effect

Packet ID Field Name Field Type Notes
0x1D Entity ID VarInt Entity's ID
Effect ID Byte See [[1]]
Amplifier Byte
Duration VarInt

Remove Entity Effect

Packet ID Field Name Field Type Notes
0x1E Entity ID VarInt Entity's ID
Effect ID Byte

Set Experience

Sent by the server when the client should change experience levels.

Packet ID Field Name Field Type Notes
0x1F Experience bar Float Between 0 and 1
Level VarInt
Total Experience VarInt

Entity Properties

Packet ID Field Name Field Type Notes
0x20 Entity ID VarInt Entity's ID
Count Int Length of following array
Properties Array of Property Data

Property Data structure:

Field Name Field Type Notes
Key String
Value Double
List Length VarInt Number of list elements that follow.
Modifiers Array of Modifier Data http://www.minecraftwiki.net/wiki/Attribute#Modifiers

Known key values:

Key Default Min Max Label
generic.maxHealth 20.0 0.0 Double.MaxValue Max Health
generic.followRange 32.0 0.0 2048.0 Follow Range
generic.knockbackResistance 0.0 0.0 1.0 Knockback Resistance
generic.movementSpeed 0.699999988079071 0.0 Double.MaxValue Movement Speed
generic.attackDamage 2.0 0.0 Double.MaxValue
horse.jumpStrength 0.7 0.0 2.0 Jump Strength
zombie.spawnReinforcements 0.0 0.0 1.0 Spawn Reinforcements Chance

Modifier Data structure:

Field Name Field Type Notes
UUID 128-bit integer
Amount Double
Operation Byte


Block Change

Packet ID Field Name Field Type Notes
0x23 Location Position Block Coordinates
Block ID VarInt The new block ID for the block
Block Metadata Unsigned Byte The new metadata for the block

Block Action

This packet is used for a number of things:

  • Chests opening and closing
  • Pistons pushing and pulling
  • Note blocks playing

See Also: Block Actions

Packet ID Field Name Field Type Notes
0x24 Location Position Block Coordinates
Byte 1 Unsigned Byte Varies depending on block - see Block_Actions
Byte 2 Unsigned Byte Varies depending on block - see Block_Actions
Block Type VarInt The block type for the block

Block Break Animation

0-9 are the displayable destroy stages and each other number means that there is no animation on this coordinate.

You can also set an animation to air! The animation will still be visible.

If you need to display several break animations at the same time you have to give each of them a unique Entity ID.

Also if you set the coordinates to a special block like water etc. it won't show the actual break animation but some other interesting effects. (Water will loose it's transparency)

Packet ID Field Name Field Type Notes
0x25 Entity ID VarInt Entity's ID
Location Position Block Position
Destroy Stage Byte 0 - 9

Effect

Sent when a client is to play a sound or particle effect.

By default, the minecraft client adjusts the volume of sound effects based on distance. The final boolean field is used to disable this, and instead the effect is played from 2 blocks away in the correct direction. Currently this is only used for effect 1013 (mob.wither.spawn), and is ignored for any other value by the client.

Packet ID Field Name Field Type Notes
0x28 Effect ID Int The ID of the effect, see below.
Location Position The location of the effect
Data Int Extra data for certain effects, see below.
Disable relative volume Bool See above
Effects
ID Name
Sound
1000 random.click
1001 random.click
1002 random.bow
1003 random.door_open or random.door_close (50/50 chance)
1004 random.fizz
1005 Play a music disc. Data Record ID
(1006 not assigned)
1007 mob.ghast.charge
1008 mob.ghast.fireball
1009 mob.ghast.fireball, but with a lower volume.
1010 mob.zombie.wood
1011 mob.zombie.metal
1012 mob.zombie.woodbreak
1013 mob.wither.spawn
1014 mob.wither.shoot
1015 mob.bat.takeoff
1016 mob.zombie.infect
1017 mob.zombie.unfect
1018 mob.enderdragon.end
1020 random.anvil_break
1021 random.anvil_use
1022 random.anvil_land
Particle
2000 Spawns 10 smoke particles, e.g. from a fire. Data direction, see below
2001 Block break. Data Block ID
2002 Splash potion. Particle effect + glass break sound. Data Potion ID
2003 Eye of ender entity break animation - particles and sound
2004 Mob spawn particle effect: smoke + flames
2005 Spawn "happy villager" effect (green crosses), used for bonemealing vegetation.

Smoke directions:

ID Direction
0 South - East
1 South
2 South - West
3 East
4 (Up or middle ?)
5 West
6 North - East
7 North
8 North - West

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.

Update Sign

This message is sent from the server to the client whenever a sign is discovered or created. This message is NOT sent when a sign is destroyed or unloaded.

Packet ID Field Name Field Type Notes
0x33 Location Position Block Coordinates
Line 1 String First line of text in the sign
Line 2 String Second line of text in the sign
Line 3 String Third line of text in the sign
Line 4 String Fourth line of text in the sign

Update Block Entity

Essentially a block update on a block entity.

Packet ID Field Name Field Type Notes
0x35 Location Position
Action Unsigned Byte The type of update to perform
Data length Short Varies
NBT Data Byte Array Present if data length > 0. Compressed with gzip. Varies

Actions

  • 1: Set mob displayed inside a mob spawner. Custom 1 contains the mob type

Sign Editor Open

Sent on placement of sign.

Packet ID Field Name Field Type Notes
0x36 Location Position Block coordinates

Player List Item

Sent by the notchian server to update the user list (<tab> in the client).

Packet ID Field Name Field Type Notes
0x38 Player name String Supports chat colouring, limited to 16 characters.
Online Bool The client will remove the user from the list if false.
Ping VarInt Ping, presumably in ms.

Update Score

This is sent to the client when it should update a scoreboard item.

Packet ID Field Name Field Type Notes
0x3C Item Name String An unique name to be displayed in the list.
Update/Remove Byte 0 to create/update an item. 1 to remove an item.
Score Name String The unique name for the scoreboard to be updated. Only sent when Update/Remove does not equal 1.
Value VarInt The score to be displayed next to the entry. Only sent when Update/Remove does not equal 1.

Warning.png The final String and Int are only sent if the Update/Remove Byte does not equal 1

Teams

Creates and updates teams.

Packet ID Field Name Field Type Notes
0x3E Team Name String A unique name for the team. (Shared with scoreboard).
Mode Byte If 0 then the team is created.

If 1 then the team is removed.

If 2 the team team information is updated.

If 3 then new players are added to the team.

If 4 then players are removed from the team.

Team Display Name String Only if Mode = 0 or 2.
Team Prefix String Only if Mode = 0 or 2. Displayed before the players' name that are part of this team.
Team Suffix String Only if Mode = 0 or 2. Displayed after the players' name that are part of this team.
Friendly fire Byte Only if Mode = 0 or 2; 0 for off, 1 for on, 3 for seeing friendly invisibles
Player count VarInt Only if Mode = 0 or 3 or 4. Number of players in the array
Players Array of strings Only if Mode = 0 or 3 or 4. Players to be added/remove from the team.


Server Difficulty

Changes the difficulty setting in the client's option menu

Packet ID Field Name Field Type Notes
0x41 Difficulty Unsigned Byte 0:PEACEFUL, 1:EASY, 2:NORMAL, 3: HARD


Combat Event

Packet ID Field Name Field Type Notes
0x42 Event Unsigned Byte 0 ENTER_COMBAT, 1 END_COMBAT, 2 ENTITY_DEAD
Duration VarInt Only for END_COMBAT
Entity ID Int Only for END_COMBAT
Player ID VarInt Only for ENTITY_DEAD
Entity ID Int Only for ENTITY_DEAD
Message String Only for ENTITY_DEAD

Serverbound

Keep Alive

The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same packet.

Packet ID Field Name Field Type Notes
0x00 Keep Alive ID VarInt

Use Entity

This packet is sent from the client to the server when the client attacks or right-clicks another entity (a player, minecart, etc).

A Notchian server only accepts this packet if the entity being attacked/used is visible without obstruction and within a 4-unit radius of the player's position.

Note that middle-click in creative mode is interpreted by the client and sent as a Creative Inventory Action packet instead.

Packet ID Field Name Field Type Notes
0x02 Target VarInt
Mouse Unsigned Byte 0 = Left-click, 1 = Right-click


Player Digging

Sent when the player mines a block. A Notchian server only accepts digging packets with coordinates within a 6-unit radius of the player's position.

Packet ID Field Name Field Type Notes
0x07 Status Byte The action the player is taking against the block (see below)
Location Position Block position
Face Byte The face being hit (see below)

Status can (currently) be one of six values:

Meaning Value
Started digging 0
Cancelled digging 1
Finished digging 2
Drop item stack 3
Drop item 4
Shoot arrow / finish eating 5

Notchian clients send a 0 (started digging) when they start digging and a 2 (finished digging) once they think they are finished. If digging is aborted, the client simply send a 1 (Cancel digging).

Status code 4 (drop item) is a special case. In-game, when you use the Drop Item command (keypress 'q'), a dig packet with a status of 4, and all other values set to 0, is sent from client to server. Status code 3 is similar, but drops the entire stack.

Status code 5 (shoot arrow / finish eating) is also a special case. The x, y and z fields are all set to 0 like above, with the exception of the face field, which is set to 255.

The face can be one of six values, representing the face being hit:

Value 0 1 2 3 4 5
Offset -Y +Y -Z +Z -X +X

In 1.7.3, when a player opens a door with left click the server receives Packet 0xE+start digging and opens the door.

Player Block Placement

Packet ID Field Name Field Type Notes
0x08 Location Position Block position
Direction Byte The offset to use for block/item placement (see below)
Held item Slot
Cursor position X Byte The position of the crosshair on the block
Cursor position Y Byte
Cursor position Z Byte

In normal operation (ie placing a block), this packet is sent once, with the values set normally.

This packet has a special case where X, Y, Z, and Direction are all -1. (Note that Y is unsigned so set to 255.) This special packet indicates that the currently held item for the player should have its state updated such as eating food, shooting bows, using buckets, etc.

In a Notchian Beta client, the block or item ID corresponds to whatever the client is currently holding, and the client sends one of these packets any time a right-click is issued on a surface, so no assumptions can be made about the safety of the ID. However, with the implementation of server-side inventory, a Notchian server seems to ignore the item ID, instead operating on server-side inventory information and holding selection. The client has been observed (1.2.5 and 1.3.2) to send both real item IDs and -1 in a single session.

Special note on using buckets: When using buckets, the Notchian client might send two packets: first a normal and then a special case. The first normal packet is sent when you're looking at a block (e.g. the water you want to scoop up). This normal packet does not appear to do anything with a Notchian server. The second, special case packet appears to perform the action - based on current position/orientation and with a distance check - it appears that buckets can only be used within a radius of 6 units.

Animation

Packet ID Field Name Field Type Notes
0x0A

Entity Action

Sent at least when crouching, leaving a bed, or sprinting. To send action animation to client use 0x28. The client will send this with Action ID = 3 when "Leave Bed" is clicked.

Packet ID Field Name Field Type Notes
0x0B Entity ID VarInt Player ID
Action ID Unsigned Byte The ID of the action, see below.
Jump Boost VarInt Horse jump boost. Ranged from 0 -> 100.

Action ID can be one of the following values:

ID Action
1 Crouch
2 Uncrouch
3 Leave bed
4 Start sprinting
5 Stop sprinting

Steer Vehicle

Packet ID Field Name Field Type Notes
0x0C Sideways Float Positive to the left of the player
Forward Float Positive forward
Flags Unsigned Byte 0x1 Jump, 0x2 Unmount


Update Sign

This message is sent from the client to the server when the "Done" button is pushed after placing a sign.

Packet ID Field Name Field Type Notes
0x12 Location Position Block Coordinates
Line 1 String First line of text in the sign
Line 2 String Second line of text in the sign
Line 3 String Third line of text in the sign
Line 4 String Fourth line of text in the sign

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
Displayed skin parts Unsigned Byte Unknown

Chat flags has several values packed into one byte.

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

Client Status

Sent when the client is ready to complete login and when the client is ready to respawn after death.

Packet ID Field Name Field Type Notes
0x16 Action ID Unsigned Byte See below

Action ID values:

Action ID Name
0 Perform respawn
1 Request stats
2 Open inventory achievement