• 欢迎来到Minecraft插件百科!
  • 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
  • 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289

Protocol:修订间差异

来自Minecraft插件百科
跳转到导航 跳转到搜索
(翻译)
 
(未显示4个用户的23个中间版本)
第1行: 第1行:
{{待翻译}}
{{待翻译}}
{{待更新|url=http://wiki.vg/Protocol}}


这里剖析了最近的 '''[http://wiki.vg/Protocol_Encryption Minecraft协议]'''.
这里剖析了最近的 '''[http://wiki.vg/Protocol_Encryption Minecraft协议]'''.
第9行: 第10行:
== 定义 ==
== 定义 ==


Minecraft服务器是基于TCP通讯的。它和客户端使用所谓的 ''数据包''交流. 一个包被通过字节编码后从TCP连接中发送. 数据包的含义取决于其包标识和连接的当前状态. 每个链接从 '''[http://wiki.vg/Handshaking 握手]'''开始, 使用包切换状态 '''[http://wiki.vg/Handshaking 握手]''',( 0x00, serverbound) and [[#Login Success|Login Success]] ([[#Login|Login]], 0x02, clientbound).
Minecraft服务器是基于TCP通讯的。它和客户端使用所谓的 ''数据包''交流. 一个包被通过字节编码后从TCP连接中发送. 数据包的含义取决于其包标识和连接的当前状态. 每个链接从 '''[http://wiki.vg/Handshaking 握手]'''开始, 使用包切换状态 '''[http://wiki.vg/Handshaking 握手]''',( 0x00, serverbound) [[#Login Success|成功登陆]] ([[#Login|登陆]], 0x02, clientbound).


=== 数据类型 ===
=== 数据类型 ===
第21行: 第22行:
{| class="wikitable"
{| class="wikitable"
  |-
  |-
  ! Term
  ! 术语
  ! Definition
  ! 定义
  |-
  |-
  | Player
  | Player——玩家
  | When used in the singular, Player always refers to the client connected to the server.
  | 使用时, 玩家通常使用它来链接到服务端.
  |-
  |-
  | Entity
  | Entity——实体
  | Entity refers to any item, player, mob, minecart or boat etc. See {{Minecraft Wiki|Entity|the Minecraft Wiki article}} for a full list.
  | 实体相当于玩家、物品、怪物、船和矿车等. 查看 {{Minecraft Wiki|Entity|the Minecraft Wiki article}} 来寻找一个完整的表单.
  |-
  |-
  | EID
  | EID——实体ID
  | 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.
  | An EID — 或者说是实体ID 是一个用来识别特定实体的4字节序列. 在同一个服务器,没有相同的实体编号.
  |-
  |-
  | XYZ
  | 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.
  | 游戏时,可以使用按钮“F3”来在屏幕上查看坐标位置 Y代表高度, X代表东西, Z代表南北.
  |-
  |-
  | Meter
  | 单位“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”.
  | Meter是Minecraft的基本长度单位, 相当于一个方块的长度. “block”一词也许意味着 “meter”或者“cubic meter”.
  |}
  |}


== 包的格式 ==
== 数据包的格式 ==


=== 无压缩 ===
=== 无压缩 ===


{| class="wikitable"
{| class="wikitable"
  ! Field Name
  ! 域名称
  ! Field Type
  ! 域类型
  ! Notes
  ! 注释
  |-
  |-
  | Length
  | 长度
  | VarInt
  | VarInt
  | Length of packet data + length of the packet ID
  | 包数据的长度 + 包序号的长度
  |-
  |-
  | Packet ID
  | 包序号
  | VarInt
  | VarInt
  |  
  |  
  |-
  |-
  | Data
  | 数据
  | Byte Array
  | Byte Array
  | Depends on the connection state and packet ID, see the sections below
  | 依赖于连接状态和包序号,详见下面的部分。
  |}
  |}


=== 压缩 ===
=== 压缩 ===


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.
当一个 [[#Set Compression|设置压缩]] 包被发送,[[wikipedia:Zlib|zlib]] 压缩将会对之后的所有包开启。 包的格式略微改变以包含未压缩前的包的长度。
 
''译注:注意区分包长度和数据长度,关系:“包”包含“数据”''
{| class=wikitable
{| class=wikitable
  ! Compressed?
  ! 是否压缩
  ! Field Name
  ! 域名称
  ! Field Type
  ! 域类型
  ! Notes
  ! 注释
  |-
  |-
  | No
  |
  | Packet Length
  | 包长度
  | VarInt
  | VarInt
  | Length of Data Length + compressed length of (Packet ID + Data)
  | 数据长度的长度 + 压缩后的 (包序号 + 数据) 的长度
  |-
  |-
  | No
  |
  | Data Length
  | 数据长度
  | VarInt
  | VarInt
  | Length of uncompressed (Packet ID + Data) or 0
  | 未压缩前的 (包序号 + 数据) 的长度 或 0
  |-
  |-
  |rowspan="2"| Yes
  |rowspan="2"|
  | Packet ID
  | 包序号
  | Varint
  | Varint
  | zlib compressed packet ID (see the sections below)
  | zlib 压缩后的包序号(详见下面的部分)
  |-
  |-
  | Data
  | 数据
  | Byte Array
  | Byte Array
  | zlib compressed packet data (see the sections below)
  | zlib 压缩后的包数据(详见下面的部分)
  |}
  |}


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.
如果数据长度被设置为 0,则这个包没有被压缩;否则它表示已压缩的包未压缩前的包长度。


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.
如果包被压缩,压缩前的 (包序号 + 数据) 的长度必须等于或大于 [[#Set Compression|设置压缩]] 包中设置的最小值,否则客户端/服务端将会断开连接。


Compression can be disabled by sending a [[#Set Compression|Set Compression]] packet with a Threshold of -1.
压缩能通过发送一个最小值设定为 -1 的 [[#Set Compression|设置压缩]] 包来关闭。


== 握手协议 ==
== 握手协议 ==
第104行: 第105行:
=== 客户端绑定 ===
=== 客户端绑定 ===


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.
因为协议在客户端发送第一个数据包后会立刻切换到另一个阶段,所以握手阶段没有客户端绑定的数据包。


=== 服务端绑定 ===
=== 服务端绑定 ===
第110行: 第111行:
==== 握手协议 ====
==== 握手协议 ====


This causes the server to switch into the target state.
这将使得服务器切换至目标阶段。


{| class="wikitable"
{| class="wikitable"
第123行: 第124行:
  |rowspan="4"| Handshaking
  |rowspan="4"| Handshaking
  |rowspan="4"| Server
  |rowspan="4"| Server
  | Protocol Version
  | 协议版本
  | VarInt
  | VarInt
  | See [[protocol version numbers]] (currently 47)
  | See [[protocol version numbers]] (currently 47)
  |-
  |-
  | Server Address
  | 服务器地址
  | String
  | String
  | hostname or IP, e.g. localhost or 127.0.0.1<!-- does this support IPv6? -->
  | 域名或是IP, 例如: localhost 或是 127.0.0.1<!-- does this support IPv6? -->
  |-  
  |-  
  | Server Port
  | 服务器端口
  | Unsigned Short
  | Unsigned Short
  | default is 25565
  | 默认值为25565
  |-
  |-
  | Next State
  | 下一阶段
  | VarInt
  | VarInt
  | 1 for [[#Status|status]], 2 for [[#Login|login]]
  | 1 for [[#Status|status]], 2 for [[#Login|login]]
  |}
  |}


==== 传统服务器列表 ====
==== 传统的服务器列表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.
严格来说这不是当前协议的一部分,传统客户端可能会发送这一数据包来发起(initiate) [[Server List Ping]], 现代服务器也应当能够适当地处理这一数据包。


{| class="wikitable"
{| class="wikitable"
第164行: 第165行:
== 开始游戏 ==
== 开始游戏 ==


=== 客户端绑定 ===
=== 发送到客户端 ===


==== 心跳包 ====
==== 心跳包 ====
第230行: 第231行:
  |}
  |}


{{Warning|If the Dimension isn't valid then the client will crash}}
{{Warning|如果位置无效,服务端将崩溃}}


==== 聊天内容 ====  
==== 聊天内容 ====  
第256行: 第257行:
  |}
  |}


{{Warning|Malformed JSON will disconnect the client}}
{{Warning|错误的JSON将断开连接}}


==== 时间更新 ====
==== 时间更新 ====


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.
MineCraft中的时间以 ticks 为基础, 现实中1秒为 20 ticks。游戏中一天有 24000 ticks,也就是现实中20分钟。


The time of day is based on the timestamp modulo 24000. 0 is sunrise, 6000 is noon, 12000 is sunset, and 18000 is midnight.
游戏中每天的时间是以 24000 ticks为标准的,0 ticks 为日出, 6000 ticks 为晌午, 12000 为日落, 因而 18000 为午夜。


The default SMP server increments the time by <code>20</code> every second.
默认情况下,双路处理器的服务器也遵循以上规则。


{| class="wikitable"
{| class="wikitable"
第279行: 第280行:
  | World Age
  | World Age
  | Long
  | Long
  | In ticks; not changed by server commands
  | 基于 ticks 计算; 不因外部命令而改变
  |-
  |-
  | Time of day
  | Time of day
  | Long
  | Long
  | The world (or region) time, in ticks. If negative the sun will stop moving at the Math.abs of the time
  | 世界(或地区)时间以ticks为单位。异常情况下太阳将会在 Math.abs 的时间停止运动
  |}
  |}


第364行: 第365行:
==== 重生 ====
==== 重生 ====


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.
来改变玩家的位置(主世界/地狱/末地), 发送给他们一个重生指令, 其次是prechunks或chunks的新位置, and finally a position and look packet. You do not need to unload chunks, the client will do it automatically.


{| class="wikitable"
{| class="wikitable"
第394行: 第395行:
  |}
  |}


{{Warning|If the Dimension isn't valid then the client will crash}}
{{Warning|如果位置无效,服务端将崩溃 }}


{{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)}}
{{Warning|如果玩家出现在了相同的位置, weird bugs can occur i.e. such player will be unable to attack other players in new world (修复后他们将重生)}}


==== 玩家姿势以及看的方向 ====  
==== 玩家姿势以及看的方向 ====  
第2,346行: 第2,347行:
  |}
  |}


==== Set Slot ====
==== 设置位置 ====


Sent by the server when an item in a slot (in a window) is added/removed.
Sent by the server when an item in a slot (in a window) is added/removed.
第2,374行: 第2,375行:
  |}
  |}


==== Window Items ====
==== 窗口物品 ====


[[File:Inventory-slots.png|thumb|The inventory slots]]
[[File:Inventory-slots.png|thumb|The inventory slots]]
第2,406行: 第2,407行:
See [[Inventory#Windows|inventory windows]] for further information about how slots are indexed.
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.
此包是用于与客户端交流更新GUI窗体的部分。


{| class="wikitable"
{| class="wikitable"
第2,427行: 第2,428行:
  | Property
  | Property
  | Short
  | Short
  | The property to be updated, see below
  | 要更新的属性,见下文
  |-
  |-
  | Value
  | Value
  | Short
  | 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"
{| class="wikitable"
第2,486行: 第2,487行:
  |}
  |}


==== 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).
A packet from the server indicating whether a request from the client was accepted, or whether there was a conflict (due to lag).
第2,514行: 第2,515行:
  |}
  |}


==== 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.
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.
第2,550行: 第2,551行:
  |}
  |}


==== Map ====
==== 地图 ====


Updates a rectangular area on a map.
Updates a rectangular area on a map.
第2,616行: 第2,617行:
  |}
  |}


==== Update Block Entity ====
==== 更新方块实体 ====


Essentially a block update on a block entity.
Essentially a block update on a block entity.
第2,653行: 第2,654行:
* '''6''': Set base color and patterns on a banner
* '''6''': Set base color and patterns on a banner


==== Open Sign Editor ====
==== 打开标志牌编辑器 ====


Sent on placement of sign.
Sent on placement of sign.
第2,673行: 第2,674行:
  |}
  |}


==== Statistics ====
==== 统计数据 ====


{| class="wikitable"
{| class="wikitable"
第2,701行: 第2,702行:
  |}
  |}


==== Player List Item ====
==== 玩家列表项 ====


Sent by the notchian server to update the user list (<tab> in the client).
Sent by the notchian server to update the user list (<tab> in the client).
第2,803行: 第2,804行:
  |}
  |}


==== 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 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.
第2,835行: 第2,836行:
  |}
  |}


==== Tab-Complete ====
==== Tab补全 ====


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.
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.
第2,859行: 第2,860行:
  |}
  |}


==== Scoreboard Objective ====
==== 计分板目标 ====


This is sent to the client when it should create a new {{Minecraft Wiki|scoreboard}} objective or remove one.
This is sent to the client when it should create a new {{Minecraft Wiki|scoreboard}} objective or remove one.
第2,891行: 第2,892行:
  |}
  |}


==== Update Score ====
==== 更新分数 ====


This is sent to the client when it should update a scoreboard item.  
This is sent to the client when it should update a scoreboard item.  
第2,923行: 第2,924行:
  |}
  |}


==== Display Scoreboard ====
==== 显示计分板 ====


This is sent to the client when it should display a scoreboard.
This is sent to the client when it should display a scoreboard.
第2,947行: 第2,948行:
  |}
  |}


==== Teams ====
==== 团队 ====


Creates and updates teams.
Creates and updates teams.
第3,011行: 第3,012行:
  |}
  |}


==== 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>.
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>.
第3,037行: 第3,038行:
  |}
  |}


==== 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.
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.
第3,057行: 第3,058行:
  |}
  |}


==== Server Difficulty ====
==== 服务器难度 ====


Changes the difficulty setting in the client's option menu
Changes the difficulty setting in the client's option menu
第3,077行: 第3,078行:
  |}
  |}


==== Combat Event ====
==== 战斗事件 ====


{| class="wikitable"
{| class="wikitable"
第3,111行: 第3,112行:
  |}
  |}


==== Camera ====
==== 摄像机 ====


{| class="wikitable"
{| class="wikitable"
第3,129行: 第3,130行:
  |}
  |}


==== World Border ====  
==== 世界边界 ====  


{| class="wikitable"
{| class="wikitable"
第3,222行: 第3,223行:
  |}
  |}


==== Title ====  
==== 显示标题 ====  


{| class="wikitable"
{| class="wikitable"
第3,280行: 第3,281行:
“Hide” makes the title disappear, but if you run times again the same title will appear. “Reset” erases the text.
“Hide” makes the title disappear, but if you run times again the same title will appear. “Reset” erases the text.


==== Set Compression ====
==== 设置压缩 ====


{| class="wikitable"
{| class="wikitable"
第3,295行: 第3,296行:
  | Threshold
  | Threshold
  | VarInt
  | VarInt
  | Packets of this size or higher may be compressed
  | 这种大小或更高的包可以被压缩。
  |}
  |}


==== Player List Header And Footer ====
==== 玩家列表页眉与页脚 ====


{| class="wikitable"
{| class="wikitable"
第3,320行: 第3,321行:
  |}
  |}


==== Resource Pack Send ====  
==== 发送资源包 ====  


{| class="wikitable"
{| class="wikitable"
第3,335行: 第3,336行:
  | URL
  | URL
  | String
  | String
  | The URL to the resource pack.
  | 资源包的 URL 地址
  |-
  |-
  | Hash
  | Hash
  | String
  | 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
  | 一个40个字符的十六进制和小写的[[wikipedia:SHA-1|SHA-1]]哈希的资源包文件。(必须小写)<br />如果不符合上一行的标准, 客户端将不会验证它哈希值及浪费不必要的带宽 但仍将把它作为唯一的标识符处理
  |}
  |}


==== Update Entity NBT ====  
==== 更新实体 NBT ====  


{| class="wikitable"
{| class="wikitable"
第3,364行: 第3,365行:
  |}
  |}


=== 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.
服务器会经常发送一个保持连接包,内含一个随机的ID。客户端必须回应同样的包。


{| class="wikitable"
{| class="wikitable"
第3,386行: 第3,387行:
  |}
  |}


==== 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.
默认服务端会检查信息是否以 '/' 开头。如果不是是,发送者的用户名将被放在消息前并且发送到所有其他客户端(包括原始的发送者)。如果是,服务端认为它是一个命令并尝试处理它。一个长度大于 100 的信息会导致服务端踢出该客户端。这个行为一开始是在不修改服务端的前提下不允许客户端不分段发送长度超过 119(以前的限制)的信息。因为这个原因,原始的服务端保留了在 119 处将消息切片的代码,但是这不是一个协议限制并且可以被跳过。


{| class="wikitable"
{| class="wikitable"
第3,406行: 第3,407行:
  |}
  |}


==== 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.
一个官方服务端只在被攻击或使用的实体是可视的、在以玩家为中心 4单位 的范围内且与玩家之间没有阻碍时才接受这个包。


Note that middle-click in creative mode is interpreted by the client and sent as a [[#Creative Inventory Action|Creative Inventory Action]] packet instead.
注意:创造模式的中键点击会被客户端解析且被发送为 [[#Creative Inventory Action|创造背包动作]] 包。


{| class="wikitable"
{| class="wikitable"
第3,435行: 第3,436行:
  | Target X
  | Target X
  | Optional Float
  | Optional Float
  | Only if Type is interact at
  | 只有当类型为 interact at
  |-
  |-
  | Target Y
  | Target Y
  | Optional Float
  | Optional Float
  | Only if Type is interact at
  | 只有当类型为 interact at
  |-
  |-
  | Target Z
  | Target Z
  | Optional Float
  | Optional Float
  | Only if Type is interact at
  | 只有当类型为 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.
当从足够高的高度掉落,这个状态从 false 设置为 true 时会受到掉落伤害。受到伤害的数值基于最后状态从 true 设置为 false。 注意有一些运动相关的包包含了这个包。


{| class="wikitable"
{| class="wikitable"
第3,465行: 第3,466行:
  | On Ground
  | On Ground
  | Boolean
  | Boolean
  | True if the client is on the ground, false otherwise
  | 当对象站在地上时为 true , 反之则为 false
  |}
  |}


==== Player Position ====
==== 玩家坐标 ====


Updates the player's XYZ position on the server.
更新玩家在服务器上的 XYZ 坐标。


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?)”
如果在服务器上最后记录的位置和这个包设置的新位置之间的距离大于 100 单位,将会导致客户端因为 “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.
如果之间的距离大于 10 单位,服务器会在日志中写下警告信息 “<name> moved too quickly!” 和两个三元坐标(可能是运动增量?),但不会踢出客户端。


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”.
如果 X Z 的定点数被设置大于 3.2×10<sup>7</sup> 客户端会因为 “Illegal position” 而被踢出服务器。


{| class="wikitable"
{| class="wikitable"
第3,491行: 第3,492行:
  | X
  | X
  | Double
  | Double
  | Absolute position
  | 绝对位置
  |-
  |-
  | Feet Y
  | Feet Y
  | Double
  | Double
  | Absolute position, normally Head Y - 1.62
  | 绝对位置,史蒂夫头部一般在 Y - 1.62
  |-
  |-
  | Z
  | Z
  | Double
  | Double
  | Absolute position
  | 绝对位置
  |-
  |-
  | On Ground
  | On Ground
  | Boolean
  | Boolean
  | True if the client is on the ground, false otherwise
  | 当对象站在地上时为 true , 反之则为 false
  |}
  |}


==== Player Look ====
==== 玩家观察 ====
[[File:Minecraft-trig-yaw.png|thumb|The unit circle for yaw]]
[[File:Minecraft-trig-yaw.png|thumb|The unit circle for yaw]]
[[File:Yaw.png|thumb|The unit circle of yaw, redrawn]]
[[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.
偏航(Yaw)以度为单位,并且不遵循经典的三角规则。

2017年9月2日 (六) 14:46的最新版本

本页面已存在其他语言的内容,请协助翻译为本地化的中文。
  • 点击此处开始翻译。
  • 如本模板出现在原文存档页面,请注意更新主页面后,仍需要去除此处该模板。
  • 如当前页面已经没有需要翻译的内容,请删去待翻译模板。
  • 有标题的大篇幅文章,如果短时间内无法全部翻译,请先把所有的标题翻译出来,以便之后的贡献者选择与翻译章节内容。
本条目对应原文已经或正在更新。
近期请前往这里关注,查看新的版本并更新至本条目。

这里剖析了最近的 Minecraft协议.

如果你有疑问, 请查阅下文或在IRC请求帮助 (#mcdevs on irc.freenode.net).

注意: 你可以不受限制地使用这个页面的内容来创建服务端, 客户端, 机器人…… 诸如此类的任何东西…

定义

Minecraft服务器是基于TCP通讯的。它和客户端使用所谓的 数据包交流. 一个包被通过字节编码后从TCP连接中发送. 数据包的含义取决于其包标识和连接的当前状态. 每个链接从 握手开始, 使用包切换状态 握手,( 0x00, serverbound) 和 成功登陆 (登陆, 0x02, clientbound).

数据类型

所有通过网络发送的数据均为大端序(big-endian),这意味着字节被从高位向低位发送。日常中大多数的计算机使用小端序存储,所以可能需要在发送数据到网络之前将其转换为大端序。

名称 长度 (字节) 内容 注释
Boolean 1 false 或 true 值可以是 true (0x01) 或 false (0x00)
Byte 1 -128 到 127 有符号的 8 位整型,负数补码
Unsigned Byte 1 0 to 255 无符号的 8 位整型
Short 2 -32768 to 32767 有符号 16 位整型,负数补码
Unsigned Short 2 0 到 65535 无符号 16 位整型
Int 4 -2147483648 到 2147483647 有符号 32 位整型,负数补码
Long 8 -9223372036854775808 到 9223372036854775807 有符号 64 位整型,负数补码
Float 4 单精度 32 位 IEEE 754 浮点数
Double 8 双精度 64 位 IEEE 754 浮点数
String ≥ 1
≤ 2147483652
一个 Unicode 编码序列 UTF-8 string 开头用 VarInt 以 byte 为单位表示它的长度
Chat ≥ 1
≤ 2147483652
详见 Chat 以 String 编码
VarInt ≥ 1
≤ 5
-2147483648 to 2147483647 Protocol Buffer Varint,编码了一个负数补码的有符号 32 位整型
VarLong ≥ 1
≤ 10
-9223372036854775808 to 9223372036854775807 Protocol Buffer Varint,编码了一个负数补码的有符号 64 位整型
Chunk 可变 一个垂直区块列 详见 SMP Map Format#Data
Metadata 可变 详见 Entities#Entity Metadata Format
Slot 可变 详见 Slot Data
Object Data 4 或 10 详见 Object Data
NBT Tag 可变 详见 NBT
Position 8 整型/方块坐标: x (-33554432 到 33554431), y (-2048 到 2047), z (-33554432 到 33554431) x 为一个 26 位整型,随着的是用 12 位整型表示的 y,然后是用 26 位整型表示的 z (均为有符号,负数补码)。同时参阅 下面的部分.
Angle 1 以一整圈的 1/256 为步长的旋转角度 是否有符号没有关系因为结果的角度是相同的。
UUID 16 一个 通用唯一识别码 官方版本的 Minecraft 服务器内部以两个 long 发送。
this.writeLong(uuid.getMostSignificantBits());
this.writeLong(uuid.getLeastSignificantBits());
Optional X 0 或 X 的长度 一个 X 类型的域或者什么都不是 域是否存在必须从上下文中得知。
Array of X X 的长度乘重复次数 零或以上个 X 类型的域 域的数量必须从上下文中得知。
Byte Array 可变 依赖于上下文 这只是一个零或更多个 Byte 的序列,他的含义将会在其他地方被解释,例如:在包描述中。长度必须从上下文中得知。

位置

分成 3 部分的 64 个比特位

  • x: 26 MSBs
  • z: 26 LSBs
  • y: 12 bits between them

编码方法:

((x & 0x3FFFFFF) << 38) | ((y & 0xFFF) << 26) | (z & 0x3FFFFFF)

解码方法:

long val; // Encoded value
x = val >> 38;
y = (val >> 26) & 0xFFF
z = val << 38 >> 38

Note: 位移的细节是和编程语言相关的;以上代码若没有调整可能在 Java 中正确运行但在其他语言中无法正确运行????。

定点数据

有些域可能会被存储为 定点数(fixed point),即使用一定数量的比特位来存储数字的整数部分(小数点的左边),其余比特位表示小数部分 (小数点的右边)。浮点数 (float 和 double) 则相反,它将数字本身(底数)放在一个块里,小数点的位置(指数)在其一旁存储。

实际上,虽然定点数的范围比浮点数小,但他们对于更大的数值的精度更高。这使得他们成为在 Minecraft 中表示一个实体的全局坐标的理想选择,因为比起在一个方块(或一米)中精确的定位他们而言,能存储表示他们所在方块位置的整数部分显得更重要。

坐标通常被表示为一个 32 位的整型,地址最低的 5 位被用来存储小数部分,剩余的用来存储整数部分。

Java 缺乏对带小数部分的整型的直接支持,但你可以将他们表示为整型(integer)。如果要从一个 double 转换到这个整型表示,使用以下公式:

 abs_int = (int)double * 32;

逆向过程:

 double = (double)abs_int / 32;

其他定义

术语 定义
Player——玩家 使用时, 玩家通常使用它来链接到服务端.
Entity——实体 实体相当于玩家、物品、怪物、船和矿车等. 查看 the Minecraft Wiki article 来寻找一个完整的表单.
EID——实体ID An EID — 或者说是实体ID — 是一个用来识别特定实体的4字节序列. 在同一个服务器,没有相同的实体编号.
XYZ坐标 游戏时,可以使用按钮“F3”来在屏幕上查看坐标位置 Y代表高度, X代表东西, Z代表南北.
单位“Meter” Meter是Minecraft的基本长度单位, 相当于一个方块的长度. “block”一词也许意味着 “meter”或者“cubic meter”.

数据包的格式

无压缩

域名称 域类型 注释
长度 VarInt 包数据的长度 + 包序号的长度
包序号 VarInt
数据 Byte Array 依赖于连接状态和包序号,详见下面的部分。

压缩

当一个 设置压缩 包被发送,zlib 压缩将会对之后的所有包开启。 包的格式略微改变以包含未压缩前的包的长度。 译注:注意区分包长度和数据长度,关系:“包”包含“数据”

是否压缩 域名称 域类型 注释
包长度 VarInt 数据长度的长度 + 压缩后的 (包序号 + 数据) 的长度
数据长度 VarInt 未压缩前的 (包序号 + 数据) 的长度 或 0
包序号 Varint zlib 压缩后的包序号(详见下面的部分)
数据 Byte Array zlib 压缩后的包数据(详见下面的部分)

包长度域提供的是包中存在的字节的数量,包括数据长度域。

如果数据长度被设置为 0,则这个包没有被压缩;否则它表示已压缩的包未压缩前的包长度。

如果包被压缩,压缩前的 (包序号 + 数据) 的长度必须等于或大于 设置压缩 包中设置的最小值,否则客户端/服务端将会断开连接。

压缩能通过发送一个最小值设定为 -1 的 设置压缩 包来关闭。

握手协议

客户端绑定

因为协议在客户端发送第一个数据包后会立刻切换到另一个阶段,所以握手阶段没有客户端绑定的数据包。

服务端绑定

握手协议

这将使得服务器切换至目标阶段。

Packet ID State Bound To Field Name Field Type Notes
0x00 Handshaking Server 协议版本 VarInt See protocol version numbers (currently 47)
服务器地址 String 域名或是IP, 例如: localhost 或是 127.0.0.1
服务器端口 Unsigned Short 默认值为25565
下一阶段 VarInt 1 for status, 2 for login

传统的服务器列表Ping

严格来说这不是当前协议的一部分,传统客户端可能会发送这一数据包来发起(initiate) Server List Ping, 现代服务器也应当能够适当地处理这一数据包。

Packet ID State Bound To Field Name Field Type Notes
0xFE Handshaking Server Payload Unsigned Byte always 1 (0x01)

See Server List Ping#1.6 for the details of the protocol that follows this packet.

开始游戏

发送到客户端

心跳包

The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same packet. If the client does not respond to them for over 30 seconds, the server kicks the client. Vice versa, if the server does not send any keep-alives for 20 seconds, the client will disconnect and yields a "Timed out" exception.

Packet ID State Bound To Field Name Field Type Notes
0x00 Play Client Keep Alive ID VarInt

加入游戏

See Protocol Encryption for information on logging in.

Packet ID State Bound To Field Name Field Type Notes
0x01 Play Client Entity ID Int The player's Entity ID (EID)
Gamemode Unsigned Byte 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. Bit 3 (0x8) is the hardcore flag.
Dimension 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 debug screen.

如果位置无效,服务端将崩溃

聊天内容

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

Packet ID State Bound To Field Name Field Type Notes
0x02 Play Client JSON Data Chat Limited to 32767 bytes
Position Byte 0: chat (chat box), 1: system message (chat box), 2: above action bar

错误的JSON将断开连接

时间更新

MineCraft中的时间以 ticks 为基础, 现实中1秒为 20 ticks。游戏中一天有 24000 ticks,也就是现实中20分钟。

游戏中每天的时间是以 24000 ticks为标准的,0 ticks 为日出, 6000 ticks 为晌午, 12000 为日落, 因而 18000 为午夜。

默认情况下,双路处理器的服务器也遵循以上规则。

Packet ID State Bound To Field Name Field Type Notes
0x03 Play Client World Age Long 基于 ticks 计算; 不因外部命令而改变
Time of day Long 世界(或地区)时间以ticks为单位。异常情况下太阳将会在 Math.abs 的时间停止运动

持有的物品

Packet ID State Bound To Field Name Field Type Notes
0x04 Play 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 Item in slot format

出生姿势

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

Packet ID State Bound To Field Name Field Type Notes
0x05 Play Client Location Position Spawn location

更新生命值

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

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

Packet ID State Bound To Field Name Field Type Notes
0x06 Play 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

重生

来改变玩家的位置(主世界/地狱/末地), 发送给他们一个重生指令, 其次是prechunks或chunks的新位置, and finally a position and look packet. You do not need to unload chunks, the client will do it automatically.

Packet ID State Bound To Field Name Field Type Notes
0x07 Play 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

如果位置无效,服务端将崩溃

如果玩家出现在了相同的位置, weird bugs can occur i.e. such player will be unable to attack other players in new world (修复后他们将重生)

玩家姿势以及看的方向

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 3.2E7D the client will be kicked for “Illegal position”.

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

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

The yaw 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)
Packet ID State Bound To Field Name Field Type Notes
0x08 Play Client X Double Absolute or relative position, depending on Flags
Y Double Absolute or relative position, depending on Flags
Z Double Absolute or relative position, depending on Flags
Yaw Float Absolute or relative rotation on the X Axis, in degrees
Pitch Float Absolute or relative rotation on the Y Axis, in degrees
Flags Byte Bit field, see below

About the Flags field:

<Dinnerbone> It's a bitfield, X/Y/Z/Y_ROT/X_ROT. If X is set, the x value is relative and not absolute.
Field Bit
X 0x01
Y 0x02
Z 0x04
Y_ROT 0x08
X_ROT 0x10

持有物品变更

Sent to change the player's slot selection.

Packet ID State Bound To Field Name Field Type Notes
0x09 Play Client Slot Byte The slot which the player has selected (0–8)

使用床

This packet tells that a player goes to bed.

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

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

Packet ID State Bound To Field Name Field Type Notes
0x0A Play Client Entity ID VarInt Sleeping player's EID
Location Position Block location of the head part of the bed

动画

Sent whenever an entity should change animation.

Packet ID State Bound To Field Name Field Type Notes
0x0B Play Client Entity ID VarInt Player ID
Animation Unsigned Byte Animation ID (see below)

Animation can be one of the following values:

ID Animation
0 Swing arm
1 Take damage
2 Leave bed
3 Eat food
4 Critical effect
5 Magic critical effect

生成玩家

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

This packet must be sent after the Player List Item (Play, 0x38, clientbound) packet that adds the player data for the client to use when spawning a player. If the 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, xxxxxxxx-xxxx-Yxxx-xxxx-xxxxxxxxxxxx, the UUID version is specified by Y. So, for UUID v3, Y will always be 3, and for UUID v2, Y will always be 2.

Packet ID State Bound To Field Name Field Type Notes
0x0C Play Client Entity ID VarInt Player's EID
Player UUID UUID
X Int Player X as a Fixed-Point number
Y Int Player Y as a Fixed-Point number
Z Int Player Z as a 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 Metadata

A negative Current Item crashes clients

The client will crash if no Metadata is sent

拾起物品

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.

Packet ID State Bound To Field Name Field Type Notes
0x0D Play Client Collected Entity ID VarInt
Collector Entity ID VarInt

生成对象

Sent by the server when an Object/Vehicle is created.

Packet ID State Bound To Field Name Field Type Notes
0x0E Play Client Entity ID VarInt EID of the object
Type Byte The type of object (See Objects)
X Int X position as a Fixed-Point number
Y Int Y position as a Fixed-Point number
Z Int Z position as a Fixed-Point number
Pitch Angle
Yaw Angle
Data Object Data

生成怪物

Sent by the server when a Mob Entity is Spawned

Packet ID State Bound To Field Name Field Type Notes
0x0F Play Client Entity ID VarInt
Type Unsigned Byte The type of mob. See Mobs
X Int X position as a Fixed-Point number
Y Int Y position as a Fixed-Point number
Z Int Z position as a Fixed-Point number
Yaw Angle
Pitch Angle
Head Pitch Angle
Velocity X Short Same units as Entity Velocity
Velocity Y Short Same units as Entity Velocity
Velocity Z Short Same units as Entity Velocity
Metadata Metadata

重生绘图

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

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

2x1 (1, 0)
4x4 (1, 2)
Packet ID State Bound To Field Name Field Type Notes
0x10 Play 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)

重生掉落经验

Spawns one or more experience orbs.

Packet ID State Bound To Field Name Field Type Notes
0x11 Play Client Entity ID VarInt Entity's ID
X Int X position as a Fixed-Point number
Y Int Y position as a Fixed-Point number
Z Int Z position as a Fixed-Point number
Count Short The amount of experience this orb will reward once collected

实体速率

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

Packet ID State Bound To Field Name Field Type Notes
0x12 Play 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

销毁实体

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

Packet ID State Bound To Field Name Field Type Notes
0x13 Play Client Count VarInt Number of elements in the following array
Entity IDs Array of VarInt The list of entities of destroy

实体

This packet may be used to initialize an entity.

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

Packet ID State Bound To Field Name Field Type Notes
0x14 Play Client Entity ID VarInt

实体相对移动

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 should be sent instead.

This packet allows at most four blocks movement in any direction, because byte range is from -128 to 127.

Packet ID State Bound To Field Name Field Type Notes
0x15 Play Client Entity ID VarInt
Delta X Byte Change in X position as a Fixed-Point number
Delta Y Byte Change in Y position as a Fixed-Point number
Delta Z Byte Change in Z position as a Fixed-Point number
On Ground Boolean

实体朝向

This packet is sent by the server when an entity rotates.

Packet ID State Bound To Field Name Field Type Notes
0x16 Play Client Entity ID VarInt
Yaw Angle New angle, not a delta
Pitch Angle New angle, not a delta
On Ground Boolean

实体朝向与相对移动

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)

Packet ID State Bound To Field Name Field Type Notes
0x17 Play Client Entity ID VarInt
Delta X Byte Change in X position as a Fixed-Point number
Delta Y Byte Change in Y position as a Fixed-Point number
Delta Z Byte Change in Z position as a Fixed-Point number
Yaw Angle New angle, not a delta
Pitch Angle New angle, not a delta
On Ground Boolean

实体传送

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

Packet ID State Bound To Field Name Field Type Notes
0x18 Play Client Entity ID VarInt
X Int X position as a Fixed-Point number
Y Int Y position as a Fixed-Point number
Z Int Z position as a Fixed-Point number
Yaw Angle New angle, not a delta
Pitch Angle New angle, not a delta
On Ground Boolean

实体手朝向

Changes the direction an entity's head is facing.

Packet ID State Bound To Field Name Field Type Notes
0x19 Play Client Entity ID VarInt
Head Yaw Angle New angle, not a delta

实体状态

Packet ID State Bound To Field Name Field Type Notes
0x1A Play Client Entity ID Int
Entity Status Byte See below
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

附加实体

This packet is sent when a player has been attached to an entity (e.g. Minecart).

Packet ID State Bound To Field Name Field Type Notes
0x1B Play 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

实体数据值

Packet ID State Bound To Field Name Field Type Notes
0x1C Play Client Entity ID VarInt
Metadata Metadata

实体属性

Packet ID State Bound To Field Name Field Type Notes
0x1D Play Client Entity ID VarInt
Effect ID Byte See this table
Amplifier Byte Notchian client displays effect level as Amplifier + 1
Duration VarInt Seconds
Hide Particles Boolean

移除实体属性

Packet ID State Bound To Field Name Field Type Notes
0x1E Play Client Entity ID VarInt
Effect ID Byte See this table

设置经验值

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

Packet ID State Bound To Field Name Field Type Notes
0x1F Play Client Experience bar Float Between 0 and 1
Level VarInt
Total Experience VarInt See Experience#Leveling up on the Minecraft Wiki for Total Experience to Level conversion

实体配置

Packet ID State Bound To Field Name Field Type Notes
0x20 Play Client Entity ID VarInt
Number Of Properties Int Number of elements in the following array
Property Key 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 Attribute#Modifiers

Known Key values:

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

Modifier Data structure:

Field Name Field Type Notes
UUID UUID
Amount Double
Operation Byte

区块数据

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 (id << 4) | data
Packet ID State Bound To Field Name Field Type Notes
0x21 Play 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 Chunk

多个方块改变

Fired whenever 2 or more blocks are changed within the render distance.

Packet ID State Bound To Field Name Field Type Notes
0x22 Play Client Chunk X Int Chunk X coordinate
Chunk Z Int Chunk Z coordinate
Record Count VarInt Number of elements in the following array, a.k.a. the number of blocks affected
Record Horizontal Position Array Unsigned Byte The 4 most significant bits (0xF0) encode the X coordinate, relative to the chunk. The 4 least significant bits (0x0F) encode the Z coordinate, relative to the chunk.
Y Coordinate Unsigned Byte
Block ID VarInt The new block ID for the block. id << 4 | data

方块改变

Fired whenever a block is changed within the render distance.

Packet ID State Bound To Field Name Field Type Notes
0x23 Play Client Location Position Block Coordinates
Block ID VarInt The new block ID for the block. id << 4 | data

方块功能

This packet is used for a number of things:

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

See Also: Block Actions

Packet ID State Bound To Field Name Field Type Notes
0x24 Play Client Location Position Block Coordinates
Byte 1 Unsigned Byte Varies depending on block — see Block Actions
Byte 2 Unsigned Byte Varies depending on block — see Block Actions
Block Type VarInt The block type for the block

方块破坏动画

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)

Packet ID State Bound To Field Name Field Type Notes
0x25 Play 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

地图区块

1.8 changes at Chunk Data

To reduce the number of bytes, this packet is used to send chunks together for better compression results.

Packet ID State Bound To Field Name Field Type Notes
0x26 Play Client Sky Light Sent Boolean Whether or not Chunk Data contains light nibble arrays. This is true in the Overworld, false in the End + Nether
Chunk Column Count VarInt Number of elements in each of the following arrays
Chunk Meta Chunk X 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
Chunk Data Array of Chunk Each chunk in this array corresponds to the data at the same position in Chunk Meta

爆炸

Sent when an explosion occurs (creepers, TNT, and ghast fireballs).

Each block in Records is set to air. Coordinates for each axis in record is int(X) + record.x

Packet ID State Bound To Field Name Field Type Notes
0x27 Play Client X Float
Y Float
Z Float
Radius Float Currently unused in the client
Record Count Int Number of elements in the following array
Records Array of (Byte, Byte, Byte) Each record is 3 signed bytes long, each bytes are the XYZ (respectively) offsets of affected blocks.
Player Motion X Float X velocity of the player being pushed by the explosion
Player Motion Y Float Y velocity of the player being pushed by the explosion
Player Motion Z Float Z velocity of the player being pushed by the explosion

属性

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

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

Packet ID State Bound To Field Name Field Type Notes
0x28 Play Client Effect ID Int The ID of the effect, see below
Location Position The location of the effect
Data Int Extra data for certain effects, see below
Disable Relative Volume Boolean See above

Effect IDs:

ID Name Data
Sound
1000 random.click
1001 random.click
1002 random.bow
1003 random.door_open or random.door_close (50/50 chance)
1004 random.fizz
1005 Play a music disc. Record ID
1006 not assigned
1007 mob.ghast.charge
1008 mob.ghast.fireball
1009 mob.ghast.fireball, but with a lower volume
1010 mob.zombie.wood
1011 mob.zombie.metal
1012 mob.zombie.woodbreak
1013 mob.wither.spawn
1014 mob.wither.shoot
1015 mob.bat.takeoff
1016 mob.zombie.infect
1017 mob.zombie.unfect
1018 mob.enderdragon.end
1020 random.anvil_break
1021 random.anvil_use
1022 random.anvil_land
Particle
2000 Spawns 10 smoke particles, e.g. from a fire Direction, see below
2001 Block break Block ID
2002 Splash potion. Particle effect + glass break sound. Potion ID
2003 Eye of Ender entity break animation — particles and sound
2004 Mob spawn particle effect: smoke + flames
2005 Spawn “happy villager” effect (green crosses), used for bonemealing vegetation

Smoke directions:

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

声音特效

Used to play a sound effect on the client.

Custom sounds may be added by resource packs.

Packet ID State Bound To Field Name Field Type Notes
0x29 Play Client Sound name String All known sound effect names can be seen 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

粒子效果

Displays the named particle

Packet ID State Bound To Field Name Field Type Notes
0x2A Play Client Particle ID Int See below
Long Distance Boolean If true, particle distance increases from 256 to 65536
X Float X position of the particle
Y Float Y position of the particle
Z Float Z position of the particle
Offset X Float This is added to the X position after being multiplied by random.nextGaussian()
Offset Y Float This is added to the Y position after being multiplied by random.nextGaussian()
Offset Z Float This is added to the Z position after being multiplied by random.nextGaussian()
Particle Data Float The data of each particle
Particle Count Int The number of particles to create
Data Array of VarInt Length depends on particle. "iconcrack" has length of 2, "blockcrack", and "blockdust" have lengths of 1, the rest have 0.

Particle IDs:

Particle Name Particle ID
explode 0
largeexplosion 1
hugeexplosion 2
fireworksSpark 3
bubble 4
splash 5
wake 6
suspended 7
depthsuspend 8
crit 9
magicCrit 10
smoke 11
largesmoke 12
spell 13
instantSpell 14
mobSpell 15
mobSpellAmbient 16
witchMagic 17
dripWater 18
dripLava 19
angryVillager 20
happyVillager 21
townaura 22
note 23
portal 24
enchantmenttable 25
flame 26
lava 27
footstep 28
cloud 29
reddust 30
snowballpoof 31
snowshovel 32
slime 33
heart 34
barrier 35
iconcrack_(id)_(data) 36
blockcrack_(id+(data<<12)) 37
blockdust_(id) 38
droplet 39
take 40
mobappearance 41

改变游戏状态

It appears when a bed can't be used as a spawn point and when the rain state changes.

Packet ID State Bound To Field Name Field Type Notes
0x2B Play Client Reason Unsigned Byte See below
Value Float Depends on Reason

Reason codes:

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

生存全局实体

With this packet, the server notifies the client of thunderbolts striking within a 512 block radius around the player. The coordinates specify where exactly the thunderbolt strikes.

Packet ID State Bound To Field Name Field Type Notes
0x2C Play 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 fixed-point number
Y Int Thunderbolt Y, a fixed-point number
Z Int Thunderbolt Z, a fixed-point number

打开窗户

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

Packet ID State Bound To Field Name Field Type Notes
0x2D Play Client Window ID Unsigned Byte A unique id number for the window to be displayed. Notchian server implementation is a counter, starting at 1.
Window Type String The window type to use for display. See Inventory for a list.
Window Title Chat The title of the window
Number Of Slots Unsigned Byte Number of slots in the window (excluding the number of slots in the player inventory)
Entity ID Optional Int EntityHorse's EID. Only sent when Window Type is “EntityHorse”

See Inventory for further information.

关闭窗户

This packet is sent from the server to the client when a window is forcibly closed, such as when a chest is destroyed while it's open.

Note, notchian clients send a close window packet with Window ID 0 to close their inventory even though there is never an Open Window packet for inventory.

Packet ID State Bound To Field Name Field Type Notes
0x2E Play Client Window ID Unsigned Byte This is the ID of the window that was closed. 0 for inventory.

设置位置

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

Packet ID State Bound To Field Name Field Type Notes
0x2F Play Client Window ID Byte The window which is being updated. 0 for player inventory. Note that all known window types include the player inventory. This packet will only be sent for the currently opened window while the player is performing actions, even if it affects the player inventory. After the window is closed, a number of these packets are sent to update the player's inventory window (0).
Slot Short The slot that should be updated
Slot Data Slot

窗口物品

文件:Inventory-slots.png
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.

Packet ID State Bound To Field Name Field Type Notes
0x30 Play Client Window ID Unsigned Byte The ID of window which items are being sent for. 0 for player inventory.
Count Short Number of elements in the following array
Slot Data Array of Slot

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

窗体属性

此包是用于与客户端交流更新GUI窗体的部分。

Packet ID State Bound To Field Name Field Type Notes
0x31 Play Client Window ID Unsigned Byte
Property Short 要更新的属性,见下文
Value Short 属性的新值,见下文

属性字段的含义取决于窗体的类型。下表显示了窗体类型和属性的已知组合和价值的定义范围。

Window type Property Value
Furnace 0: Progress arrow 0–200 (presumably in in-game ticks)
1: Fire icon (fuel) 0–200 (presumably in in-game ticks)
Enchantment Table 0: Level requirement for top enchantment slot The enchantment's xp level requirement
1: Level requirement for middle enchantment slot
2: Level requirement for bottom enchantment slot
3: The seed for generating the enchantments view for the client Unknown
4: tooltip shown on mouse hover over top enchantment slot 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
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

确认事物

A packet from the server indicating whether a request from the client was accepted, or whether there was a conflict (due to lag).

Packet ID State Bound To Field Name Field Type Notes
0x32 Play Client Window ID Byte The ID of the window that the action occurred in
Action Number Short Every action that is to be accepted has a unique number. This field corresponds to that number.
Accepted Boolean Whether the action was accepted

更新标志

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

Packet ID State Bound To Field Name Field Type Notes
0x33 Play 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

地图

Updates a rectangular area on a map.

Packet ID State Bound To Field Name Field Type Notes
0x34 Play Client Item Damage VarInt The damage value (map ID) of the map being modified
Scale Byte
Icon Count VarInt Number of elements in the following array
Icon Direction And Type Array Byte 0xF0 = Direction, 0x0F = Type
X Byte
Z Byte
Columns Byte Number of columns updated
Rows Optional Byte Only if Columns is more than 0; number of rows updated
X Optional Byte Only if Columns is more than 0; x offset of the westernmost column
Z Optional Byte Only if Columns is more than 0; z offset of the northernmost row
Length Optional VarInt Only if Columns is more than 0; length of the following array
Data Optional Array of Unsigned Byte Only if Columns is more than 0; see Map item format

更新方块实体

Essentially a block update on a block entity.

Packet ID State Bound To Field Name Field Type Notes
0x35 Play Client Location Position
Action Unsigned Byte The type of update to perform, see below
NBT Data Optional 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

打开标志牌编辑器

Sent on placement of sign.

Packet ID State Bound To Field Name Field Type Notes
0x36 Play Client Location Position

统计数据

Packet ID State Bound To Field Name Field Type Notes
0x37 Play Client Count VarInt Number of elements in the following array
Statistic Name Array String https://gist.github.com/thinkofdeath/a1842c21a0cf2e1fb5e0
Value VarInt The amount to set it to

玩家列表项

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

Packet ID State Bound To Field Name Field Type Notes
0x38 Play Client Action VarInt Determines the rest of the Player format after the UUID
Number Of Players VarInt Number of elements in the following array
Player UUID Array UUID
Action Field Name
0: add player Name String
Number Of Properties VarInt Number of elements in the following array
Property Name Array String
Value String
Is Signed Boolean
Signature Optional String Only if Is Signed is true
Gamemode VarInt
Ping VarInt
Has Display Name Boolean
Display Name Optional Chat Only if Has Display Name is true
1: update gamemode Gamemode VarInt
2: update latency Ping VarInt
3: update display name Has Display Name Boolean
Display Name Optional Chat Only send if Has Display Name is true
4: remove player no fields no fields

玩家能力

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

Packet ID State Bound To Field Name Field Type Notes
0x39 Play Client Flags Byte Bit mask, see above
Flying Speed Float
Walking Speed Float

Tab补全

The server responds with a list of auto-completions of the last word sent to it. In the case of regular chat, this is a player username. Command names and parameters are also supported.

Packet ID State Bound To Field Name Field Type Notes
0x3A Play Client Count VarInt Number of elements in the following array
Matches Array of String One eligible command, note that each command is sent separately instead of in a single string, hence the need for Count

计分板目标

This is sent to the client when it should create a new scoreboard objective or remove one.

Packet ID State Bound To Field Name Field Type Notes
0x3B Play 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”

更新分数

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

Packet ID State Bound To Field Name Field Type Notes
0x3C Play 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.

显示计分板

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

Packet ID State Bound To Field Name Field Type Notes
0x3D Play Client Position Byte The position of the scoreboard. 0: list, 1: sidebar, 2: below name.
Score Name String The unique name for the scoreboard to be displayed.

团队

Creates and updates teams.

Packet ID State Bound To Field Name Field Type Notes
0x3E Play 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

插件信息

Mods and plugins can use this to send their data. Minecraft itself uses a number of plugin channels. These internal channels are prefixed with MC|.

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

Packet ID State Bound To Field Name Field Type Notes
0x3F Play Client Channel String Name of the plugin channel used to send the data
Data Byte Array Any data, depending on the channel. MC| channels are documented here.

断开连接

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.

Packet ID State Bound To Field Name Field Type Notes
0x40 Play Client Reason Chat Displayed to the client when the connection terminates.

服务器难度

Changes the difficulty setting in the client's option menu

Packet ID State Bound To Field Name Field Type Notes
0x41 Play Client Difficulty Unsigned Byte 0: peaceful, 1: easy, 2: normal, 3: hard

战斗事件

Packet ID State Bound To Field Name Field Type Notes
0x42 Play 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

摄像机

Packet ID State Bound To Field Name Field Type Notes
0x43 Play Client Camera ID VarInt

世界边界

Packet ID State Bound To Field Name Field Type Notes
0x44 Play Client Action VarInt Determines the format of the rest of the packet
Action Field Name
0: set size Radius Double meters
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
2: set center X Double
Z Double
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
4: set warning time Warning Time VarInt unit?
5: set warning blocks Warning Blocks VarInt

显示标题

Packet ID State Bound To Field Name Field Type Notes
0x45 Play Client Action VarInt
Action Field Name
0: set title Title Text Chat
1: set subtitle Subtitle Text Chat
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.

设置压缩

Packet ID State Bound To Field Name Field Type Notes
0x46 Play Client Threshold VarInt 这种大小或更高的包可以被压缩。

玩家列表页眉与页脚

Packet ID State Bound To Field Name Field Type Notes
0x47 Play Client Header Chat
Footer Chat

发送资源包

Packet ID State Bound To Field Name Field Type Notes
0x48 Play Client URL String 资源包的 URL 地址
Hash String 一个40个字符的十六进制和小写的SHA-1哈希的资源包文件。(必须小写)
如果不符合上一行的标准, 客户端将不会验证它哈希值及浪费不必要的带宽 — 但仍将把它作为唯一的标识符处理

更新实体 NBT

Packet ID State Bound To Field Name Field Type Notes
0x49 Play Client Entity ID VarInt
Tag NBT Tag

发送到服务器

保持连接

服务器会经常发送一个保持连接包,内含一个随机的ID。客户端必须回应同样的包。

Packet ID State Bound To Field Name Field Type Notes
0x00 Play Server Keep Alive ID VarInt

聊天信息

默认服务端会检查信息是否以 '/' 开头。如果不是是,发送者的用户名将被放在消息前并且发送到所有其他客户端(包括原始的发送者)。如果是,服务端认为它是一个命令并尝试处理它。一个长度大于 100 的信息会导致服务端踢出该客户端。这个行为一开始是在不修改服务端的前提下不允许客户端不分段发送长度超过 119(以前的限制)的信息。因为这个原因,原始的服务端保留了在 119 处将消息切片的代码,但是这不是一个协议限制并且可以被跳过。

Packet ID State Bound To Field Name Field Type Notes
0x01 Play Server Message String The client sends the raw input, not Chat

使用实体

这个包在玩家攻击或者右键点击其他实体(一个玩家、矿车等)时从客户端发往服务器。

一个官方服务端只在被攻击或使用的实体是可视的、在以玩家为中心 4单位 的范围内且与玩家之间没有阻碍时才接受这个包。

注意:创造模式的中键点击会被客户端解析且被发送为 创造背包动作 包。

Packet ID State Bound To Field Name Field Type Notes
0x02 Play Server Target VarInt
Type VarInt 0: interact, 1: attack, 2: interact at
Target X Optional Float 只有当类型为 interact at 时
Target Y Optional Float 只有当类型为 interact at 时
Target Z Optional Float 只有当类型为 interact at 时

玩家状态

这个包用于表明玩家正在陆地上(行走/游泳)还是在空中(跳跃/掉落)。

当从足够高的高度掉落,这个状态从 false 设置为 true 时会受到掉落伤害。受到伤害的数值基于最后状态从 true 设置为 false。 注意有一些运动相关的包包含了这个包。

Packet ID State Bound To Field Name Field Type Notes
0x03 Play Server On Ground Boolean 当对象站在地上时为 true , 反之则为 false

玩家坐标

更新玩家在服务器上的 XYZ 坐标。

如果在服务器上最后记录的位置和这个包设置的新位置之间的距离大于 100 单位,将会导致客户端因为 “You moved too quickly :( (Hacking?)” 而被踢出服务器。

如果之间的距离大于 10 单位,服务器会在日志中写下警告信息 “<name> moved too quickly!” 和两个三元坐标(可能是运动增量?),但不会踢出客户端。

如果 X 或 Z 的定点数被设置大于 3.2×107 客户端会因为 “Illegal position” 而被踢出服务器。

Packet ID State Bound To Field Name Field Type Notes
0x04 Play Server X Double 绝对位置
Feet Y Double 绝对位置,史蒂夫头部一般在 Y - 1.62
Z Double 绝对位置
On Ground Boolean 当对象站在地上时为 true , 反之则为 false

玩家观察

文件:Minecraft-trig-yaw.png
The unit circle for yaw
文件:Yaw.png
The unit circle of yaw, redrawn

更新玩家目前所看的方向。

偏航(Yaw)以度为单位,并且不遵循经典的三角规则。