Protocol
Heads up!
|
This page presents a dissection of the current Minecraft protocol.
If you're having trouble, check out the FAQ or ask for help in the IRC channel (#mcdevs on chat.freenode.net).
Note: While you may use the contents of this page without restriction to create servers, clients, bots, etc… you still need to provide attribution to #mcdevs if you copy any of the contents of this page for publication elsewhere.
The changes between versions may be viewed at Protocol History.
Contents
- 1 Definitions
- 2 Packet format
- 3 Handshaking
- 4 Play
- 4.1 Clientbound
- 4.1.1 Spawn Object
- 4.1.2 Spawn Experience Orb
- 4.1.3 Spawn Global Entity
- 4.1.4 Spawn Mob
- 4.1.5 Spawn Painting
- 4.1.6 Spawn Player
- 4.1.7 Animation (clientbound)
- 4.1.8 Statistics
- 4.1.9 Block Break Animation
- 4.1.10 Update Block Entity
- 4.1.11 Block Action
- 4.1.12 Block Change
- 4.1.13 Boss Bar
- 4.1.14 Server Difficulty
- 4.1.15 Tab-Complete (clientbound)
- 4.1.16 Chat Message (clientbound)
- 4.1.17 Multi Block Change
- 4.1.18 Confirm Transaction (clientbound)
- 4.1.19 Close Window (clientbound)
- 4.1.20 Open Window
- 4.1.21 Window Items
- 4.1.22 Window Property
- 4.1.23 Set Slot
- 4.1.24 Set Cooldown
- 4.1.25 Plugin Message (clientbound)
- 4.1.26 Named Sound Effect
- 4.1.27 Disconnect (play)
- 4.1.28 Entity Status
- 4.1.29 Explosion
- 4.1.30 Unload Chunk
- 4.1.31 Change Game State
- 4.1.32 Keep Alive (clientbound)
- 4.1.33 Chunk Data
- 4.1.34 Effect
- 4.1.35 Particle
- 4.1.36 Join Game
- 4.1.37 Map
- 4.1.38 Entity Relative Move
- 4.1.39 Entity Look And Relative Move
- 4.1.40 Entity Look
- 4.1.41 Entity
- 4.1.42 Vehicle Move (clientbound)
- 4.1.43 Open Sign Editor
- 4.1.44 Player Abilities (clientbound)
- 4.1.45 Combat Event
- 4.1.46 Player List Item
- 4.1.47 Player Position And Look (clientbound)
- 4.1.48 Use Bed
- 4.1.49 Destroy Entities
- 4.1.50 Remove Entity Effect
- 4.1.51 Resource Pack Send
- 4.1.52 Respawn
- 4.1.53 Entity Head Look
- 4.1.54 World Border
- 4.1.55 Camera
- 4.1.56 Held Item Change (clientbound)
- 4.1.57 Display Scoreboard
- 4.1.58 Entity Metadata
- 4.1.59 Attach Entity
- 4.1 Clientbound
Definitions
The Minecraft server accepts connections from TCP clients and communicates with them using packets. A packet is a sequence of bytes sent over the TCP connection. The meaning of a packet depends both on its packet ID and the current state of the connection. The initial state of each connection is Handshaking, and state is switched using the packets Handshake (Handshaking, 0x00, serverbound) and Login Success (Login, 0x02, clientbound).
Data types
All data sent over the network (except for VarInt and VarLong) is big-endian, that is the bytes are sent from most significant byte to least significant byte. The majority of everyday computers are little-endian, therefore it may be necessary to change the endianness before sending data over the network.
Name | Size (bytes) | Encodes | Notes |
---|---|---|---|
Boolean | 1 | Either false or true | True is encoded as 0x01 , false as 0x00 .
|
Byte | 1 | An integer between -128 and 127 | Signed 8-bit integer, two's complement |
Unsigned Byte | 1 | An integer between 0 and 255 | Unsigned 8-bit integer |
Short | 2 | An integer between -32768 and 32767 | Signed 16-bit integer, two's complement |
Unsigned Short | 2 | An integer between 0 and 65535 | Unsigned 16-bit integer |
Int | 4 | An integer between -2147483648 and 2147483647 | Signed 32-bit integer, two's complement |
Long | 8 | An integer between -9223372036854775808 and 9223372036854775807 | Signed 64-bit integer, two's complement |
Float | 4 | A single-precision 32-bit IEEE 754 floating point number | |
Double | 8 | A double-precision 64-bit IEEE 754 floating point number | |
String (n) | ≥ 1 ≤ (n×3) + 3 |
A sequence of Unicode scalar values | UTF-8 string prefixed with its size in bytes as a VarInt. Maximum length of n characters, which varies by context. The encoding used on the wire is regular UTF-8, not Java's "slight modification". However, the length of the string for purposes of the length limit is its number of UTF-16 code units, that is, scalar values > U+FFFF are counted as two. Up to n × 3 bytes can be used to encode a UTF-8 string comprising n code units when converted to UTF-16, and both of those limits are checked. Maximum n value is 32767. The + 3 is due to the max size of a valid length VarInt.
|
Text Component | Varies | See Text formatting#Text components | Encoded as a NBT Tag, with the type of tag used depending on the case:
|
JSON Text Component | ≥ 1 ≤ (262144×3) + 3 |
See Text formatting#Text components | The maximum permitted length when decoding is 262144, but the Notchian server since 1.20.3 refuses to encode longer than 32767. This may be a bug. |
Identifier | ≥ 1 ≤ (32767×3) + 3 |
See Identifier below | Encoded as a String with max length of 32767. |
VarInt | ≥ 1 ≤ 5 |
An integer between -2147483648 and 2147483647 | Variable-length data encoding a two's complement signed 32-bit integer; more info in their section |
VarLong | ≥ 1 ≤ 10 |
An integer between -9223372036854775808 and 9223372036854775807 | Variable-length data encoding a two's complement signed 64-bit integer; more info in their section |
Entity Metadata | Varies | Miscellaneous information about an entity | See Entity_metadata#Entity Metadata Format |
Slot | Varies | An item stack in an inventory or container | See Slot Data |
NBT | Varies | Depends on context | See NBT |
Position | 8 | An integer/block position: x (-33554432 to 33554431), z (-33554432 to 33554431), y (-2048 to 2047) | x as a 26-bit integer, followed by z as a 26-bit integer, followed by y as a 12-bit integer (all signed, two's complement). See also the section below. |
Angle | 1 | A rotation angle in steps of 1/256 of a full turn | Whether or not this is signed does not matter, since the resulting angles are the same. |
UUID | 16 | A UUID | Encoded as an unsigned 128-bit integer (or two unsigned 64-bit integers: the most significant 64 bits and then the least significant 64 bits) |
BitSet | Varies | See #BitSet below | A length-prefixed bit set. |
Fixed BitSet (n) | ceil(n / 8) | See #Fixed BitSet below | A bit set with a fixed length of n bits. |
Optional X | 0 or size of X | A field of type X, or nothing | Whether or not the field is present must be known from the context. |
Array of X | count times size of X | Zero or more fields of type X | The count must be known from the context. |
X Enum | size of X | A specific value from a given list | The list of possible values and how each is encoded as an X must be known from the context. An invalid value sent by either side will usually result in the client being disconnected with an error or even crashing. |
Byte Array | Varies | Depends on context | This is just a sequence of zero or more bytes, its meaning should be explained somewhere else, e.g. in the packet description. The length must also be known from the context. |
ID or X | size of VarInt + (size of X or 0) | See #ID or X below | Either a registry ID or an inline data definition of type X. |
ID Set | Varies | See #ID Set below | Set of registry IDs specified either inline or as a reference to a tag. |
Sound Event | Varies | See #Sound Event below | Parameters for a sound event. |
Identifier
Identifiers are a namespaced location, in the form of minecraft:thing
. If the namespace is not provided, it defaults to minecraft
(i.e. thing
is minecraft:thing
). Custom content should always be in its own namespace, not the default one. Both the namespace and value can use all lowercase alphanumeric characters (a-z and 0-9), dot (.
), dash (-
), and underscore (_
). In addition, values can use slash (/
). The naming convention is lower_case_with_underscores
. More information.
For ease of determining whether a namespace or value is valid, here are regular expressions for each:
- Namespace:
[a-z0-9.-_]
- Value:
[a-z0-9.-_/]
VarInt and VarLong
Variable-length format such that smaller numbers use fewer bytes. These are very similar to Protocol Buffer Varints: the 7 least significant bits are used to encode the value and the most significant bit indicates whether there's another byte after it for the next part of the number. The least significant group is written first, followed by each of the more significant groups; thus, VarInts are effectively little endian (however, groups are 7 bits, not 8).
VarInts are never longer than 5 bytes, and VarLongs are never longer than 10 bytes. Within these limits, unnecessarily long encodings (e.g. 81 00
to encode 1) are allowed.
Pseudocode to read and write VarInts and VarLongs:
private static final int SEGMENT_BITS = 0x7F;
private static final int CONTINUE_BIT = 0x80;
public int readVarInt() {
int value = 0;
int position = 0;
byte currentByte;
while (true) {
currentByte = readByte();
value |= (currentByte & SEGMENT_BITS) << position;
if ((currentByte & CONTINUE_BIT) == 0) break;
position += 7;
if (position >= 32) throw new RuntimeException("VarInt is too big");
}
return value;
}
public long readVarLong() {
long value = 0;
int position = 0;
byte currentByte;
while (true) {
currentByte = readByte();
value |= (long) (currentByte & SEGMENT_BITS) << position;
if ((currentByte & CONTINUE_BIT) == 0) break;
position += 7;
if (position >= 64) throw new RuntimeException("VarLong is too big");
}
return value;
}
public void writeVarInt(int value) {
while (true) {
if ((value & ~SEGMENT_BITS) == 0) {
writeByte(value);
return;
}
writeByte((value & SEGMENT_BITS) | CONTINUE_BIT);
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
value >>>= 7;
}
}
public void writeVarLong(long value) {
while (true) {
if ((value & ~((long) SEGMENT_BITS)) == 0) {
writeByte(value);
return;
}
writeByte((value & SEGMENT_BITS) | CONTINUE_BIT);
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
value >>>= 7;
}
}
Note Minecraft's VarInts are identical to LEB128 with the slight change of throwing a exception if it goes over a set amount of bytes.
Note that Minecraft's VarInts are not encoded using Protocol Buffers; it's just similar. If you try to use Protocol Buffers Varints with Minecraft's VarInts, you'll get incorrect results in some cases. The major differences:
- Minecraft's VarInts are all signed, but do not use the ZigZag encoding. Protocol buffers have 3 types of Varints:
uint32
(normal encoding, unsigned),sint32
(ZigZag encoding, signed), andint32
(normal encoding, signed). Minecraft's are theint32
variety. Because Minecraft uses the normal encoding instead of ZigZag encoding, negative values always use the maximum number of bytes. - Minecraft's VarInts are never longer than 5 bytes and its VarLongs will never be longer than 10 bytes, while Protocol Buffer Varints will always use 10 bytes when encoding negative numbers, even if it's an
int32
.
Sample VarInts:
Value | Hex bytes | Decimal bytes |
---|---|---|
0 | 0x00 | 0 |
1 | 0x01 | 1 |
2 | 0x02 | 2 |
127 | 0x7f | 127 |
128 | 0x80 0x01 | 128 1 |
255 | 0xff 0x01 | 255 1 |
25565 | 0xdd 0xc7 0x01 | 221 199 1 |
2097151 | 0xff 0xff 0x7f | 255 255 127 |
2147483647 | 0xff 0xff 0xff 0xff 0x07 | 255 255 255 255 7 |
-1 | 0xff 0xff 0xff 0xff 0x0f | 255 255 255 255 15 |
-2147483648 | 0x80 0x80 0x80 0x80 0x08 | 128 128 128 128 8 |
Sample VarLongs:
Value | Hex bytes | Decimal bytes |
---|---|---|
0 | 0x00 | 0 |
1 | 0x01 | 1 |
2 | 0x02 | 2 |
127 | 0x7f | 127 |
128 | 0x80 0x01 | 128 1 |
255 | 0xff 0x01 | 255 1 |
2147483647 | 0xff 0xff 0xff 0xff 0x07 | 255 255 255 255 7 |
9223372036854775807 | 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x7f | 255 255 255 255 255 255 255 255 127 |
-1 | 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x01 | 255 255 255 255 255 255 255 255 255 1 |
-2147483648 | 0x80 0x80 0x80 0x80 0xf8 0xff 0xff 0xff 0xff 0x01 | 128 128 128 128 248 255 255 255 255 1 |
-9223372036854775808 | 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x01 | 128 128 128 128 128 128 128 128 128 1 |
Position
Note: What you are seeing here is the latest version of the Data types article, but the position type was different before 1.14.
64-bit value split into three signed integer parts:
- x: 26 MSBs
- z: 26 middle bits
- y: 12 LSBs
For example, a 64-bit position can be broken down as follows:
Example value (big endian): 01000110000001110110001100 10110000010101101101001000 001100111111
- The red value is the X coordinate, which is
18357644
in this example. - The blue value is the Z coordinate, which is
-20882616
in this example. - The green value is the Y coordinate, which is
831
in this example.
Encoded as follows:
((x & 0x3FFFFFF) << 38) | ((z & 0x3FFFFFF) << 12) | (y & 0xFFF)
And decoded as:
val = read_long(); x = val >> 38; y = val << 52 >> 52; z = val << 26 >> 38;
Note: The above assumes that the right shift operator sign extends the value (this is called an arithmetic shift), so that the signedness of the coordinates is preserved. In many languages, this requires the integer type of val
to be signed. In the absence of such an operator, the following may be useful:
if x >= 1 << 25 { x -= 1 << 26 } if y >= 1 << 11 { y -= 1 << 12 } if z >= 1 << 25 { z -= 1 << 26 }
Fixed-point numbers
Some fields may be stored as fixed-point numbers, where a certain number of bits represent the signed integer part (number to the left of the decimal point) and the rest represent the fractional part (to the right). Floating point numbers (float and double), in contrast, keep the number itself (mantissa) in one chunk, while the location of the decimal point (exponent) is stored beside it. Essentially, while fixed-point numbers have lower range than floating point numbers, their fractional precision is greater for higher values.
Prior to version 1.9 a fixed-point format with 5 fraction bits and 27 integer bits was used to send entity positions to the client. Some uses of fixed point remain in modern versions, but they differ from that format.
Most programming languages lack support for fractional integers directly, but you can represent them as integers. The following C or Java-like pseudocode converts a double to a fixed-point integer with n fraction bits:
x_fixed = (int)(x_double * (1 << n));
And back again:
x_double = (double)x_fixed / (1 << n);
Bit sets
The types BitSet and Fixed BitSet represent packed lists of bits. The Notchian implementation uses Java's BitSet
class.
BitSet
Bit sets of type BitSet are prefixed by their length in longs.
Field Name | Field Type | Meaning |
---|---|---|
Length | VarInt | Number of longs in the following array. May be 0 (if no bits are set). |
Data | Array of Long | A packed representation of the bit set as created by BitSet.toLongArray .
|
The ith bit is set when (Data[i / 64] & (1 << (i % 64))) != 0
, where i starts at 0.
Fixed BitSet
Bit sets of type Fixed BitSet (n) have a fixed length of n bits, encoded as ceil(n / 8)
bytes. Note that this is different from BitSet, which uses longs.
Field Name | Field Type | Meaning |
---|---|---|
Data | Byte Array (n) | A packed representation of the bit set as created by BitSet.toByteArray , padded with zeroes at the end to fit the specified length.
|
The ith bit is set when (Data[i / 8] & (1 << (i % 8))) != 0
, where i starts at 0. This encoding is not equivalent to the long array in BitSet.
Registry references
ID or X
Represents a data record of type X, either inline, or by reference to a registry implied by context.
Field Name | Field Type | Meaning |
---|---|---|
ID | VarInt | 0 if value of type X is given inline; otherwise registry ID + 1. |
Value | Optional X | Only present if ID is 0. |
ID Set
Represents a set of IDs in a certain registry (implied by context), either directly (enumerated IDs) or indirectly (tag name).
Field Name | Field Type | Meaning |
---|---|---|
Type | VarInt | Value used to determine the data that follows. It can be either:
|
Tag Name | Optional Identifier | The registry tag defining the ID set. Only present if Type is 0. |
IDs | Optional Array of VarInt | An array of registry IDs. Only present if Type is not 0. The size of the array is equal to Type - 1 .
|
Registry data
These types are commonly used in conjuction with ID or X to specify custom data inline.
Sound Event
Describes a sound that can be played.
Name | Type | Description |
---|---|---|
Sound Name | Identifier | |
Has Fixed Range | Boolean | Whether this sound has a fixed range, as opposed to a variable volume based on distance. |
Fixed Range | Optional Float | The maximum range of the sound. Only present if Has Fixed Range is true. |
Other definitions
Term | Definition |
---|---|
Player | When used in the singular, Player always refers to the client connected to the server. |
Entity | Entity refers to any item, player, mob, minecart or boat etc. See the Minecraft Wiki article for a full list. |
EID | An EID — or Entity ID — is a 4-byte sequence used to identify a specific entity. An entity's EID is unique on the entire server. |
XYZ | In this document, the axis names are the same as those shown in the debug screen (F3). Y points upwards, X points east, and Z points south. |
Meter | The meter is Minecraft's base unit of length, equal to the length of a vertex of a solid block. The term “block” may be used to mean “meter” or “cubic meter”. |
Global palette | A table/dictionary/palette mapping nonnegative integers to block states. The block state IDs can be constructed from this table by multiplying what the Minecraft Wiki calls “block IDs” by 16 and adding the metadata/damage value (or in most programming languages block_id << 4 | metadata ).
|
Notchian | The official implementation of vanilla Minecraft as developed and released by Mojang. |
Packet format
Without compression
Field Name | Field Type | Notes |
---|---|---|
Length | VarInt | Length of packet data + length of the packet ID |
Packet ID | VarInt | |
Data | Byte Array | Depends on the connection state and packet ID, see the sections below |
With compression
Once a Set Compression packet is sent, zlib compression is enabled for all following packets. The format of a packet changes slighty to include the size of the uncompressed packet.
Compressed? | Field Name | Field Type | Notes |
---|---|---|---|
No | Packet Length | VarInt | Length of Data Length + compressed length of (Packet ID + Data) |
No | Data Length | VarInt | Length of uncompressed (Packet ID + Data) or 0 |
Yes | Packet ID | Varint | zlib compressed packet ID (see the sections below) |
Data | Byte Array | zlib compressed packet data (see the sections below) |
The length given by the Packet Length field is the number of bytes that remain in that packet, including the Data Length field.
If Data Length is set to zero, then the packet is uncompressed; otherwise it is the size of the uncompressed packet.
If compressed, the uncompressed length of (Packet ID + Data) must be equal to or over the threshold set in the packet Set Compression (Login, 0x03, clientbound), otherwise the receiving party will disconnect.
Compression can be disabled by sending the packet Set Compression (Login, 0x03, clientbound) with a Threshold of -1.
Handshaking
Clientbound
There are no clientbound packets in the Handshaking state, since the protocol immediately switches to a different state after the client sends the first packet.
Serverbound
Handshake
This causes the server to switch into the target state.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x00 | Handshaking | Server | Protocol Version | VarInt | See protocol version numbers (currently 210) |
Server Address | String | Hostname or IP, e.g. localhost or 127.0.0.1, that was used to connect. The Notchian server does not use this information. | |||
Server Port | Unsigned Short | Default is 25565. The Notchian server does not use this information. | |||
Next State | VarInt Enum | 1 for status, 2 for login |
Legacy Server List Ping
This packet uses a nonstandard format. It is never length-prefixed, and the packet ID is an Unsigned Byte instead of a VarInt.
While not technically part of the current protocol, legacy clients may send this packet to initiate Server List Ping, and modern servers should handle it correctly.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0xFE | Handshaking | Server | Payload | Unsigned Byte | always 1 (0x01 )
|
See Server List Ping#1.6 for the details of the protocol that follows this packet.
Play
Clientbound
Spawn Object
Sent by the server when a vehicle or other object is created.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x00 | Play | Client | Entity ID | VarInt | EID of the object |
Object UUID | UUID | ||||
Type | Byte | The type of object (see Entities#Objects) | |||
X | Double | ||||
Y | Double | ||||
Z | Double | ||||
Pitch | Angle | ||||
Yaw | Angle | ||||
Data | Int | Meaning dependent on the value of the Type field, see Object Data for details. | |||
Velocity X | Short | Same units as Entity Velocity. | |||
Velocity Y | Short | Same units as Entity Velocity. | |||
Velocity Z | Short | Same units as Entity Velocity. |
Spawn Experience Orb
Spawns one or more experience orbs.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x01 | Play | Client | Entity ID | VarInt | |
X | Double | ||||
Y | Double | ||||
Z | Double | ||||
Count | Short | The amount of experience this orb will reward once collected |
Spawn Global Entity
With this packet, the server notifies the client of thunderbolts striking within a 512 block radius around the player. The coordinates specify where exactly the thunderbolt strikes.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x02 | Play | Client | Entity ID | VarInt | The EID of the thunderbolt |
Type | Byte Enum | The global entity type, currently always 1 for thunderbolt | |||
X | Double | ||||
Y | Double | ||||
Z | Double |
Spawn Mob
Sent by the server when a mob entity is spawned.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x03 | Play | Client | Entity ID | VarInt | |
Entity UUID | UUID | ||||
Type | Unsigned Byte | The type of mob. See Entities#Mobs | |||
X | Double | ||||
Y | Double | ||||
Z | Double | ||||
Yaw | Angle | ||||
Pitch | Angle | ||||
Head Pitch | Angle | ||||
Velocity X | Short | Same units as Entity Velocity | |||
Velocity Y | Short | Same units as Entity Velocity | |||
Velocity Z | Short | Same units as Entity Velocity | |||
Metadata | Entity Metadata |
Spawn Painting
This packet shows location, name, and type of painting.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x04 | Play | Client | Entity ID | VarInt | |
Entity UUID | UUID | ||||
Title | String | Name of the painting. Max length 13 | |||
Location | Position | Center coordinates (see below) | |||
Direction | Byte Enum | Direction the painting faces (North = 2, South = 0, West = 1, East = 3) |
Calculating the center of an image: given a (width × height) grid of cells, with (0, 0)
being the top left corner, the center is (max(0, width / 2 - 1), height / 2)
. E.g. (1, 0)
for a 2×1 painting, or (1, 2)
for a 4×4 painting.
Spawn Player
This packet is sent by the server when a player comes into visible range, not when a player joins.
This packet must be sent after the Player List Item (Play, 0x38, clientbound) packet that adds the player data for the client to use when spawning a player. If the Player List Item for the player spawned by this packet is not present when this packet arrives, Notchian clients will not spawn the player entity. The Player List Item packet includes skin/cape data.
Servers can, however, safely spawn player entities for players not in visible range. The client appears to handle it correctly.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x05 | Play | Client | Entity ID | VarInt | Player's EID |
Player UUID | UUID | See below for notes on offline mode and NPCs | |||
X | Double | ||||
Y | Double | ||||
Z | Double | ||||
Yaw | Angle | ||||
Pitch | Angle | ||||
Metadata | Entity Metadata |
When in online mode, the UUIDs must be valid and have valid skin blobs. In offline mode, UUID v3 is used.
For NPCs UUID v2 should be used. Note:
<+Grum> i will never confirm this as a feature you know that :)
In an example UUID, xxxxxxxx-xxxx-Yxxx-xxxx-xxxxxxxxxxxx
, the UUID version is specified by Y
. So, for UUID v3, Y
will always be 3
, and for UUID v2, Y
will always be 2
.
Animation (clientbound)
Sent whenever an entity should change animation.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x06 | Play | Client | Entity ID | VarInt | Player ID |
Animation | Unsigned Byte | Animation ID (see below) |
Animation can be one of the following values:
ID | Animation |
---|---|
0 | Swing main arm |
1 | Take damage |
2 | Leave bed |
3 | Swing offhand |
4 | Critical effect |
5 | Magic critical effect |
Statistics
Packet ID | State | Bound To | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|---|---|
0x07 | Play | Client | Count | VarInt | Number of elements in the following array | ||
Statistic | Name | Array | String | https://gist.github.com/thinkofdeath/a1842c21a0cf2e1fb5e0 | |||
Value | VarInt | The amount to set it to |
Block Break Animation
0–9 are the displayable destroy stages and each other number means that there is no animation on this coordinate.
Block break animations can still be applied on air; the animation will remain visible although there is no block being broken. However, if this is applied to a transparent block, odd graphical effects may happen, including water losing its transparency. (An effect similar to this can be seen in normal gameplay when breaking ice blocks)
If you need to display several break animations at the same time you have to give each of them a unique Entity ID.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x08 | Play | Client | Entity ID | VarInt | Entity ID of the entity breaking the block |
Location | Position | Block Position | |||
Destroy Stage | Byte | 0–9 to set it, any other value to remove it |
Update Block Entity
Sets tile entity associated with the block at the given location.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x09 | Play | Client | Location | Position | |
Action | Unsigned Byte | The type of update to perform, see below | |||
NBT Data | NBT Tag | Data to set. May be a TAG_END (0), in which case the block entity at the given location is removed (though this is not required since the client will remove the block entity automatically on chunk unload or block removal) |
Action field:
- 1: Set SpawnPotentials of a mob spawner
- 2: Set command block text (command and last execution status)
- 3: Set the level, primary, and secondary powers of a beacon
- 4: Set rotation and skin of mob head
- 5: Set type of flower in flower pot
- 6: Set base color and patterns on a banner
- 7: Set the data for a Structure tile entity
- 8: Set the destination for a end gateway
- 9: Set the text on a sign
Block Action
This packet is used for a number of things:
- Chests opening and closing
- Pistons pushing and pulling
- Note blocks playing
- Updating beacons
See also: Block Actions
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x0A | Play | Client | 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 ID for the block, not including metadata/damage value |
Block Change
Fired whenever a block is changed within the render distance.
Changing a block in a chunk that is not loaded is not a stable action. The Notchian client currently uses a shared empty chunk which is modified for all block changes in unloaded chunks; while in 1.10 this chunk never renders in older versions the changed block will appear in all copies of the empty chunk. Servers should avoid sending block changes in unloaded chunks and clients should ignore such packets.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x0B | Play | Client | Location | Position | Block Coordinates |
Block ID | VarInt | The new block state ID for the block as given in the global palette (When reading data: type = id >> 4 , meta = id & 15 , when writing data: id = type << 4 | (meta & 15) )
|
Boss Bar
Packet ID | State | Bound To | Field Name | Field Type | Notes | |
---|---|---|---|---|---|---|
0x0C | Play | Client | UUID | UUID | Unique ID for this bar | |
Action | VarInt Enum | Determines the layout of the remaining packet | ||||
Action | Field Name | |||||
0: add | Title | Chat | ||||
Health | Float | From 0 to 1. Values greater than 1 do not crash a Notchian client, and start rendering part of a second health bar at around 1.5. | ||||
Color | VarInt Enum | Color ID (see below) | ||||
Division | VarInt Enum | Type of division (see below) | ||||
Flags | Unsigned Byte | Bit mask. 0x1: should darken sky, 0x2: is dragon bar (used to play end music) | ||||
1: remove | no fields | no fields | Removes this boss bar | |||
2: update health | Health | Float | as above | |||
3: update title | Title | Chat | ||||
4: update style | Color | VarInt Enum | Color ID (see below) | |||
Dividers | VarInt Enum | as above | ||||
5: update flags | Flags | Unsigned Byte | as above |
ID | Color |
---|---|
0 | Pink |
1 | Blue |
2 | Red |
3 | Green |
4 | Yellow |
5 | Purple |
6 | White |
ID | Type of division |
---|---|
0 | No division |
1 | 6 notches |
2 | 10 notches |
3 | 12 notches |
4 | 20 notches |
Server Difficulty
Changes the difficulty setting in the client's option menu
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x0D | Play | Client | Difficulty | Unsigned Byte | 0: peaceful, 1: easy, 2: normal, 3: hard |
Tab-Complete (clientbound)
The server responds with a list of auto-completions of the last word sent to it. In the case of regular chat, this is a player username. Command names and parameters are also supported.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x0E | Play | Client | Count | VarInt | Number of elements in the following array |
Matches | Array of String | One eligible command, note that each command is sent separately instead of in a single string, hence the need for Count |
Chat Message (clientbound)
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 | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x0F | Play | Client | JSON Data | Chat | Limited to 32767 bytes |
Position | Byte | 0: chat (chat box), 1: system message (chat box), 2: above hotbar |
Multi Block Change
Fired whenever 2 or more blocks are changed within the same chunk on the same tick.
Changing blocks in chunks not loaded by the client is unsafe (see note on Block Change).
Packet ID | State | Bound To | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|---|---|
0x10 | Play | Client | Chunk X | Int | Chunk X coordinate | ||
Chunk Z | Int | Chunk Z coordinate | |||||
Record Count | VarInt | Number of elements in the following array, i.e. the number of blocks affected | |||||
Record | Horizontal Position | Array | Unsigned Byte | The 4 most significant bits (0xF0 ) encode the X coordinate, relative to the chunk. The 4 least significant bits (0x0F ) encode the Z coordinate, relative to the chunk.
| |||
Y Coordinate | Unsigned Byte | Y coordinate of the block | |||||
Block ID | VarInt | The new block state ID for the block as given in the global palette (When reading data: type = id >> 4 , meta = id & 15 , when writing data: id = type << 4 | (meta & 15) )
|
To decode the position into a world position:
worldX = (horizPos >> 4 & 15) + (chunkX * 16);
worldY = vertPos;
worldZ = (horizPos & 15) + (chunkZ * 16);
Confirm Transaction (clientbound)
A packet from the server indicating whether a request from the client was accepted, or whether there was a conflict (due to lag).
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x11 | Play | Client | Window ID | Byte | The ID of the window that the action occurred in |
Action Number | Short | Every action that is to be accepted has a unique number. This field corresponds to that number. | |||
Accepted | Boolean | Whether the action was accepted |
Close Window (clientbound)
This packet is sent from the server to the client when a window is forcibly closed, such as when a chest is destroyed while it's open.
Note, notchian clients send a close window packet with Window ID 0 to close their inventory even though there is never an Open Window packet for inventory.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x12 | Play | Client | Window ID | Unsigned Byte | This is the ID of the window that was closed. 0 for inventory. |
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 | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x13 | Play | Client | Window ID | Unsigned Byte | A unique id number for the window to be displayed. Notchian server implementation is a counter, starting at 1. |
Window Type | String | The window type to use for display. See Inventory for a list. | |||
Window Title | Chat | 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) | |||
Entity ID | Optional Int | EntityHorse's EID. Only sent when Window Type is “EntityHorse” |
See Inventory for further information.
Window Items
Sent by the server when items in multiple slots (in a window) are added/removed. This includes the main inventory, equipped armour and crafting slots.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x14 | Play | Client | Window ID | Unsigned Byte | The ID of window which items are being sent for. 0 for player inventory. |
Count | Short | Number of elements in the following array | |||
Slot Data | Array of Slot |
See inventory windows for further information about how slots are indexed.
Window Property
This packet is used to inform the client that part of a GUI window should be updated.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x15 | Play | Client | Window ID | Unsigned Byte | |
Property | Short | The property to be updated, see below | |||
Value | Short | The new value for the property, see below |
The meaning of the Property field depends on the type of the window. The following table shows the known combinations of window type and property, and how the value is to be interpreted.
Window type | Property | Value |
---|---|---|
Furnace | 0: Fire icon (fuel left) | counting from fuel burn time down to 0 (in-game ticks) |
1: Maximum fuel burn time | fuel burn time or 0 (in-game ticks) | |
2: Progress arrow | 0–200 (in-game ticks) | |
3: Maximum progress | always 200 | |
Enchantment Table | 0: Level requirement for top enchantment slot | The enchantment's xp level requirement |
1: Level requirement for middle enchantment slot | ||
2: Level requirement for bottom enchantment slot | ||
3: The seed for generating the enchantments view for the client | Unknown | |
4: Enchantment shown on mouse hover over top enchantment slot | The enchantment id (set to -1 to hide it) | |
5: Enchantment shown on mouse hover over middle enchantment slot | ||
6: Enchantment shown on mouse hover over bottom enchantment slot | ||
Beacon | 0: Power level | Unknown |
1: First potion effect | Unknown | |
2: Second potion effect | Unknown | |
Anvil | 0: Repair cost | The repair's cost in xp levels |
Brewing Stand | 0: Brew time | 0–400, with 400 making the arrow empty, and 0 making the arrow full |
Set Slot
Sent by the server when an item in a slot (in a window) is added/removed.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x16 | Play | Client | Window ID | Byte | The window which is being updated. 0 for player inventory. Note that all known window types include the player inventory. This packet will only be sent for the currently opened window while the player is performing actions, even if it affects the player inventory. After the window is closed, a number of these packets are sent to update the player's inventory window (0). |
Slot | Short | The slot that should be updated | |||
Slot Data | Slot |
To set the cursor (the item currently dragged with the mouse), use -1 as Window ID and as Slot.
This packet can only be used to edit the hotbar of the player's inventory if window ID is set to 0 (slots 36 through 44). If the window ID is set to -2, then any slot in the inventory can be used but no add item animation will be played.
Set Cooldown
Applies a cooldown period to all items with the given type. Used by the Notchian server with enderpearls. This packet should be sent when the cooldown starts and also when the cooldown ends (to compensate for lag), although the client will end the cooldown automatically.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x17 | Play | Client | Item ID | VarInt | Numeric ID of the item to apply a cooldown to. |
Cooldown Ticks | VarInt | Number of ticks to apply a cooldown for, or 0 to clear the cooldown. |
Plugin Message (clientbound)
- Main article: Plugin channels
Mods and plugins can use this to send their data. Minecraft itself uses a number of plugin channels. These internal channels are prefixed with MC|
.
More documentation on this: http://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x18 | Play | Client | Channel | String | Name of the plugin channel used to send the data |
Data | Byte Array | Any data, depending on the channel. MC| channels are documented here. The length of this array must be inferred from the packet length.
|
Named Sound Effect
- See also: #Sound Effect
Used to play a sound effect on the client. Custom sounds may be added by resource packs.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x19 | Play | Client | Sound Name | String | All sound effect names as of 1.9.0 can be seen here. |
Sound Category | VarInt Enum | The category that this sound will be played from (current categories) | |||
Effect Position X | Int | Effect X multiplied by 8 (fixed-point number with only 3 bits dedicated to the fractional part) | |||
Effect Position Y | Int | Effect Y multiplied by 8 (fixed-point number with only 3 bits dedicated to the fractional part) | |||
Effect Position Z | Int | Effect Z multiplied by 8 (fixed-point number with only 3 bits dedicated to the fractional part) | |||
Volume | Float | 1 is 100%, can be more | |||
Pitch | Float | Float between 0.5 and 2.0 by Notchian clients |
Disconnect (play)
Sent by the server before it disconnects a client. The client assumes that the server has already closed the connection by the time the packet arrives.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x1A | Play | Client | Reason | Chat | Displayed to the client when the connection terminates. |
Entity Status
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x1B | Play | Client | Entity ID | Int | |
Entity Status | Byte Enum | See below |
Entity Status | Meaning |
---|---|
0 | Spawn tipped arrow particle effects |
1 | Reset a mob spawner minecart's timer (unused by the client?) |
1 | Create rabbit running particles |
2 | Entity hurt animation |
3 | Entity died animation |
4 | Iron Golem throwing up arms |
6 | Wolf/Ocelot/Horse taming — Spawn “heart” particles |
7 | Wolf/Ocelot/Horse tamed — Spawn “smoke” particles |
8 | Wolf shaking water — Trigger the shaking animation |
9 | Mark item use as finished (ie, eating finished, drinking finished) |
10 | Sheep eating grass |
10 | Ignite TNT minecart |
11 | Iron Golem handing over a rose |
12 | Villager mating — Spawn “heart” particles |
13 | Spawn particles indicating that a villager is angry and seeking revenge |
14 | Spawn happy particles near a villager |
15 | Witch animation — Spawn “magic” particles |
16 | Play zombie converting into a villager sound |
17 | Firework exploding |
18 | Animal in love (ready to mate) — Spawn “heart” particles |
19 | Reset squid rotation |
20 | Spawn explosion particle — works for some living entities |
21 | Play guardian sound — works for every entity |
22 | Enables reduced debug for the given player |
23 | Disables reduced debug for the given player |
24–28 | Sets the op permission level 0–4 for the connected player |
29 | Shield block sound |
30 | Shield break sound |
31 | For a fishing rod bobber, if the hooked entity is this player, tug that player toward the caster of the rod |
32 | Armorstand hit sound |
33 | Entity hurt due to thorns (play thorns sound, perform normal hurt animation) |
Explosion
Sent when an explosion occurs (creepers, TNT, and ghast fireballs).
Each block in Records is set to air. Coordinates for each axis in record is int(X) + record.x
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x1C | Play | Client | X | Float | |
Y | Float | ||||
Z | Float | ||||
Radius | Float | Currently unused in the client | |||
Record Count | Int | Number of elements in the following array | |||
Records | Array of (Byte, Byte, Byte) | Each record is 3 signed bytes long, each bytes are the XYZ (respectively) offsets of affected blocks. | |||
Player Motion X | Float | X velocity of the player being pushed by the explosion | |||
Player Motion Y | Float | Y velocity of the player being pushed by the explosion | |||
Player Motion Z | Float | Z velocity of the player being pushed by the explosion |
Unload Chunk
Tells the client to unload a chunk column.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x1D | Play | Client | Chunk X | Int | Block coordinate divided by 16, rounded down |
Chunk Z | Int | Block coordinate divided by 16, rounded down |
Change Game State
Used for a wide variety of game state things, from weather to bed use to game mode to demo messages.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x1E | Play | Client | Reason | Unsigned Byte | See below |
Value | Float | Depends on Reason |
Reason codes:
Reason | Effect | Value |
---|---|---|
0 | Invalid Bed | Would be used to switch between messages, but the only used message is 0 for invalid bed |
1 | End raining | |
2 | Begin raining | |
3 | Change game mode | 0: Survival, 1: Creative, 2: Adventure, 3: Spectator |
4 | Exit end | 0: Immediately send Client Status of respawn without showing end credits; 1: Show end credits and respawn at the end (or when esc is pressed). 1 is sent if the player has not yet received the "The end?" achievement, while if they do have it 0 is used. |
5 | Demo message | 0: Show welcome to demo screen, 101: Tell movement controls, 102: Tell jump control, 103: Tell inventory control |
6 | Arrow hitting player | Appears to be played when an arrow strikes another player in Multiplayer |
7 | Fade value | The current darkness value. 1 = Dark, 0 = Bright, Setting the value higher causes the game to change color and freeze |
8 | Fade time | Time in ticks for the sky to fade |
10 | Play elder guardian mob appearance (effect and sound) |
Keep Alive (clientbound)
The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same packet. If the client does not respond to them for over 30 seconds, the server kicks the client. Vice versa, if the server does not send any keep-alives for 20 seconds, the client will disconnect and yields a "Timed out" exception.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x1F | Play | Client | Keep Alive ID | VarInt |
Chunk Data
- See also: #Unload Chunk
The server only sends skylight information for chunk pillars in the Overworld, it's up to the client to know in which dimenison the player is currently located. You can also infer this information from the primary bitmask and the amount of uncompressed bytes sent. This packet also sends all block entities in the chunk (though sending them is not required; it is still legal to send them with Update Block Entity later).
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x20 | Play | Client | Chunk X | Int | Block coordinate divided by 16, rounded down |
Chunk Z | Int | Block coordinate divided by 16, rounded down | |||
Ground-Up Continuous | Boolean | This is true if the packet represents all chunk sections in this vertical chunk column, where the Primary Bit Mask specifies exactly which chunk sections are included, and which are air. | |||
Primary Bit Mask | VarInt | Bitmask with bits set to 1 for every 16×16×16 chunk section whose data is included in Data. The least significant bit represents the chunk section at the bottom of the chunk column (from y=0 to y=15). | |||
Size | VarInt | Size of Data in bytes, plus size of Biomes in bytes if present | |||
Data | Array of Chunk Section | The length of the array is equal to the number of bits set in Primary Bit Mask. Chunks are sent bottom-to-top, i.e. the first chunk, if sent, extends from Y=0 to Y=15. | |||
Biomes | Optional Byte Array | Only if Ground-Up Continuous: biome array, byte per XZ coordinate, 256 bytes total. | |||
Number of block entities | VarInt | Length of the following array | |||
Block entities | Array of NBT Tag | All block entities in the chunk. Use the x, y, and z tags in the NBT to determine their positions. |
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 1023 (wither spawn) and effect 1028 (enderdragon death); it is ignored on other effects.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x21 | Play | Client | 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 | Boolean | See above |
Effect IDs:
ID | Name | Data |
---|---|---|
Sound | ||
1000 | Dispenser dispenses | |
1001 | Dispenser fails to dispense | |
1002 | Dispenser shoots | |
1003 | Ender eye launched | |
1004 | Firework shot | |
1005 | Iron door opened | |
1006 | Wooden door opened | |
1007 | Wooden trapdoor opened | |
1008 | Fence gate opened | |
1009 | Fire extinguished | |
1010 | Play record | Record ID |
1011 | Iron door closed | |
1012 | Wooden door closed | |
1013 | Wooden trapdoor closed | |
1014 | Fence gate closed | |
1015 | Ghast warns | |
1016 | Ghast shoots | |
1017 | Enderdragon shoots | |
1018 | Blaze shoots | |
1019 | Zombie attacks wood door | |
1020 | Zombie attacks iron door | |
1021 | Zombie breaks wood door | |
1022 | Wither breaks block | |
1023 | Wither spawned | |
1024 | Wither shoots | |
1025 | Bat takes off | |
1026 | Zombie infects | |
1027 | Zombie villager converted | |
1028 | Ender dragon death | |
1029 | Anvil destroyed | |
1030 | Anvil used | |
1031 | Anvil landed | |
1032 | Portal travel | |
1033 | Chorus flower grown | |
1034 | Chorus flower died | |
1035 | Brewing stand brewed | |
1036 | Iron trapdoor opened | |
1037 | Iron trapdoor closed | |
Particle | ||
2000 | Spawns 10 smoke particles, e.g. from a fire | Direction, see below |
2001 | Block break + block break sound | Block ID |
2002 | Splash potion. Particle effect + glass break sound. | Potion ID |
2003 | Eye of Ender entity break animation — particles and sound | |
2004 | Mob spawn particle effect: smoke + flames | |
2005 | Bonemeal particles | How many particles to spawn (if set to 0, 15 are spawned) |
2006 | Dragon breath | |
3000 | End gateway spawn | |
3001 | Enderdragon growl |
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 |
Particle
Displays the named particle
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x22 | Play | Client | Particle ID | Int | See below |
Long Distance | Boolean | If true, particle distance increases from 256 to 65536 | |||
X | Float | X position of the particle | |||
Y | Float | Y position of the particle | |||
Z | Float | Z position of the particle | |||
Offset X | Float | This is added to the X position after being multiplied by random.nextGaussian() | |||
Offset Y | Float | This is added to the Y position after being multiplied by random.nextGaussian() | |||
Offset Z | Float | This is added to the Z position after being multiplied by random.nextGaussian() | |||
Particle Data | Float | The data of each particle | |||
Particle Count | Int | The number of particles to create | |||
Data | Array of VarInt | Length depends on particle. "iconcrack" has length of 2, "blockcrack", and "blockdust" have lengths of 1, the rest have 0. |
Particle IDs:
Particle Name | Particle ID |
---|---|
explode | 0 |
largeexplosion | 1 |
hugeexplosion | 2 |
fireworksSpark | 3 |
bubble | 4 |
splash | 5 |
wake | 6 |
suspended | 7 |
depthsuspend | 8 |
crit | 9 |
magicCrit | 10 |
smoke | 11 |
largesmoke | 12 |
spell | 13 |
instantSpell | 14 |
mobSpell | 15 |
mobSpellAmbient | 16 |
witchMagic | 17 |
dripWater | 18 |
dripLava | 19 |
angryVillager | 20 |
happyVillager | 21 |
townaura | 22 |
note | 23 |
portal | 24 |
enchantmenttable | 25 |
flame | 26 |
lava | 27 |
footstep | 28 |
cloud | 29 |
reddust | 30 |
snowballpoof | 31 |
snowshovel | 32 |
slime | 33 |
heart | 34 |
barrier | 35 |
iconcrack_(id)_(data) | 36 |
blockcrack_(id+(data<<12)) | 37 |
blockdust_(id) | 38 |
droplet | 39 |
take | 40 |
mobappearance | 41 |
dragonbreath | 42 |
endrod | 43 |
damageindicator | 44 |
sweepattack | 45 |
Join Game
See Protocol Encryption for information on logging in.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x23 | Play | Client | Entity ID | Int | The player's Entity ID (EID) |
Gamemode | Unsigned Byte | 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. Bit 3 (0x8) is the hardcore flag. | |||
Dimension | Int Enum | -1: Nether, 0: Overworld, 1: End; also, note that this is not a VarInt but instead a regular int. | |||
Difficulty | Unsigned Byte | 0: peaceful, 1: easy, 2: normal, 3: hard | |||
Max Players | Unsigned Byte | Was once used by the client to draw the player list, but now is ignored | |||
Level Type | String | default, flat, largeBiomes, amplified, default_1_1 | |||
Reduced Debug Info | Boolean | If true, a Notchian client shows reduced information on the debug screen. |
Map
Updates a rectangular area on a map item.
Packet ID | State | Bound To | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|---|---|
0x24 | Play | Client | Item Damage | VarInt | The damage value (map ID) of the map being modified | ||
Scale | Byte | From 0 for a fully zoomed-in map (1 block per pixel) to 4 for a fully zoomed-out map (16 blocks per pixel) | |||||
Tracking Position | Boolean | Specifies whether the icons are shown | |||||
Icon Count | VarInt | Number of elements in the following array | |||||
Icon | Direction And Type | Array | Byte | 0xF0 = Direction, 0x0F = Type | |||
X | Byte | ||||||
Z | Byte | ||||||
Columns | Byte | Number of columns updated | |||||
Rows | Optional Byte | Only if Columns is more than 0; number of rows updated | |||||
X | Optional Byte | Only if Columns is more than 0; x offset of the westernmost column | |||||
Z | Optional Byte | Only if Columns is more than 0; z offset of the northernmost row | |||||
Length | Optional VarInt | Only if Columns is more than 0; length of the following array | |||||
Data | Optional Array of Unsigned Byte | Only if Columns is more than 0; see Map item format |
Entity Relative Move
This packet is sent by the server when an entity moves less then 8 blocks; if an entity moves more than 8 blocks Entity Teleport (Play, 0x4A, clientbound) should be sent instead.
This packet allows at most 8 blocks movement in any direction, because short range is from -32768 to 32767. And 32768 / (128 * 32)
= 8.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x25 | Play | Client | Entity ID | VarInt | |
Delta X | Short | Change in X position as (currentX * 32 - prevX * 32) * 128
| |||
Delta Y | Short | Change in Y position as (currentY * 32 - prevY * 32) * 128
| |||
Delta Z | Short | Change in Z position as (currentZ * 32 - prevZ * 32) * 128
| |||
On Ground | Boolean |
Entity Look And Relative Move
This packet is sent by the server when an entity rotates and moves. Since a short range is limited from -32768 to 32767, and movement is offset of fixed-point numbers, this packet allows at most 8 blocks movement in any direction. (-32768 / (32 * 128) == -8
)
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x26 | Play | Client | Entity ID | VarInt | |
Delta X | Short | Change in X position as (currentX * 32 - prevX * 32) * 128
| |||
Delta Y | Short | Change in Y position as (currentY * 32 - prevY * 32) * 128
| |||
Delta Z | Short | Change in Z position as (currentZ * 32 - prevZ * 32) * 128
| |||
Yaw | Angle | New angle, not a delta | |||
Pitch | Angle | New angle, not a delta | |||
On Ground | Boolean |
Entity Look
This packet is sent by the server when an entity rotates.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x27 | Play | Client | Entity ID | VarInt | |
Yaw | Angle | New angle, not a delta | |||
Pitch | Angle | New angle, not a delta | |||
On Ground | Boolean |
Entity
This packet may be used to initialize an entity.
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 | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x28 | Play | Client | Entity ID | VarInt |
Vehicle Move (clientbound)
Note that all fields use absolute positioning and do not allow for relative positioning.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x29 | Play | Client | X | Double | Absolute position (X coordinate) |
Y | Double | Absolute position (Y coordinate) | |||
Z | Double | Absolute position (Z coordinate) | |||
Yaw | Float | Absolute rotation on the vertical axis, in degrees | |||
Pitch | Float | Absolute rotation on the horizontal axis, in degrees |
Open Sign Editor
Sent when the client has placed a sign and is allowed to send Update Sign.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x2A | Play | Client | Location | Position |
Player Abilities (clientbound)
The latter 2 floats are used to indicate the field of view and flying speed respectively, while the first byte is used to determine the value of 4 booleans.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x2B | Play | Client | Flags | Byte | Bit field, see below |
Flying Speed | Float | ||||
Field of View Modifier | Float | Modifies the field of view, like a speed potion. A Notchian server will use the same value as the movement speed (send in the Entity Properties packet). |
About the flags:
Field | Bit |
---|---|
Invulnerable | 0x01 |
Flying | 0x02 |
Allow Flying | 0x04 |
Creative Mode | 0x08 |
Combat Event
Packet ID | State | Bound To | Field Name | Field Type | Notes | |
---|---|---|---|---|---|---|
0x2C | Play | Client | Event | VarInt Enum | Determines the layout of the remaining packet | |
Event | Field Name | |||||
0: enter combat | no fields | no fields | ||||
1: end combat | Duration | VarInt | ||||
Entity ID | Int | |||||
2: entity dead | Player ID | VarInt | ||||
Entity ID | Int | |||||
Message | Chat |
Player List Item
Sent by the server to update the user list (<tab> in the client).
Packet ID | State | Bound To | Field Name | Field Type | Notes | |||||
---|---|---|---|---|---|---|---|---|---|---|
0x2D | Play | Client | Action | VarInt | Determines the rest of the Player format after the UUID | |||||
Number Of Players | VarInt | Number of elements in the following array | ||||||||
Player | UUID | Array | UUID | |||||||
Action | Field Name | |||||||||
0: add player | Name | String | ||||||||
Number Of Properties | VarInt | Number of elements in the following array | ||||||||
Property | Name | Array | String | |||||||
Value | String | |||||||||
Is Signed | Boolean | |||||||||
Signature | Optional String | Only if Is Signed is true | ||||||||
Gamemode | VarInt | |||||||||
Ping | VarInt | |||||||||
Has Display Name | Boolean | |||||||||
Display Name | Optional Chat | Only if Has Display Name is true | ||||||||
1: update gamemode | Gamemode | VarInt | ||||||||
2: update latency | Ping | VarInt | ||||||||
3: update display name | Has Display Name | Boolean | ||||||||
Display Name | Optional Chat | Only send if Has Display Name is true | ||||||||
4: remove player | no fields | no fields |
The Property field looks as in the response of Mojang API#UUID -> Profile + Skin/Cape, except of course using the protocol format instead of JSON. That is, each player will usually have one property with Name “textures” and Value being a base64-encoded JSON string as documented at Mojang API#UUID -> Profile + Skin/Cape. An empty properties array is also acceptable, and will cause clients to display the player with one of the two default skins depending on UUID.
Player Position And Look (clientbound)
Updates the player's position on the server. This packet will also close the “Downloading Terrain” screen when joining/respawning.
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 meters, the client will be 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.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x2E | Play | Client | X | Double | Absolute or relative position, depending on Flags |
Y | Double | Absolute or relative position, depending on Flags | |||
Z | Double | Absolute or relative position, depending on Flags | |||
Yaw | Float | Absolute or relative rotation on the X axis, in degrees | |||
Pitch | Float | Absolute or relative rotation on the Y axis, in degrees | |||
Flags | Byte | Bit field, see below | |||
Teleport ID | VarInt | Client should confirm this packet with Teleport Confirm containing the same Teleport ID |
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.
Field | Bit |
---|---|
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 | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x2F | Play | Client | Entity ID | VarInt | Sleeping player's EID |
Location | Position | Block location of the head part of the bed |
Destroy Entities
Sent by the server when a list of entities is to be destroyed on the client.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x30 | Play | Client | Count | VarInt | Number of elements in the following array |
Entity IDs | Array of VarInt | The list of entities of destroy |
Remove Entity Effect
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x31 | Play | Client | Entity ID | VarInt | |
Effect ID | Byte | See this table |
Resource Pack Send
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x32 | Play | Client | URL | String | The URL to the resource pack. |
Hash | String | A 40 character hexadecimal and lowercase SHA-1 hash of the resource pack file. (must be lower case in order to work) If it's not a 40 character hexadecimal string, the client will not use it for hash verification and likely waste bandwidth — but it will still treat it as a unique id |
Respawn
To change the player's dimension (overworld/nether/end), send them a respawn packet with the appropriate dimension, followed by prechunks/chunks for the new dimension, and finally a position and look packet. You do not need to unload chunks, the client will do it automatically.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x33 | Play | Client | Dimension | Int Enum | -1: The Nether, 0: The Overworld, 1: The End |
Difficulty | Unsigned Byte | 0: Peaceful, 1: Easy, 2: Normal, 3: Hard | |||
Gamemode | Unsigned Byte | 0: survival, 1: creative, 2: adventure, 3: spectator. The hardcore flag is not included | |||
Level Type | String | Same as Join Game |
Avoid changing player's dimension to same dimension they were already in unless they are dead. If you change the dimension to one they are already in, weird bugs can occur, such as the player being unable to attack other players in new world (until they die and respawn).
If you must respawn a player in the same dimension without killing them, send two respawn packets, one to a different world and then another to the world you want. You do not need to complete the first respawn; it only matters that you send two packets.
Entity Head Look
Changes the direction an entity's head is facing.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x34 | Play | Client | Entity ID | VarInt | |
Head Yaw | Angle | New angle, not a delta |
World Border
Packet ID | State | Bound To | Field Name | Field Type | Notes | |
---|---|---|---|---|---|---|
0x35 | Play | Client | Action | VarInt Enum | Determines the format of the rest of the packet | |
Action | Field Name | |||||
0: set size | Diameter | Double | Length of a single side of the world border, in meters | |||
1: lerp size | Old Diameter | Double | Current length of a single side of the world border, in meters | |||
New Diameter | Double | Target length of a single side of the world border, in meters | ||||
Speed | VarLong | Number of real-time milliseconds until New Diameter is reached. It appears that Notchian server does not sync world border speed to game ticks, so it gets out of sync with server lag. If the world border is not moving, this is set to 0. | ||||
2: set center | X | Double | ||||
Z | Double | |||||
3: initialize | X | Double | ||||
Z | Double | |||||
Old Diameter | Double | Current length of a single side of the world border, in meters | ||||
New Diameter | Double | Target length of a single side of the world border, in meters | ||||
Speed | VarLong | Number of real-time milliseconds until New Diameter is reached. It appears that Notchian server does not sync world border speed to game ticks, so it gets out of sync with server lag. If the world border is not moving, this is set to 0. | ||||
Portal Teleport Boundary | VarInt | Resulting coordinates from a portal teleport are limited to ±value. Usually 29999984. | ||||
Warning Time | VarInt | In seconds as set by /worldborder warning time
| ||||
Warning Blocks | VarInt | In meters | ||||
4: set warning time | Warning Time | VarInt | In seconds as set by /worldborder warning time
| |||
5: set warning blocks | Warning Blocks | VarInt | In meters |
The Notchian client determines how solid to display the warning by comparing to whichever is higher, the warning distance or whichever is lower, the distance from the current diameter to the target diameter or the place the border will be after warningTime seconds. In pseudocode:
distance = max(min(resizeSpeed * 1000 * warningTime, abs(targetDiameter - currentDiameter)), warningDistance);
if (playerDistance < distance) {
warning = 1.0 - playerDistance / distance;
} else {
warning = 0.0;
}
Camera
Sets the entity that the player renders from. This is normally used when the player left-clicks an entity while in spectator mode.
The player's camera will move with the entity and look where it is looking. The entity is often another player, but can be any type of entity. The player is unable to move this entity (move packets will act as if they are coming from the other entity).
If the given entity is not loaded by the player, this packet is ignored. To return control to the player, send this packet with their entity ID.
The Notchian server resets this (sends it back to the default entity) whenever the spectated entity is killed or the player sneaks, but only if they were spectating an entity. It also sends this packet whenever the player switches out of spectator mode (even if they weren't spectating an entity).
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x36 | Play | Client | Camera ID | VarInt | ID of the entity to set the client's camera to |
The notchian also loads certain shaders for given entities:
- Creeper →
shaders/post/creeper.json
- Spider (and cave spider) →
shaders/post/spider.json
- Enderman →
shaders/post/invert.json
- Anything else → the current shader is unloaded
Held Item Change (clientbound)
Sent to change the player's slot selection.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x37 | Play | Client | Slot | Byte | The slot which the player has selected (0–8) |
Display Scoreboard
This is sent to the client when it should display a scoreboard.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x38 | Play | Client | Position | Byte | The position of the scoreboard. 0: list, 1: sidebar, 2: below name. |
Score Name | String | The unique name for the scoreboard to be displayed. |
Entity Metadata
Updates one or more metadata properties for an existing entity. Any properties not included in the Metadata field are left unchanged.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x39 | Play | Client | Entity ID | VarInt | |
Metadata | Entity Metadata |
Attach Entity
This packet is sent when an entity has been leashed to another entity.
Packet ID | State | Bound To | Field Name | Field Type | Notes |
---|---|---|---|---|---|
0x3A | Play | Client | Attached Entity ID | Int | Attached ent |