ZH:Protocol

本页面提供了对当前Minecraft协议的剖析.

如果你还有疑问，参考FAQ或在[ircs://chat.freenode.net:6697/mcdevs #mcdevs chat.freenode.net上的]IRC频道寻求帮助（更多信息）.

注意：你可以不受限制地使用此页面内容来创建服务端、客户端、机器人等，但是如果你如果复制此页面的任何内容并在其他地方发布，那么仍需要提供#mcdevs的属性.

版本间的更改可以在协议历史中查看.

定义
Minecraft服务端接受来自TCP客户端的连接并通过数据包进行交流. 数据包是通过TCP连接发送的字节序列. 数据包的含义取决于它的数据包ID和连接的当前状态. 每个连接的初始状态都是握手中，状态通过数据包握手和登入成功来更改.

经压缩
一旦发送了设置压缩数据包（带有非负阈值），将为接下来的所有数据包启用zlib压缩. 数据包的格式会略有变化，来包含未压缩数据包的大小.

由Packet Length字段提供的长度是数据包中剩余的字节数，包括Data Length字段.

如果Data Length设置为0，那么该数据包是未压缩的，否则这就是未压缩数据包的大小.

如果压缩，（Packet ID + Data）的未压缩长度必须等于或大于数据包设置压缩数据包中的阈值，否则接收方将会断开连接.

压缩可以通过发送一个负阈值的设置压缩数据包来禁用，或从开始就不发送设置压缩数据包.

客户端方
在握手中（Handshaking）状态中没有客户端方的数据包，因为协议会在客户端发送第一个数据包的瞬间切换为别的状态.

握手
这将会导致服务端切换为目标状态.

旧版服务端列表Ping
虽然从技术上来说不是当前协议的一部分，旧版客户端还是可能会发送该数据包来初始化服务端列表Ping，所以现代服务端还是应该能正确地处理它.

有关跟随该数据包的细节见服务端列表Ping#1.6

生成物体
当载具或其他物体创建时由服务端发送.

生成经验球
生成一或多个经验球.

生成全局实体
使用这个数据包，服务端会在玩家周围512格半径内发生雷击时通知客户端. 坐标指定了雷击的确切位置.

生成生物
当生物实体生成时由服务端发送.

生成画
该数据包显示画的位置、名称和类型.

计算图像的中心：给定一个（width × height）的网格， 为左上角，中心就是. 例如 是2×1的画，或 是4×4的画.

中按坐标排列的画列表（其中x和y是从左上角开始数的像素，而宽度和高度是一像素为单位或1/16格）：

也提供了画名称到实际图像的列表.

生成玩家
当玩家进入可见范围时，而不是玩家加入时，由服务端发送.

该数据包必须在生成玩家时用于服务端添加玩家数据的玩家信息数据包之后发送. 如果当该数据包到达时还不存在由该数据包生成的玩家信息，那么Notchian客户端将不会生成该玩家实体. 玩家信息数据包包含皮肤/披风数据.

虽然服务器可以为不在可见范围内的玩家安全地生成玩家实体，客户端看起来也能正确地处理它.

当处于时，UUID必须有效且拥有有效的皮肤信息.

当处于离线模式时，UUID v3会与以UTF-8编码（大小写敏感）的字符串 一起使用.

而对于NPC会使用UUID v2. 注释：

<+Grum> i will never confirm this as a feature you know that :) <+Grum> 我觉得这是你绝对不会知道的特性:)

在一个示例UUID（ ）中，UUID版本由 指定. 所以，对于UUID v3， 总是为 ，而对于UUID v2， 将总是为.

动画（客户端方）
子啊无论何时实体应改变动画时发送.

动画可以时下列值中的一个：

统计数据
作为对客户端状态0x04（id 1）的响应发送.

类别（这些是带命名空间的，但是将其中的 替换成了 ）：

方块、物品和实体会使用方块（非方块状态）、物品和实体ID.

Custom拥有以下内容（单位只对客户端有影响）：

单位：


 * 无：只是一个正常的数字（格式化为0个小数位）
 * 伤害：数值是十倍于正常量
 * 距离：以厘米为单位的距离（百分之一格）
 * 时间：以游戏刻为单位的时间跨度

方块破坏动画
0–9时可以显示的破坏阶段，而其他的数字代表在该坐标上没有动画.

方块破坏动画也用应用于空气上，尽管没有方块正在被破坏，但动画仍然是可见的. 然而，如果将其应用于透明的方块上时，会发生古怪的图像效果，包括水会丢失它的透明. （类似于正常游玩过程中破坏冰块的效果）

如果你需要在同一时间显示多个破坏动画，那么你需要给它们每个一个唯一的实体ID. 该实体ID不需要与客户端中的实际实体对应，就算使用随机生成的数字也是有效的.

更新方块实体
设置给定位置处方块所关联的方块实体.

Action字段：


 * 1：设置刷怪箱的数据（除SpawnPotentials之外的内容：当前延迟、最小/大延迟、生成的生物、生成计数和生成范围等）
 * 2：设置命令方块文本（命令和最后执行状态）
 * 3：设置信标的等级、主效果及辅助效果
 * 4：设置生物头颅的皮肤和旋转
 * 5：声明一个潮涌核心
 * 6：设置旗帜的基础色和图案
 * 7：为Structure附加值实体设置数据
 * 8：设置末地折跃门的目的地
 * 9：设置告示牌上的文本
 * 10：未使用
 * 11：声明一张床
 * 12：设置拼图方块的数据
 * 13：设置营火中的物品

方块动作
该数据包是用于一些由方块表现的动作和动画（通常是非持久性的）.

值列表详见方块动作.

方块更改
当渲染距离内的方块更改时触发.

服务端难度
更改客户端选项菜单中的难度设置.

聊天消息（客户端方）
辨别聊天和系统消息之间的差异很重要，因为这有助于用户的聊天可见性选项. 有关更多这些位置见聊天#处理聊天.

多个方块更改
在同一刻中同一区块内有两个及以上的方块被更改时触发.

要将位置编码至世界位置中：

Tab补全（客户端方）
服务器以发送给它的最后一个单词的自动补全列表作为响应. 在常规聊天的情况下，这是玩家的用户名. 同时还支持命令名称和参数. 客户端会在列出它们之前按字母顺序对它们进行排序.

声明命令
列出服务端上的所有命令，以及它们解析的方式.

这是一个拥有一个根节点的有向图. 每一个重定向节点或子节点都必须只引用已声明的节点.

有关该数据包的更多信息，见命令数据一文.

确认交互（客户端方）
A packet from the server indicating whether a request from the client was accepted, or whether there was a conflict (due to lag). If the packet was not accepted, the client must respond with a serverbound confirm transaction packet.

关闭窗口（客户端方）
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.

窗口物品


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.

See inventory windows for further information about how slots are indexed.

窗口属性
This packet is used to inform the client that part of a GUI window should be updated.

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.

For an enchanting table, the following numerical IDs are used:

设置槽
Sent by the server when an item in a slot (in a window) is added/removed.

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.

设置冷却
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. Can be applied to any item, note that interactions still get sent to the server with the item but the client does not play the animation nor attempt to predict results (i.e block placing).

插件消息（客户端方）
Mods and plugins can use this to send their data. Minecraft itself uses several plugin channels. These internal channels are in the  namespace.

More documentation on this: http://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/

命名声音效果
Used to play a sound effect on the client. Custom sounds may be added by resource packs.

断开连接（游玩）
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.

实体状态
Entity statuses generally trigger an animation for an entity. The available statuses vary by the entity's type (and are available to subclasses of that type as well).

See Entity statuses for a list of which statuses are valid for each type of entity.

爆炸
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

卸载区块
Tells the client to unload a chunk column.

It is legal to send this packet even if the given chunk is not currently loaded.

更改游戏状态
Used for a wide variety of game state things, from whether to bed use to gamemode to demo messages.

Reason codes:

打开马窗口
This packet is used exclusively for opening the horse GUI. Open Window is used for all other GUIs.

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.

The Notchian server uses a system-dependent time in milliseconds to generate the keep alive ID value.

区块数据
The server only sends skylight information for chunk pillars in the, 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).

Note that the Notchian client requires an Update View Position packet when it crosses a chunk border, otherwise it'll only display render distance + 2 chunks around the chunk it spawned in.

效果
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.

Effect IDs:

Smoke directions:

Play record: This is actually a special case within this packet. You can start/stop a record at a specific location. Use a valid to start a record (or overwrite a currently playing one), any other value will stop the record. See Data Generators for information on item IDs.

粒子
Displays the named particle

更新光照
Updates light levels for a chunk.

Individual block or sky light arrays are is given for each block with increasing x coordinates, within rows of increasing z coordinates, within layers of increasing y coordinates. Even-indexed items (those with an even x coordinate, starting at 0) are packed into the low bits, odd-indexed into the high bits.

加入游戏
See Protocol Encryption for information on logging in.

地图数据
Updates a rectangular area on a item.

For icons, a direction of 0 is a vertical icon and increments by 22.5&deg; (360/16).

Types are based off of rows and columns in :

交易列表
The list of trades a villager NPC is offering.



实体相对移动
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 should be sent instead.

This packet allows at most 8 blocks movement in any direction, because short range is from -32768 to 32767. And  = 8.

实体外观和相对移动
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.

实体外观
This packet is sent by the server when an entity rotates.

实体
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.

载具移动（客户端方）
Note that all fields use absolute positioning and do not allow for relative positioning.

打开书
Sent when a player right clicks with a signed book. This tells the client to open the book GUI.

打开窗口
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. For horses, use Open Horse Window.

打开告示牌编辑器
Sent when the client has placed a sign and is allowed to send Update Sign. There must already be a sign at the given location (which the client does not do automatically) - send a Block Change first.

合成配方响应
Response to the serverbound packet (Craft Recipe Request), with the same recipe ID. Appears to be used to notify the UI.

玩家能力（客户端方）
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.

About the flags:

玩家信息
Sent by the server to update the user list ( in the client).

The Property field looks as in the response of Mojang API, 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. 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.

Ping values correspond with icons in the following way:
 * A ping that negative (i.e. not known to the server yet) will result in the no connection icon.
 * A ping under 150 milliseconds will result in 5 bars
 * A ping under 300 milliseconds will result in 4 bars
 * A ping under 600 milliseconds will result in 3 bars
 * A ping under 1000 milliseconds (1 second) will result in 2 bars
 * A ping greater than or equal to 1 second will result in 1 bar.

面向玩家
Used to rotate the client player to face the given location or entity (for ).

If the entity given by entity ID cannot be found, this packet should be treated as if is entity was false.

玩家位置和外观（客户端方）
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  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.

About the Flags field:

 It's a bitfield, X/Y/Z/Y_ROT/X_ROT. If X is set, the x value is relative and not absolute.

解锁配方
Action:
 * 0 (init) = All the recipes in the list 2 will added to the recipe book. All the recipes in list 1 will be tagged as displayed, recipes that aren't tagged will be shown in the notification. VERIFY LIST ORDER?
 * 1 (add) = All the recipes in the list are added and their icon will be shown in the notification.
 * 2 (remove) = Remove all the recipes in the list. This allows them to re-displayed when they are readded.

破坏实体
Sent by the server when a list of entities is to be destroyed on the client.

重生
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.

实体头部外观
Changes the direction an entity's head is facing.

While sending the Entity Look packet changes the vertical rotation of the head, sending this packet appears to be necessary to rotate the head horizontally.

选择进度标签页
Sent by the server to indicate that the client should switch advancement tab. Sent either when the client switches tab in the GUI or when an advancement in another tab is made.

The Identifier can be one of the following:

If no or an invalid identifier is sent, the client will switch to the first tab in the GUI.

世界边界
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:

摄像机
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).

The notchian also loads certain shaders for given entities:


 * Creeper &rarr;
 * Spider (and cave spider) &rarr;
 * Enderman &rarr;
 * Anything else &rarr; the current shader is unloaded

手持物品更改（客户端方）
Sent to change the player's slot selection.

更新视图位置
Updates the client's location. This is used to determine what chunks should remain loaded and if a chunk load should be ignored; chunks outside of the view distance may be unloaded.

Sent whenever the player moves across a chunk border horizontally, and also (according to testing) for any integer change in the vertical axis, even if it doesn't go across a chunk section border.

更新视图距离
Sent by the integrated singleplayer server when changing render distance. Does not appear to be used by the dedicated server, as  in server.properties cannot be changed at runtime.

显示记分板
This is sent to the client when it should display a scoreboard.

实体元数据
Updates one or more metadata properties for an existing entity. Any properties not included in the Metadata field are left unchanged.

附加实体
This packet is sent when an entity has been to another entity.

实体速度
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).

设置经验
Sent by the server when the client should change experience levels.

更新生命值
Sent by the server to update/set the health of the player it is sent to.

Food 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.

记分板记分项
This is sent to the client when it should create a new objective or remove one.

队伍
Creates and updates teams.

Team Color: The color of a team defines how the names of the team members are visualized; any formatting code can be used. The following table lists all the possible values.

更新分数
This is sent to the client when it should update a scoreboard item.

生成位置
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.

时间更新
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  every second.

标题
“Hide” makes the title disappear, but if you run times again the same title will appear. “Reset” erases the text.

The title is visible on screen for Fade In + Stay + Fade Out ticks.

实体声音效果
Plays a sound effect from an entity.

声音效果
This packet is used to play a number of hardcoded sound events. For custom sounds, use Named Sound Effect.

停止声音
Categories:

玩家列表头和脚
This packet may be used by custom servers to display additional information above/below the player list. It is never sent by the Notchian server.

NBT查询响应
Sent in response to Query Block NBT or Query Entity NBT.

收集物品
Sent by the server when someone picks up an item lying on the ground — its sole purpose appears to be the animation of the item flying towards you. It doesn't destroy the entity in the client memory, and it doesn't add it to your inventory. The server only checks for items to be picked up after each Player Position (and Player Position And Look) packet sent by the client. The collector entity can be any entity; it does not have to be a player. The collected entity also can be any entity, but the Notchian server only uses this for items, experience orbs, and the different varieties of arrows.

实体传送
This packet is sent by the server when an entity moves more than 8 blocks.

进度
Advancement structure:

Advancement display:

Advancement progress:

Criterion progress:

实体属性
Sets on the given entity.

Known Key values (see also ):

Modifier Data structure:

The operation controls how the base value of the modifier is changed.


 * 0: Add/subtract amount
 * 1: Add/subtract amount percent of the current value
 * 2: Multiply by amount percent

All of the 0's are applied first, and then the 1's, and then the 2's.

实体效果
Within flags:


 * 0x01: Is ambient - was the effect spawned from a beacon? All beacon-generated effects are ambient.  Ambient effects use a different icon in the HUD (blue border rather than gray).  If all effects on an entity are ambient, the "Is potion effect ambient" living metadata field should be set to true.  Usually should not be enabled.
 * 0x02: Show particles - should all particles from this effect be hidden? Effects with particles hidden are not included in the calculation of the effect color, and are not rendered on the HUD (but are still rendered within the inventory).  Usually should be enabled.

声明配方
Recipe types:

Ingredient is defined as:

标签
Tags look like:

传送确认
Sent by client as confirmation of Player Position And Look.

查询方块NBT
Used when Shift + F3 + I is pressed while looking at a block.

设置难度
Must have at least op level 2 to use. Appears to only be used on singleplayer; the difficulty buttons are still disabled in multiplayer.

聊天消息（服务端方）
Used to send a chat message to the server. The message may not be longer than 256 characters or else the server will kick the client.

If the message starts with a, the server will attempt to interpret it as a command. Otherwise, the server will broadcast the same chat message to all players on the server (including the player that sent the message), prepended with player's name. Specifically, it will respond with a translate chat component, " " with the first parameter set to the display name of the player (including some chat component logic to support clicking the name to send a PM) and the second parameter set to the message. See processing chat for more information.

客户端状态
Action ID values:

客户端设置
Sent when the player connects, or when settings are changed.

Displayed Skin Parts flags:


 * Bit 0 (0x01): Cape enabled
 * Bit 1 (0x02): Jacket enabled
 * Bit 2 (0x04): Left Sleeve enabled
 * Bit 3 (0x08): Right Sleeve enabled
 * Bit 4 (0x10): Left Pants Leg enabled
 * Bit 5 (0x20): Right Pants Leg enabled
 * Bit 6 (0x40): Hat enabled

The most significant bit (bit 7, 0x80) appears to be unused.

Tab补全（服务端方）
Sent when the client needs to tab-complete a  suggestion type.

确认交互（服务端方）
If a transaction sent by the client was not accepted, the server will reply with a Confirm Transaction (clientbound) packet with the Accepted field set to false. When this happens, the client must send this packet to apologize (as with movement), otherwise the server ignores any successive transactions.

单击窗口按钮
Used when clicking on window buttons. Until 1.14, this was only used by enchantment tables.

单击窗口
This packet is sent by the player when it clicks on a slot in a window.

See Inventory for further information about how slots are indexed.

When right-clicking on a stack of items, half the stack will be picked up and half left in the slot. If the stack is an odd number, the half left in the slot will be smaller of the amounts.

The distinct type of click performed by the client is determined by the combination of the Mode and Button fields.

Starting from version 1.5, “painting mode” is available for use in inventory windows. It is done by picking up stack of something (more than 1 item), then holding mouse button (left, right or middle) and dragging held stack over empty (or same type in case of right button) slots. In that case client sends the following to server after mouse button release (omitting first pickup packet which is sent as usual):


 * 1) packet with mode 5, slot -999, button (0 for left | 4 for right);
 * 2) packet for every slot painted on, mode is still 5, button (1 | 5);
 * 3) packet with mode 5, slot -999, button (2 | 6);

If any of the painting packets other than the “progress” ones are sent out of order (for example, a start, some slots, then another start; or a left-click in the middle) the painting status will be reset.

The server will send back a Confirm Transaction packet. If the click was not accepted, the client must send a matching serverbound confirm transaction packet before sending more Click Window packets, otherwise the server will reject them silently. The Notchian server also sends a Window Items packet for the open window and Set Slot packets for the clicked and cursor slot, but only when the click was not accepted, probably to resynchronize client and server.

关闭窗口（服务端方）
This packet is sent by the client when closing a window.

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 the inventory.

插件消息（服务端方）
Mods and plugins can use this to send their data. Minecraft itself uses some plugin channels. These internal channels are in the  namespace.

More documentation on this: http://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/

Note that the length of Data is known only from the packet length, since the packet has no length field of any kind.

编辑书
When editing a draft, the NBT section of the Slot contains this:

TAG_Compound( '' ): 1 entry { TAG_List('pages'): 2 entries {   TAG_String(0): 'Something on Page 1' TAG_String(1): 'Something on Page 2' } }

When signing the book, it instead looks like this:

TAG_Compound( '' ): 3 entires { TAG_String('author'): 'Steve' TAG_String('title'): 'A Wonderful Book' TAG_List('pages'): 2 entries {   TAG_String(0): 'Something on Page 1' TAG_String(1): 'Something on Page 2' } }

查询实体NBT
Used when Shift + F3 + I is pressed while looking at an entity.

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

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

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

Keep Alive（服务端方）
The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same packet.

锁定难度
Must have at least op level 2 to use. Appears to only be used on singleplayer; the difficulty buttons are still disabled in multiplayer.

玩家位置
Updates the player's XYZ position on the server.

Checking for moving too fast is achieved like this:


 * Each server tick, the player's current position is stored
 * When a player moves, the changes in x, y, and z coordinates are compared with the positions from the previous tick (&Delta;x, &Delta;y, &Delta;z)
 * Total movement distance squared is computed as &Delta;x&sup2; + &Delta;y&sup2; + &Delta;z&sup2;
 * The expected movement distance squared is computed as velocityX&sup2; + veloctyY&sup2; + velocityZ&sup2;
 * If the total movement distance squared value minus the expected movement distance squared value is more than 100 (300 if the player is using an elytra), they are moving too fast.

If the player is moving too fast, it will be logged that " moved too quickly! " followed by the change in x, y, and z, and the player will be teleported back to their current (before this packet) serverside position.

Also, if the absolute value of X or the absolute value of Z is a value greater than 3.2×107, or X, Y, or Z are not finite (either positive infinity, negative infinity, or NaN), the client will be kicked for “Invalid move player packet received”.

玩家位置和外观（服务端方）
A combination of Player Look and Player Position.

玩家外观


Updates the direction the player is looking in.

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 and pitch of player (in degrees), standing at point (x0, y0, z0) and looking towards point (x, y, z) can be calculated with:

dx = x-x0 dy = y-y0 dz = z-z0 r = sqrt( dx*dx + dy*dy + dz*dz ) yaw = -atan2(dx,dz)/PI*180 if yaw < 0 then yaw = 360 + yaw pitch = -arcsin(dy/r)/PI*180

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)

玩家
This packet as well as Player Position, Player Look, and Player Position And Look are called the “serverbound movement packets”. Vanilla clients will send Player Position once every 20 ticks even for a stationary 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.

载具移动（服务端方）
Sent when a player moves in a vehicle. Fields are the same as in Player Position And Look. Note that all fields use absolute positioning and do not allow for relative positioning.

操控船
Used to visually update whether boat paddles are turning. The server will update the Boat entity metadata to match the values here.

Right paddle turning is set to true when the left button or forward button is held; left paddle turning is set to true when the right button or forward button is set to true.

拾起物品
Used to swap out an empty space on the hotbar with the item in the given inventory slot. The Notchain client uses this for pick block functionality (middle click) to retrieve items from the inventory.

The server will first search the player's hotbar for an empty slot, starting from the current slot and looping around to the slot before it. If there are no empty slots, it will start a second search from the current slot and find the first slot that does not contain an enchanted item. If there still are no slots that meet that criteria, then the server will use the currently selected slot.

After finding the appropriate slot, the server swaps the items and then send 3 packets:


 * Set Slot, with window ID set to -2 and slot set to the newly chosen slot and the item set to the item that is now in that slot (which was previously at the slot the client requested)
 * Set Slot, with window ID set to -2 and slot set to the slot the player requested, with the item that is now in that slot and was previously on the hotbar slot
 * Held Item Change, with the slot set to the newly chosen slot.

合成配方请求
This packet is sent when a player clicks a recipe in the crafting book that is craftable (white border).

玩家能力（服务端方）
The latter 2 fields are used to indicate the walking and flying speeds respectively, while the first field is used to determine the value of 4 booleans.

The vanilla client sends this packet when the player starts/stops flying with the Flags parameter changed accordingly. All other parameters are ignored by the vanilla server.

玩家挖掘
Sent when the player mines a block. A Notchian server only accepts digging packets with coordinates within a 6-unit radius between the center of the block and 1.5 units from the player's feet (not their eyes).

Status can be one of seven values:

The Face field can be one of the following values, representing the face being hit:

实体动作
Sent by the client to indicate that it has performed certain actions: sneaking (crouching), sprinting, exiting a bed, jumping with a horse, and opening a horse's inventory while riding it.

Action ID can be one of the following values:

Leave bed is only sent when the “Leave Bed” button is clicked on the sleep GUI, not when waking up due today time.

Open horse inventory is only sent when pressing the inventory key (default: E) while on a horse — all other methods of opening a horse's inventory (involving right-clicking or shift-right-clicking it) do not use this packet.

操控载具
Also known as 'Input' packet.

配方书数据
The Recipe Book Status type is sent when one of the states changes.

命名物品
Sent as a player is renaming an item in an anvil (each keypress in the anvil UI sends a new Name Item packet). If the new name is empty, then the item loses its custom name (this is different from setting the custom name to the normal name of the item). The item name may be no longer than 35 characters long, and if it is longer than that, then the rename is silently ignored.

选择交易
When a player selects a specific trade offered by a villager NPC.

设置信标效果
Changes the effect of the current beacon.

手持物品更改（服务端方）
Sent when the player changes the slot selection

创造模式物品栏动作
While the user is in the standard inventory (i.e., not a crafting bench) in Creative mode, the player will send this packet.

Clicking in the creative inventory menu is quite different from non-creative inventory management. Picking up an item with the mouse actually deletes the item from the server, and placing an item into a slot or dropping it out of the inventory actually tells the server to create the item from scratch. (This can be verified by clicking an item that you don't mind deleting, then severing the connection to the server; the item will be nowhere to be found when you log back in.) As a result of this implementation strategy, the "Destroy Item" slot is just a client-side implementation detail that means "I don't intend to recreate this item.". Additionally, the long listings of items (by category, etc.) are a client-side interface for choosing which item to create. Picking up an item from such listings sends no packets to the server; only when you put it somewhere does it tell the server to create the item in that location.

This action can be described as "set inventory slot". Picking up an item sets the slot to item ID -1. Placing an item into an inventory slot sets the slot to the specified item. Dropping an item (by clicking outside the window) effectively sets slot -1 to the specified item, which causes the server to spawn the item entity, etc.. All other inventory slots are numbered the same as the non-creative inventory (including slots for the 2x2 crafting menu, even though they aren't visible in the vanilla client).

更新拼图方块
Sent when Done is pressed on the interface.

更新结构方块
Possible actions:


 * 0 - Update data
 * 1 - Save the structure
 * 2 - Load the structure
 * 3 - Detect size

The Notchian client uses update data to indicate no special action should be taken (i.e. the done button).

更新告示牌
This message is sent from the client to the server when the “Done” button is pushed after placing a sign.

The server only accepts this packet after Open Sign Editor, otherwise this packet is silently ignored.

动画（服务端方）
Sent when the player's arm swings.

旁观
Teleports the player to the given entity. The player must be in spectator mode.

The Notchian client only uses this to teleport to players, but it appears to accept any type of entity. The entity does not need to be in the same dimension as the player; if necessary, the player will be respawned in the right world. If the given entity cannot be found (or isn't loaded), this packet will be ignored. It will also be ignored if the player attempts to teleport to themselves.

玩家方块放置
Upon placing a block, this packet is sent once.

The Cursor Position X/Y/Z fields (also known as in-block coordinates) are calculated using raytracing. The unit corresponds to sixteen pixels in the default resource pack. For example, let's say a slab is being placed against the south face of a full block. The Cursor Position X will be higher if the player was pointing near the right (east) edge of the face, lower if pointing near the left. The Cursor Position Y will be used to determine whether it will appear as a bottom slab (values 0.0–0.5) or as a top slab (values 0.5-1.0). The Cursor Position Z should be 1.0 since the player was looking at the southernmost part of the block.

Inside block is true when a player's head (specifically eyes) are inside of a block's collision. In 1.13 and later versions, collision is rather complicated and individual blocks can have multiple collision boxes. For instance, a ring of vines has a non-colliding hole in the middle. This value is only true when the player is directly in the box. In practice, though, this value is only used by scaffolding to place in front of the player when sneaking inside of it (other blocks will place behind when you intersect with them -- try with glass for instance).

使用物品
Sent when pressing the Use Item key (default: right click) with an item in hand.

登入
The login process is as follows:


 * 1) C→S: Handshake with Next State set to 2 (login)
 * 2) C→S: Login Start
 * 3) S→C: Encryption Request
 * 4) Client auth
 * 5) C→S: Encryption Response
 * 6) Server auth, both enable encryption
 * 7) S→C: Set Compression (optional)
 * 8) S→C: Login Success

Set Compression, if present, must be sent before Login Success. Note that anything sent after Set Compression must use the Post Compression packet format.

For unauthenticated and localhost connections (either of the two conditions is enough for an unencrypted connection) there is no encryption. In that case Login Start is directly followed by Login Success.

See Protocol Encryption for details.

加密请求
See Protocol Encryption for details.

登入成功
This packet switches the connection state to play.

设置压缩
Enables compression. If compression is enabled, all following packets are encoded in the compressed packet format. Negative values will disable compression, meaning the packet format should remain in the uncompressed packet format. However, this packet is entirely optional, and if not sent, compression will also not be enabled (the notchian server does not send the packet when compression is disabled).

登入插件请求
Used to implement a custom handshaking flow together with Login Plugin Response.

Unlike plugin messages in "play" mode, these messages follow a lock-step request/response scheme, where the client is expected to respond to a request indicating whether it understood. The notchian client always responds that it hasn't understood, and sends an empty payload.

加密响应
See Protocol Encryption for details.