欢迎来到Minecraft插件百科!
对百科编辑一脸懵逼?
帮助:快速入门
带您快速熟悉百科编辑!
因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289
查看“Protocol”的源代码
←
Protocol
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于这些用户组的用户执行:
用户
、
自动确认用户
、
巡查者
您可以查看和复制此页面的源代码。
This page presents a dissection of the current '''[https://minecraft.net/ Minecraft] protocol'''. If you're having trouble, check out the [[Protocol FAQ|FAQ]] or ask for help in the IRC channel ([irc://irc.freenode.net/mcdevs #mcdevs on irc.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]]. == 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|Handshaking]], and state is switched using the packets [[#Handshake|Handshake]] ([[#Handshaking|Handshaking]], 0x00, serverbound) and [[#Login Success|Login Success]] ([[#Login|Login]], 0x02, clientbound). === Data types === <!-- Transcluded contents of Data Types article in here - go to that page if you want to edit it --> {{:Data Types}} === Other definitions === {| class="wikitable" |- ! 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 {{Minecraft Wiki|Entity|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”. |} == Packet format == === Without compression === {| class="wikitable" ! 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|Set Compression]] packet is sent, [[wikipedia:Zlib|zlib]] compression is enabled for all following packets. The format of a packet changes slighty to include the size of the uncompressed packet. {| class=wikitable ! 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 |- |rowspan="2"| 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 [[#Set Compression|Set Compression]] packet, otherwise the client/server will disconnect. Compression can be disabled by sending a [[#Set Compression|Set Compression]] packet 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x00 |rowspan="4"| Handshaking |rowspan="4"| Server | Protocol Version | VarInt | See [[protocol version numbers]] (currently 47) |- | Server Address | String | hostname or IP, e.g. localhost or 127.0.0.1<!-- does this support IPv6? --> |- | Server Port | Unsigned Short | default is 25565 |- | Next State | VarInt | 1 for [[#Status|status]], 2 for [[#Login|login]] |} ==== Legacy Server List Ping ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- | 0xFE | Handshaking | Server | Payload | Unsigned Byte | always 1 (<code>0x01</code>) |} See [[Server List Ping#1.6]] for the details of the protocol that follows this packet. == Play == === Clientbound === ==== Keep Alive ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x00 |rowspan="1"| Play |rowspan="1"| Client | Keep Alive ID | VarInt | |} ==== Join Game ==== See [[Protocol Encryption]] for information on logging in. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="7"| 0x01 |rowspan="7"| Play |rowspan="7"| 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 | Byte | -1: Nether, 0: Overworld, 1: End |- | Difficulty | Unsigned Byte | 0: peaceful, 1: easy, 2: normal, 3: hard |- | Max Players | Unsigned Byte | Used by the client to draw the player list |- | Level Type | String | default, flat, largeBiomes, amplified, default_1_1 |- | Reduced Debug Info | Boolean | If true, a Notchian client shows reduced information on the {{Minecraft Wiki|debug screen}}. |} {{Warning|If the Dimension isn't valid then the client will crash}} ==== 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 {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x02 |rowspan="2"| Play |rowspan="2"| Client | JSON Data | [[Chat]] | Limited to 32767 bytes |- | Position | Byte | 0: chat (chat box), 1: system message (chat box), 2: above action bar |} {{Warning|Malformed JSON will disconnect the client}} ==== Time Update ==== Time is based on ticks, where 20 ticks happen every second. There are 24000 ticks in a day, making Minecraft days exactly 20 minutes long. The time of day is based on the timestamp modulo 24000. 0 is sunrise, 6000 is noon, 12000 is sunset, and 18000 is midnight. The default SMP server increments the time by <code>20</code> every second. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x03 |rowspan="2"| Play |rowspan="2"| Client | World Age | Long | In ticks; not changed by server commands |- | Time of day | Long | The world (or region) time, in ticks. If negative the sun will stop moving at the Math.abs of the time |} ==== Entity Equipment ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x04 |rowspan="3"| Play |rowspan="3"| Client | Entity ID | VarInt | Entity's EID |- | Slot | Short | Equipment slot. 0: held, 1–4: armor slot (1: boots, 2: leggings, 3: chestplate, 4: helmet) |- | Item | [[Slot Data|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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x05 |rowspan="1"| Play |rowspan="1"| Client | Location | Position | Spawn location |} ==== Update Health ==== Sent by the server to update/set the health of the player it is sent to. Food {{Minecraft Wiki|Food#Hunger vs. Saturation|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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x06 |rowspan="3"| Play |rowspan="3"| Client | 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 |} ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x07 |rowspan="4"| Play |rowspan="4"| Client | Dimension | Int | -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. The hardcore flag is not included |- | Level Type | String | Same as [[#Join Game|Join Game]] |} {{Warning|If the Dimension isn't valid then the client will crash}} {{Warning|Avoid changing player's dimension to same dimension they were already in, weird bugs can occur i.e. such player will be unable to attack other players in new world (fixes after their death and respawn)}} ==== Player Position And Look ==== Updates the player's 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 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 <code>3.2E7D</code> the client will be kicked for “Illegal position”. Yaw is measured in degrees, and does not follow classical trigonometry rules. The unit circle of yaw on the XZ-plane starts at (0, 1) and turns counterclockwise, with 90 at (-1, 0), 180 at (0, -1) and 270 at (1, 0). Additionally, yaw is not clamped to between 0 and 360 degrees; any number is valid, including negative numbers and numbers greater than 360. Pitch is measured in degrees, where 0 is looking straight ahead, -90 is looking straight up, and 90 is looking straight down. The yaw in degrees of a player standing at point (x0, z0) and looking towards point (x, z) can be calculated with: l = x-x0 w = z-z0 c = sqrt( l*l + w*w ) alpha1 = -arcsin(l/c)/PI*180 alpha2 = arccos(w/c)/PI*180 if alpha2 > 90 then yaw = 180 - alpha1 else yaw = alpha1 You can get a unit vector from a given yaw/pitch via: x = -cos(pitch) * sin(yaw) y = -sin(pitch) z = cos(pitch) * cos(yaw) {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="6"| 0x08 |rowspan="6"| Play |rowspan="6"| 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 |} 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. {| class="wikitable" |- ! Field ! Bit |- | X | 0x01 |- | Y | 0x02 |- | Z | 0x04 |- | Y_ROT | 0x08 |- | X_ROT | 0x10 |} ==== Held Item Change ==== Sent to change the player's slot selection. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x09 |rowspan="1"| Play |rowspan="1"| Client | Slot | Byte | The slot which the player has selected (0–8) |} ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x0A |rowspan="2"| Play |rowspan="2"| Client | Entity ID | VarInt | Sleeping player's EID |- | Location | Position | Block location of the head part of the bed |} ==== Animation ==== Sent whenever an entity should change animation. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x0B |rowspan="2"| Play |rowspan="2"| Client | Entity ID | VarInt | Player ID |- | Animation | Unsigned Byte | Animation ID (see below) |} Animation can be one of the following values: {| class="wikitable" ! ID ! Animation |- | 0 | Swing arm |- | 1 | Take damage |- | 2 | Leave bed |- | 3 | Eat food |- | 4 | Critical effect |- | 5 | Magic critical effect |} ==== 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|Player List Item]] ([[#Play|Play]], 0x38, clientbound) packet that adds the player data for the client to use when spawning a player. If the tab list entry for the UUID included in this packet is not present when this packet arrives, the entity will not be spawned. The tab includes skin/cape data. Servers can, however, safely spawn player entities for players not in visible range. The client appears to handle it correctly. 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, <code>xxxxxxxx-xxxx-Yxxx-xxxx-xxxxxxxxxxxx</code>, the UUID version is specified by <code>Y</code>. So, for UUID v3, <code>Y</code> will always be <code>3</code>, and for UUID v2, <code>Y</code> will always be <code>2</code>. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="9"| 0x0C |rowspan="9"| Play |rowspan="9"| Client | Entity ID | VarInt | Player's EID |- | Player UUID | UUID | |- | X | Int | Player X as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Y | Int | Player Y as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Z | Int | Player Z as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Yaw | Angle | |- | Pitch | Angle | |- | 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. |- | Metadata | [[Entities#Entity Metadata Format|Metadata]] | |} {{Warning|A negative Current Item crashes clients}} {{Warning|The client will crash if no Metadata is sent}} ==== 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|Player Position]] (and [[#Player Position And Look|Player Position And Look]]) packet sent by the client. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x0D |rowspan="2"| Play |rowspan="2"| Client | Collected Entity ID | VarInt | |- | Collector Entity ID | VarInt | |} ==== Spawn Object ==== Sent by the server when an Object/Vehicle is created. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="8"| 0x0E |rowspan="8"| Play |rowspan="8"| Client | Entity ID | VarInt | EID of the object |- | Type | Byte | The type of object (See [[Entities#Objects|Objects]]) |- | X | Int | X position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Y | Int | Y position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Z | Int | Z position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Pitch | Angle | |- | Yaw | Angle | |- | Data | [[Object Data]] | |} ==== Spawn Mob ==== Sent by the server when a Mob Entity is Spawned {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="12"| 0x0F |rowspan="12"| Play |rowspan="12"| Client | Entity ID | VarInt | |- | Type | Unsigned Byte | The type of mob. See [[Entities#Mobs|Mobs]] |- | X | Int | X position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Y | Int | Y position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Z | Int | Z position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Yaw | Angle | |- | Pitch | Angle | |- | Head Pitch | Angle | |- | Velocity X | Short | Same units as [[#Entity Velocity|Entity Velocity]] |- | Velocity Y | Short | Same units as [[#Entity Velocity|Entity Velocity]] |- | Velocity Z | Short | Same units as [[#Entity Velocity|Entity Velocity]] |- | Metadata | [[Entities#Entity Metadata Format|Metadata]] | |} ==== 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) {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x10 |rowspan="4"| Play |rowspan="4"| Client | Entity ID | VarInt | |- | Title | String | Name of the painting. Max length 13 |- | Location | Position | Center coordinates |- | Direction | Unsigned Byte | Direction the painting faces. 0: north (-z), 1: west (-x), 2: south (+z), 3: east (+x) |} ==== Spawn Experience Orb ==== Spawns one or more experience orbs. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x11 |rowspan="5"| Play |rowspan="5"| Client | Entity ID | VarInt | Entity's ID |- | X | Int | X position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Y | Int | Y position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Z | Int | Z position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Count | Short | The amount of experience this orb will reward once collected |} ==== 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). {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x12 |rowspan="4"| Play |rowspan="4"| Client | Entity ID | VarInt | |- | 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 a list of entities is to be destroyed on the client. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x13 |rowspan="2"| Play |rowspan="2"| Client | Count | VarInt | Number of elements in the following array |- | Entity IDs | Array of VarInt | The list of entities of destroy |} ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x14 |rowspan="1"| Play |rowspan="1"| Client | Entity ID | VarInt | |} ==== Entity Relative Move ==== This packet is sent by the server when an entity moves less then 4 blocks; if an entity moves more than 4 blocks [[#Entity Teleport|Entity Teleport]] should be sent instead. This packet allows at most four blocks movement in any direction, because byte range is from -128 to 127. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x15 |rowspan="5"| Play |rowspan="5"| Client | Entity ID | VarInt | |- | Delta X | Byte | Change in X position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Delta Y | Byte | Change in Y position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Delta Z | Byte | Change in Z position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | On Ground | Boolean | |} ==== Entity Look ==== This packet is sent by the server when an entity rotates. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x16 |rowspan="5"| Play |rowspan="5"| Client | Entity ID | VarInt | |- | Yaw | Angle | New angle, not a delta |- | Pitch | Angle | New angle, not a delta |- | On Ground | Boolean | |} ==== Entity Look And Relative Move ==== This packet is sent by the server when an entity rotates and moves. Since a byte range is limited from -128 to 127, and movement is offset of fixed-point numbers, this packet allows at most four blocks movement in any direction. (-128/32 == -4) {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="7"| 0x17 |rowspan="7"| Play |rowspan="7"| Client | Entity ID | VarInt | |- | Delta X | Byte | Change in X position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Delta Y | Byte | Change in Y position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Delta Z | Byte | Change in Z position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Yaw | Angle | New angle, not a delta |- | Pitch | Angle | New angle, not a delta |- | On Ground | Boolean | |} ==== Entity Teleport ==== This packet is sent by the server when an entity moves more than 4 blocks. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="7"| 0x18 |rowspan="7"| Play |rowspan="7"| Client | Entity ID | VarInt | |- | X | Int | X position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Y | Int | Y position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Z | Int | Z position as a [[Data Types#Fixed-point numbers|Fixed-Point number]] |- | Yaw | Angle | New angle, not a delta |- | Pitch | Angle | New angle, not a delta |- | On Ground | Boolean | |} ==== Entity Head Look ==== Changes the direction an entity's head is facing. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x19 |rowspan="2"| Play |rowspan="2"| Client | Entity ID | VarInt | |- | Head Yaw | Angle | New angle, not a delta |} ==== Entity Status ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x1A |rowspan="2"| Play |rowspan="2"| Client | Entity ID | Int | |- | Entity Status | Byte | See below |} {| class="wikitable" |- ! Entity Status ! Meaning |- | 1 | Sent when resetting a mob spawn minecart's timer - appears to be unused by the client |- | 2 | Living Entity hurt |- | 3 | Living Entity dead |- | 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 | (of self) Eating accepted by server |- | 10 | Sheep eating grass |- | 10 | Play TNT ignite sound |- | 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 players |- | 23 | Disables reduced debug for players |} ==== Attach Entity ==== This packet is sent when a player has been attached to an entity (e.g. Minecart). {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x1B |rowspan="3"| Play |rowspan="3"| Client | Entity ID | Int | Attached entity's EID. Set to -1 to detach. |- | Vehicle ID | Int | Vechicle's Entity ID |- | Leash | Boolean | If true leashes the entity to the vehicle |} ==== Entity Metadata ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x1C |rowspan="2"| Play |rowspan="2"| Client | Entity ID | VarInt | |- | Metadata | [[Entities#Entity Metadata Format|Metadata]] | |} ==== Entity Effect ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x1D |rowspan="5"| Play |rowspan="5"| Client | Entity ID | VarInt | |- | Effect ID | Byte | See {{Minecraft Wiki|Status effect#List of effects|this table}} |- | Amplifier | Byte | Notchian client displays effect level as Amplifier + 1 |- | Duration | VarInt | Seconds |- | Hide Particles | Boolean | |} ==== Remove Entity Effect ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x1E |rowspan="2"| Play |rowspan="2"| Client | Entity ID | VarInt | |- | Effect ID | Byte | See {{Minecraft Wiki|Status effect#List of effects|this table}} |} ==== Set Experience ==== Sent by the server when the client should change experience levels. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x1F |rowspan="3"| Play |rowspan="3"| Client | Experience bar | Float | Between 0 and 1 |- | Level | VarInt | |- | Total Experience | VarInt | See {{Minecraft Wiki|Experience#Leveling up}} on the Minecraft Wiki for Total Experience to Level conversion |} ==== Entity Properties ==== {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name !colspan="2"| Field Type ! Notes |- |rowspan="6"| 0x20 |rowspan="6"| Play |rowspan="6"| Client |colspan="2"| Entity ID |colspan="2"| VarInt | |- |colspan="2"| Number Of Properties |colspan="2"| Int | Number of elements in the following array |- |rowspan="4"| Property | Key |rowspan="4"| Array | String | See below |- | Value | Double | See below |- | Number Of Modifiers | VarInt | Number of elements in the following array |- | Modifiers | Array of Modifier Data | See {{Minecraft Wiki|Attribute#Modifiers}} |} Known Key values: {| class="wikitable" |- ! 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: {| class="wikitable" |- ! Field Name ! Field Type ! Notes |- | UUID | UUID | |- | Amount | Double | |- | Operation | Byte | |} ==== Chunk Data ==== Chunks are not unloaded by the client automatically. To unload chunks, send this packet with Ground-Up Continuous=true and no 16^3 chunks (eg. Primary Bit Mask=0). The server does not send skylight information for nether-chunks, it's up to the client to know if the player is currently in the nether. You can also infer this information from the primary bitmask and the amount of uncompressed bytes sent. See also: [[SMP Map Format]] Changes in 1.8: * Data value section removed * Extended id section removed * Block id section is now a unsigned short (little endian) per a block * The block id is equal to <code>(id << 4) | data</code> {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="6"| 0x21 |rowspan="6"| Play |rowspan="6"| Client | Chunk X | Int | Chunk X coordinate |- | Chunk Z | Int | Chunk Z coordinate |- | Ground-Up Continuous | Boolean | This is true if the packet represents all sections in this vertical column, where the Primary Bit Mask specifies exactly which sections are included, and which are air |- | Primary Bit Mask | Unsigned Short | Bitmask with 1 for every 16x16x16 section whose data follows in the compressed data |- | Size | VarInt | Size of Data |- | Data | [[SMP Map Format#Data|Chunk]] | |} ==== Multi Block Change ==== Fired whenever 2 or more blocks are changed within the render distance. {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name !colspan="2"| Field Type ! Notes |- |rowspan="6"| 0x22 |rowspan="6"| Play |rowspan="6"| Client |colspan="2"| Chunk X |colspan="2"| Int | Chunk X coordinate |- |colspan="2"| Chunk Z |colspan="2"| Int | Chunk Z coordinate |- |colspan="2"| Record Count |colspan="2"| VarInt | Number of elements in the following array, a.k.a. the number of blocks affected |- |rowspan="3"| Record | Horizontal Position |rowspan="3"| Array | Unsigned Byte | The 4 most significant bits (<code>0xF0</code>) encode the X coordinate, relative to the chunk. The 4 least significant bits (<code>0x0F</code>) encode the Z coordinate, relative to the chunk. |- | Y Coordinate | Unsigned Byte | |- | Block ID | VarInt | The new block ID for the block. <code><nowiki>id << 4 | data</nowiki></code> |} ==== Block Change ==== Fired whenever a block is changed within the render distance. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x23 |rowspan="2"| Play |rowspan="2"| Client | Location | Position | Block Coordinates |- | Block ID | VarInt | The new block ID for the block. <code><nowiki>id << 4 | data</nowiki></code> |} ==== 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]] {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x24 |rowspan="4"| Play |rowspan="4"| 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 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 lose it's transparency) {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x25 |rowspan="3"| Play |rowspan="3"| Client | Entity ID | VarInt | EID for the animation |- | Location | Position | Block Position |- | Destroy Stage | Byte | 0–9 to set it, any other value to remove it |} ==== Map Chunk Bulk ==== 1.8 changes at [[#Chunk Data|Chunk Data]] To reduce the number of bytes, this packet is used to send chunks together for better compression results. {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name !colspan="2"| Field Type ! Notes |- |rowspan="7"| 0x26 |rowspan="7"| Play |rowspan="7"| Client |colspan="2"| Sky Light Sent |colspan="2"| Boolean | Whether or not Chunk Data contains light nibble arrays. This is true in the Overworld, false in the End + Nether |- |colspan="2"| Chunk Column Count |colspan="2"| VarInt | Number of elements in each of the following arrays |- |rowspan="3"| Chunk Meta | Chunk X |rowspan="3"| Array | Int | The X coordinate of the chunk |- | Chunk Z | Int | The Z coordinate of the chunk |- | Primary Bit Mask | Unsigned Short | A bit mask which specifies which sections are not empty in this chunk |- |colspan="2"| Chunk Data |colspan="2"| Array of [[SMP Map Format#Data|Chunk]] | Each chunk in this array corresponds to the data at the same position in Chunk Meta |} ==== 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 {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="9"| 0x27 |rowspan="9"| Play |rowspan="9"| 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 |} ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x28 |rowspan="4"| Play |rowspan="4"| 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: {| class="wikitable" ! ID ! Name ! Data |- !colspan="3"| Sound |- | 1000 | <code>random.click</code> | |- | 1001 | <code>random.click</code> | |- | 1002 | <code>random.bow</code> | |- | 1003 | <code>random.door_open</code> or <code>random.door_close</code> (50/50 chance) | |- | 1004 | <code>random.fizz</code> | |- | 1005 | Play a music disc. | {{Minecraft Wiki|Music Discs|Record ID}} |- | 1006 | ''not assigned'' | |- | 1007 | <code>mob.ghast.charge</code> | |- | 1008 | <code>mob.ghast.fireball</code> | |- | 1009 | <code>mob.ghast.fireball</code>, but with a lower volume | |- | 1010 | <code>mob.zombie.wood</code> | |- | 1011 | <code>mob.zombie.metal</code> | |- | 1012 | <code>mob.zombie.woodbreak</code> | |- | 1013 | <code>mob.wither.spawn</code> | |- | 1014 | <code>mob.wither.shoot</code> | |- | 1015 | <code>mob.bat.takeoff</code> | |- | 1016 | <code>mob.zombie.infect</code> | |- | 1017 | <code>mob.zombie.unfect</code> | |- | 1018 | <code>mob.enderdragon.end</code> | |- | 1020 | <code>random.anvil_break</code> | |- | 1021 | <code>random.anvil_use</code> | |- | 1022 | <code>random.anvil_land</code> | |- !colspan="3"| Particle |- | 2000 | Spawns 10 smoke particles, e.g. from a fire | Direction, see below |- | 2001 | Block break | {{Minecraft Wiki|Data values|Block ID}} |- | 2002 | Splash potion. Particle effect + glass break sound. | [http://www.lb-stuff.com/Minecraft/PotionDataValues1.9pre3.txt 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: {| class="wikitable" ! 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 |} ==== Sound Effect ==== Used to play a sound effect on the client. Custom sounds may be added by resource packs. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="6"| 0x29 |rowspan="6"| Play |rowspan="6"| Client | Sound name | String | All known sound effect names can be seen [https://github.com/SirCmpwn/Craft.Net/blob/master/source/Craft.Net.Common/SoundEffect.cs here] |- | Effect position X | Int | Effect X multiplied by 8 |- | Effect position Y | Int | Effect Y multiplied by 8 |- | Effect position Z | Int | Effect Z multiplied by 8 |- | Volume | Float | 1 is 100%, can be more |- | Pitch | Unsigned Byte | 63 is 100%, can be more |} ==== Particle ==== Displays the named particle {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="11"| 0x2A |rowspan="11"| Play |rowspan="11"| 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: {| class="wikitable" |- ! 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 |} ==== Change Game State ==== It appears when a bed can't be used as a spawn point and when the rain state changes. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x2B |rowspan="2"| Play |rowspan="2"| Client | Reason | Unsigned Byte | See below |- | Value | Float | Depends on Reason |} ''Reason codes'': {| class="wikitable" ! Reason ! Effect ! Value |- | 0 | Invalid Bed | |- | 1 | End raining | |- | 2 | Begin raining | |- | 3 | Change game mode | 0: Survival, 1: Creative, 2: Adventure, 3: Spectator |- | 4 | Enter credits | |- | 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 mob appearance (effect and sound) | Unknown |} ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x2C |rowspan="5"| Play |rowspan="5"| Client | Entity ID | VarInt | The EID of the thunderbolt |- | Type | Byte | The global entity type, currently always 1 for thunderbolt |- | X | Int | Thunderbolt X, a [[Data Types#Fixed-point numbers|fixed-point number]] |- | Y | Int | Thunderbolt Y, a [[Data Types#Fixed-point numbers|fixed-point number]] |- | Z | Int | Thunderbolt Z, a [[Data Types#Fixed-point numbers|fixed-point number]] |} ==== Open Window ==== This is sent to the client when it should open an inventory, such as a chest, workbench, or furnace. This message is not sent anywhere for clients opening their own inventory. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x2D |rowspan="5"| Play |rowspan="5"| 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. ==== Close Window ==== 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|Open Window]] packet for inventory. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- | 0x2E |rowspan="1"| Play |rowspan="1"| Client | Window ID | Unsigned Byte | This is the ID of the window that was closed. 0 for inventory. |} ==== Set Slot ==== Sent by the server when an item in a slot (in a window) is added/removed. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x2F |rowspan="3"| Play |rowspan="3"| 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 Data|Slot]] | |} ==== Window Items ==== [[File:Inventory-slots.png|thumb|The inventory slots]] 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x30 |rowspan="3"| Play |rowspan="3"| 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 Data|Slot]] | |} See [[Inventory#Windows|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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x31 |rowspan="3"| Play |rowspan="3"| 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. {| class="wikitable" |- ! Window type ! Property ! Value |- |rowspan="2"| Furnace | 0: Progress arrow | 0–200 (presumably in in-game ticks) |- | 1: Fire icon (fuel) | 0–200 (presumably in in-game ticks) |- |rowspan="7"| Enchantment Table | 0: Level requirement for top enchantment slot |rowspan="3"| 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: tooltip shown on mouse hover over top enchantment slot |rowspan="3"| Unknown (set to -1 to hide it) |- | 5: tooltip shown on mouse hover over middle enchantment slot |- | 6: tooltip shown on mouse hover over bottom enchantment slot |- |rowspan="3"| 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 |} ==== Confirm Transaction ==== A packet from the server indicating whether a request from the client was accepted, or whether there was a conflict (due to lag). {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x32 |rowspan="3"| Play |rowspan="3"| 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 |} ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x33 |rowspan="5"| Play |rowspan="5"| Client | Location | Position | |- | Line 1 | [[Chat]] | First line of text in the sign |- | Line 2 | [[Chat]] | Second line of text in the sign |- | Line 3 | [[Chat]] | Third line of text in the sign |- | Line 4 | [[Chat]] | Fourth line of text in the sign |} ==== Map ==== Updates a rectangular area on a map. {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name !colspan="2"| Field Type ! Notes |- |rowspan="12"| 0x34 |rowspan="12"| Play |rowspan="12"| Client |colspan="2"| Item Damage |colspan="2"| VarInt | The damage value (map ID) of the map being modified |- |colspan="2"| Scale |colspan="2"| Byte | |- |colspan="2"| Icon Count |colspan="2"| VarInt | Number of elements in the following array |- |rowspan="3"| Icon | Direction And Type |rowspan="3"| Array | Byte | 0xF0 = Direction, 0x0F = Type |- | X | Byte | |- | Z | Byte | |- |colspan="2"| Columns |colspan="2"| Byte | Number of columns updated |- |colspan="2"| Rows |colspan="2"| Optional Byte | Only if Columns is more than 0; number of rows updated |- |colspan="2"| X |colspan="2"| Optional Byte | Only if Columns is more than 0; x offset of the westernmost column |- |colspan="2"| Z |colspan="2"| Optional Byte | Only if Columns is more than 0; z offset of the northernmost row |- |colspan="2"| Length |colspan="2"| Optional VarInt | Only if Columns is more than 0; length of the following array |- |colspan="2"| Data |colspan="2"| Optional Array of Unsigned Byte | Only if Columns is more than 0; see {{Minecraft Wiki|Map item format}} |} ==== Update Block Entity ==== Essentially a block update on a block entity. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x35 |rowspan="3"| Play |rowspan="3"| Client | Location | Position | |- | Action | Unsigned Byte | The type of update to perform, see below |- | NBT Data | Optional [[NBT|NBT Tag]] | If not present then it's a TAG_END (0) |} ''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 ==== Open Sign Editor ==== Sent on placement of sign. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x36 |rowspan="1"| Play |rowspan="1"| Client | Location | Position | |} ==== Statistics ==== {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name !colspan="2"| Field Type ! Notes |- |rowspan="3"| 0x37 |rowspan="3"| Play |rowspan="3"| Client |colspan="2"| Count |colspan="2"| VarInt | Number of elements in the following array |- |rowspan="2"| Statistic | Name |rowspan="2"| Array | String | [https://gist.github.com/thinkofdeath/a1842c21a0cf2e1fb5e0 https://gist.github.com/thinkofdeath/a1842c21a0cf2e1fb5e0] |- | Value | VarInt | The amount to set it to |} ==== Player List Item ==== Sent by the notchian server to update the user list (<tab> in the client). {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="4"| Field Name !colspan="3"| Field Type ! Notes |- |rowspan="19"| 0x38 |rowspan="19"| Play |rowspan="19"| Client |colspan="4"| Action |colspan="3"| VarInt | Determines the rest of the Player format after the UUID |- |colspan="4"| Number Of Players |colspan="3"| VarInt | Number of elements in the following array |- |rowspan="17"| Player |colspan="3"| UUID |rowspan="17"| Array |colspan="2"| UUID | |- ! Action !colspan="2"| Field Name !colspan="2"| ! |- |rowspan="10"| 0: add player |colspan="2"| Name |colspan="2"| String | |- |colspan="2"| Number Of Properties |colspan="2"| VarInt | Number of elements in the following array |- |rowspan="4"| Property | Name |rowspan="4"| Array | String | |- | Value | String | |- | Is Signed | Boolean | |- | Signature | Optional String | Only if Is Signed is true |- |colspan="2"| Gamemode |colspan="2"| VarInt | |- |colspan="2"| Ping |colspan="2"| VarInt | |- |colspan="2"| Has Display Name |colspan="2"| Boolean | |- |colspan="2"| Display Name |colspan="2"| Optional [[Chat]] | Only if Has Display Name is true |- | 1: update gamemode |colspan="2"| Gamemode |colspan="2"| VarInt | |- | 2: update latency |colspan="2"| Ping |colspan="2"| VarInt | |- |rowspan="2"| 3: update display name |colspan="2"| Has Display Name |colspan="2"| Boolean | |- |colspan="2"| Display Name |colspan="2"| Optional [[Chat]] | Only send if Has Display Name is true |- | 4: remove player |colspan="2"| ''no fields'' |colspan="2"| ''no fields'' | |} ==== Player Abilities ==== The latter 2 floats are used to indicate the walking and flying speeds respectively, while the first byte is used to determine the value of 4 booleans. The flags are whether damage is disabled (god mode, 8, bit 3), whether the player can fly (4, bit 2), whether the player is flying (2, bit 1), and whether the player is in creative mode (1, bit 0). To get the values of these booleans, simply AND (&) the byte with 1,2,4 and 8 respectively, to get the 0 or 1 bitwise value. To set them OR (|) them with their repspective masks. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="3"| 0x39 |rowspan="3"| Play |rowspan="3"| Client | Flags | Byte | Bit mask, see above |- | Flying Speed | Float | |- | Walking Speed | Float | |} ==== Tab-Complete ==== 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x3A |rowspan="2"| Play |rowspan="2"| 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 |} ==== Scoreboard Objective ==== This is sent to the client when it should create a new {{Minecraft Wiki|scoreboard}} objective or remove one. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x3B |rowspan="4"| Play |rowspan="4"| Client | Objective Name | String | An unique name for the objective |- | Mode | Byte | 0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text. |- | Objective Value | Optional String | Only if mode is 0 or 2. The text to be displayed for the score |- | Type | Optional String | Only if mode is 0 or 2. “integer” or “hearts” |} ==== Update Score ==== This is sent to the client when it should update a scoreboard item. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x3C |rowspan="4"| Play |rowspan="4"| Client | Score Name | String | The name of the score to be updated or removed |- | Action | Byte | 0 to create/update an item. 1 to remove an item. |- | Objective Name | String | The name of the objective the score belongs to |- | Value | Optional VarInt | The score to be displayed next to the entry. Only sent when Action does not equal 1. |} ==== Display Scoreboard ==== This is sent to the client when it should display a scoreboard. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x3D |rowspan="2"| Play |rowspan="2"| 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. |} ==== Teams ==== Creates and updates teams. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="10"| 0x3E |rowspan="10"| Play |rowspan="10"| Client | 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 | Optional String | Only if Mode = 0 or 2. |- | Team Prefix | Optional String | Only if Mode = 0 or 2. Displayed before the players' name that are part of this team |- | Team Suffix | Optional String | Only if Mode = 0 or 2. Displayed after the players' name that are part of this team |- | Friendly Fire | Optional Byte | Only if Mode = 0 or 2. 0 for off, 1 for on, 3 for seeing friendly invisibles |- | Name Tag Visibility | Optional String | Only if Mode = 0 or 2. always, hideForOtherTeams, hideForOwnTeam, never |- | Color | Optional Byte | Only if Mode = 0 or 2. Same as [[Chat]] colors |- | Player Count | Optional VarInt | Only if Mode = 0 or 3 or 4. Number of players in the array |- | Players | Optional Array of String | Only if Mode = 0 or 3 or 4. Players to be added/remove from the team. Max 40 characters so may be uuid's later |} ==== Plugin Message ==== Mods and plugins can use this to send their data. Minecraft itself uses a number of [[plugin channel]]s. These internal channels are prefixed with <code>MC|</code>. More documentation on this: [http://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/ http://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/] {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x3F |rowspan="2"| Play |rowspan="2"| Client | Channel | String | Name of the [[plugin channel]] used to send the data |- | Data | Byte Array | Any data, depending on the channel. <code><nowiki>MC|</nowiki></code> channels are documented [[plugin channel|here]]. |} ==== Disconnect ==== Sent by the server before it disconnects a client. The server assumes that the sender has already closed the connection by the time the packet arrives. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- | 0x40 |rowspan="1"| Play |rowspan="1"| Client | Reason | [[Chat]] | Displayed to the client when the connection terminates. |} ==== Server Difficulty ==== Changes the difficulty setting in the client's option menu {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x41 |rowspan="1"| Play |rowspan="1"| Client | Difficulty | Unsigned Byte | 0: peaceful, 1: easy, 2: normal, 3: hard |} ==== Combat Event ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="6"| 0x42 |rowspan="6"| Play |rowspan="6"| Client | Event | VarInt | 0: enter combat, 1: end combat, 2: entity dead |- | Duration | Optional VarInt | Only for end combat |- | Player ID | Optional VarInt | Only for entity dead |- | Entity ID | Optional Int | Only for end combat and entity dead |- | Message | String | Only for entity dead |} ==== Camera ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x43 |rowspan="1"| Play |rowspan="1"| Client | Camera ID | VarInt | |} ==== World Border ==== {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name ! Field Type ! Notes |- |rowspan="18"| 0x44 |rowspan="18"| Play |rowspan="18"| Client |colspan="2"| Action | VarInt | Determines the format of the rest of the packet |- ! Action ! Field Name ! ! |- | 0: set size | Radius | Double | meters |- |rowspan="3"| 1: lerp size | Old Radius | Double | meters |- | New Radius | Double | meters |- | Speed | VarLong | number of real-time ticks/seconds (?) until New Radius is reached. From experiments, it appears that Notchian server does not sync world border speed to game ticks, so it gets out of sync with server lag |- |rowspan="2"| 2: set center | X | Double | |- | Z | Double | |- |rowspan="8"| 3: initialize | X | Double | |- | Z | Double | |- | Old Radius | Double | |- | New Radius | Double | |- | Speed | VarLong | |- | Portal Teleport Boundary | VarInt | Resulting coordinates from a portal teleport are limited to +-value. Usually 29999984. |- | Warning Time | VarInt | |- | Warning Blocks | VarInt | |- |rowspan="1"| 4: set warning time | Warning Time | VarInt | unit? |- |rowspan="1"| 5: set warning blocks | Warning Blocks | VarInt | |} ==== Title ==== {| class="wikitable" ! Packet ID ! State ! Bound To !colspan="2"| Field Name ! Field Type ! Notes |- |rowspan="9"| 0x45 |rowspan="9"| Play |rowspan="9"| Client |colspan="2"| Action | VarInt | |- ! Action ! Field Name ! ! |- | 0: set title | Title Text | [[Chat]] | |- | 1: set subtitle | Subtitle Text | [[Chat]] | |- |rowspan="3"| 2: set times and display | Fade In | Int | ticks |- | Stay | Int | ticks |- | Fade Out | Int | ticks |- | 3: hide | ''no fields'' | ''no fields'' | |- | 4: reset | ''no fields'' | ''no fields'' | |} “Hide” makes the title disappear, but if you run times again the same title will appear. “Reset” erases the text. ==== Set Compression ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x46 |rowspan="1"| Play |rowspan="1"| Client | Threshold | VarInt | Packets of this size or higher may be compressed |} ==== Player List Header And Footer ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x47 |rowspan="2"| Play |rowspan="2"| Client | Header | [[Chat]] | |- | Footer | [[Chat]] | |} ==== Resource Pack Send ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x48 |rowspan="2"| Play |rowspan="2"| Client | URL | String | The URL to the resource pack. |- | Hash | String | A 40 character hexadecimal and lowercase [[wikipedia:SHA-1|SHA-1]] hash of the resource pack file. (must be lower case in order to work)<br />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 |} ==== Update Entity NBT ==== {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="2"| 0x49 |rowspan="2"| Play |rowspan="2"| Client | Entity ID | VarInt | |- | Tag | [[NBT|NBT Tag]] | |} === 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. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x00 |rowspan="1"| Play |rowspan="1"| Server | Keep Alive ID | VarInt | |} ==== Chat Message ==== The default server will check the message to see if it begins with a '/'. If it doesn't, the username of the sender is prepended and sent to all other clients (including the original sender). If it does, the server assumes it to be a command and attempts to process it. A message longer than 100 characters will cause the server to kick the client. This change was initially done by allowing the client to not slice the message up to 119 (the previous limit), without changes to the server. For this reason, the vanilla server kept the code to cut messages at 119, but this isn't a protocol limitation and can be ignored. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x01 |rowspan="1"| Play |rowspan="1"| Server | Message | String | The client sends the raw input, not [[Chat]] |} ==== 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|Creative Inventory Action]] packet instead. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="5"| 0x02 |rowspan="5"| Play |rowspan="5"| Server | Target | VarInt | |- | Type | VarInt | 0: interact, 1: attack, 2: interact at |- | Target X | Optional Float | Only if Type is interact at |- | Target Y | Optional Float | Only if Type is interact at |- | Target Z | Optional Float | Only if Type is interact at |} ==== Player ==== This packet is used to indicate whether the player is on ground (walking/swimming), or airborne (jumping/falling). When dropping from sufficient height, fall damage is applied when this state goes from false to true. The amount of damage applied is based on the point where it last changed from true to false. Note that there are several movement related packets containing this state. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="1"| 0x03 |rowspan="1"| Play |rowspan="1"| Server | On Ground | Boolean | True if the client is on the ground, false otherwise |} ==== Player Position ==== Updates the player's XYZ 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, this will result in the client being kicked for “You moved too quickly :( (Hacking?)” If the distance is greater than 10 units, the server will log the warning message "<name> moved too quickly!", followed by two coordinate triples (maybe movement delta?), but will not kick the client. Also if the fixed-point number of X or Z is set greater than 3.2×10<sup>7</sup> the client will be kicked for “Illegal position”. {| class="wikitable" ! Packet ID ! State ! Bound To ! Field Name ! Field Type ! Notes |- |rowspan="4"| 0x04 |rowspan="4"| Play |rowspan="4"| Server | X | Double | Absolute position |- | Feet Y | Double | Absolute position, normally Head Y - 1.62 |- | Z | Double | Absolute position |- | On Ground | Boolean | True if the client is on the ground, false otherwise |} ==== Player Look ==== [[File:Minecraft-trig-yaw.png|thumb|The unit circle for yaw]] [[File:Yaw.png|thumb|The unit circle of yaw, redrawn]] Updates the direction the player is looking in. Yaw is measured in degrees, and does not follow classical trigonometry rules.
本页使用的模板:
Data Types
(
查看源代码
)
模板:Info
(
查看源代码
)
模板:Minecraft Wiki
(
查看源代码
)
模板:Plainlink
(
查看源代码
)
模板:Warning
(
查看源代码
)
模板:待更新
(
查看源代码
)
模板:待翻译
(
查看源代码
)
返回
Protocol
。
导航菜单
个人工具
登录
命名空间
页面
讨论
大陆简体
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
编辑相关
百科公告
编辑帮助
互助客栈
贡献分数
测试沙盒
发布条目
插件分类
管理
安全
聊天
编程
经济
修正
娱乐
综合
信息
机械
角色
传送
网页
整地
创世
付费
其它
工具
链入页面
相关更改
特殊页面
页面信息
相关网站
MCMOD百科
Minecraft中文百科
Minecraft纪念论坛
Minecraft百度贴吧
虚无世界Wiki