https://zh.minecraft.wiki/
Minecraft Wiki现在已经迁移到zh.minecraft.wiki。以下是我们在新维基中成功实施的一些变化的简要概述:
- 新的外观
- 更快的加载时间
- 更少的广告
- 改进的搜索功能
- 移除了年龄弹窗
- 重新引入匿名编辑
请查看新维基上的完整公告以获取更详细的解释。
https://zh.minecraft.wiki/
Minecraft Wiki现在已经迁移到zh.minecraft.wiki。以下是我们在新维基中成功实施的一些变化的简要概述:
- 新的外观
- 更快的加载时间
- 更少的广告
- 改进的搜索功能
- 移除了年龄弹窗
- 重新引入匿名编辑
请查看新维基上的完整公告以获取更详细的解释。
https://zh.minecraft.wiki/
Minecraft Wiki现在已经迁移到zh.minecraft.wiki。以下是我们在新维基中成功实施的一些变化的简要概述:
- 新的外观
- 更快的加载时间
- 更少的广告
- 改进的搜索功能
- 移除了年龄弹窗
- 重新引入匿名编辑
请查看新维基上的完整公告以获取更详细的解释。
/data命令允许执行者获取、合并、修改或是移除方块、实体或命令存储的NBT数据。
语法
/data有四个子命令(get、merge、modify、remove)。
data ...... get (block <targetPos>|entity <target>|storage <target>) [<path>] [<scale>]- 获取指定NBT的值。
... merge (block <targetPos>|entity <target>|storage <target>) <nbt>- 将指定NBT与
<nbt>合并。 ... modify (block <targetPos>|entity <target>|storage <target>) <targetPath> ...- 修改指定NBT ...
... append ...- ...在列表最后插入一个值...
... insert <index> ...- ...在列表指定位置插入一个值...
... merge ...- ...将指定的复合NBT与另一个值合并...
... prepend ...- ...在列表最前面插入一个值...
... set ...- ...将NBT覆盖为新的值...
... from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]- ...使用特定方块、实体或存储的指定NBT。
... string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]- ...使用特定方块、实体或存储的指定NBT中的子字符串。
... value <value>- ...使用
<value>。
... remove (block <targetPos>|entity <target>|storage <target>) <path>- 删除指定NBT。
- 以多种方式展示语法
/data- 上述可代入参数有:
<target>=(block <targetPos> | entity <target> | storage <target>)<修改>=(append|insert <index>|merge|prepend|set)<source>=(block <sourcePos> | entity <source> | storage <source>)
/data… get… block <targetPos> [<path>] [<scale>]… entity <target> [<path>] [<scale>]… storage <target> [<path>] [<scale>]
… merge… block <targetPos> <nbt>… entity <target> <nbt>… storage <target> <nbt>
… modify… block <targetPos> <targetPath> (append|insert <index>|merge|prepend|set)… from… block <sourcePos> [<sourcePath>]… entity <source> [<sourcePath>]… storage <source> [<sourcePath>]
… string… block <sourcePos> [<sourcePath>] [<start>] [<end>]… entity <source> [<sourcePath>] [<start>] [<end>]… storage <source> [<sourcePath>] [<start>] [<end>]
… value <value>
… entity <target> <targetPath> (append|insert <index>|merge|prepend|set)… from… block <sourcePos> [<sourcePath>]… entity <source> [<sourcePath>]… storage <source> [<sourcePath>]
… string… block <sourcePos> [<sourcePath>] [<start>] [<end>]… entity <source> [<sourcePath>] [<start>] [<end>]… storage <source> [<sourcePath>] [<start>] [<end>]
… value <value>
… storage <target> <targetPath> (append|insert <index>|merge|prepend|set)… from… block <sourcePos> [<sourcePath>]… entity <source> [<sourcePath>]… storage <source> [<sourcePath>]
… string… block <sourcePos> [<sourcePath>] [<start>] [<end>]… entity <source> [<sourcePath>] [<start>] [<end>]… storage <source> [<sourcePath>] [<start>] [<end>]
… value <value>
… remove… block <targetPos> <path>… entity <target> <path>… storage <target> <path>
/data… get (block <targetPos>|entity <target>|storage <target>) [<path>] [<scale>]… merge (block <targetPos>|entity <target>|storage <target>) <nbt>… modify (block <targetPos>|entity <target>|storage <target>) <targetPath> (append|insert <index>|merge|prepend|set)… from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]… string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]… value <value>
… remove (block <targetPos>|entity <target>|storage <target>) <path>
/data (get (block <targetPos>|entity <target>|storage <target>) [<path>] [<scale>]|merge (block <targetPos>|entity <target>|storage <target>) <nbt>|modify (block <targetPos>|entity <target>|storage <target>) <targetPath> (append|insert <index>|merge|prepend|set) (from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]|string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]|value <value>)|remove (block <targetPos>|entity <target>|storage <target>) <path>)
data get block <targetPos> [<path>] [<scale>]data get entity <target> [<path>] [<scale>]data get storage <target> [<path>] [<scale>]data merge block <targetPos> <nbt>data merge entity <target> <nbt>data merge storage <target> <nbt>data modify block <targetPos> <targetPath> append from block <sourcePos> [<sourcePath>]data modify block <targetPos> <targetPath> append from entity <source> [<sourcePath>]data modify block <targetPos> <targetPath> append from storage <source> [<sourcePath>]data modify block <targetPos> <targetPath> append string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> append string entity <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> append string storage <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> append value <value>data modify block <targetPos> <targetPath> insert <index> from block <sourcePos> [<sourcePath>]data modify block <targetPos> <targetPath> insert <index> from entity <source> [<sourcePath>]data modify block <targetPos> <targetPath> insert <index> from storage <source> [<sourcePath>]data modify block <targetPos> <targetPath> insert <index> string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> insert <index> string entity <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> insert <index> string storage <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> insert <index> value <value>data modify block <targetPos> <targetPath> merge from block <sourcePos> [<sourcePath>]data modify block <targetPos> <targetPath> merge from entity <source> [<sourcePath>]data modify block <targetPos> <targetPath> merge from storage <source> [<sourcePath>]data modify block <targetPos> <targetPath> merge string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> merge string entity <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> merge string storage <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> merge value <value>data modify block <targetPos> <targetPath> prepend from block <sourcePos> [<sourcePath>]data modify block <targetPos> <targetPath> prepend from entity <source> [<sourcePath>]data modify block <targetPos> <targetPath> prepend from storage <source> [<sourcePath>]data modify block <targetPos> <targetPath> prepend string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> prepend string entity <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> prepend string storage <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> prepend value <value>data modify block <targetPos> <targetPath> set from block <sourcePos> [<sourcePath>]data modify block <targetPos> <targetPath> set from entity <source> [<sourcePath>]data modify block <targetPos> <targetPath> set from storage <source> [<sourcePath>]data modify block <targetPos> <targetPath> set string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> set string entity <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> set string storage <source> [<sourcePath>] [<start>] [<end>]data modify block <targetPos> <targetPath> set value <value>data modify entity <target> <targetPath> append from block <sourcePos> [<sourcePath>]data modify entity <target> <targetPath> append from entity <source> [<sourcePath>]data modify entity <target> <targetPath> append from storage <source> [<sourcePath>]data modify entity <target> <targetPath> append string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> append string entity <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> append string storage <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> append value <value>data modify entity <target> <targetPath> insert <index> from block <sourcePos> [<sourcePath>]data modify entity <target> <targetPath> insert <index> from entity <source> [<sourcePath>]data modify entity <target> <targetPath> insert <index> from storage <source> [<sourcePath>]data modify entity <target> <targetPath> insert <index> string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> insert <index> string entity <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> insert <index> string storage <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> insert <index> value <value>data modify entity <target> <targetPath> merge from block <sourcePos> [<sourcePath>]data modify entity <target> <targetPath> merge from entity <source> [<sourcePath>]data modify entity <target> <targetPath> merge from storage <source> [<sourcePath>]data modify entity <target> <targetPath> merge string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> merge string entity <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> merge string storage <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> merge value <value>data modify entity <target> <targetPath> prepend from block <sourcePos> [<sourcePath>]data modify entity <target> <targetPath> prepend from entity <source> [<sourcePath>]data modify entity <target> <targetPath> prepend from storage <source> [<sourcePath>]data modify entity <target> <targetPath> prepend string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> prepend string entity <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> prepend string storage <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> prepend value <value>data modify entity <target> <targetPath> set from block <sourcePos> [<sourcePath>]data modify entity <target> <targetPath> set from entity <source> [<sourcePath>]data modify entity <target> <targetPath> set from storage <source> [<sourcePath>]data modify entity <target> <targetPath> set string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> set string entity <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> set string storage <source> [<sourcePath>] [<start>] [<end>]data modify entity <target> <targetPath> set value <value>data modify storage <target> <targetPath> append from block <sourcePos> [<sourcePath>]data modify storage <target> <targetPath> append from entity <source> [<sourcePath>]data modify storage <target> <targetPath> append from storage <source> [<sourcePath>]data modify storage <target> <targetPath> append string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> append string entity <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> append string storage <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> append value <value>data modify storage <target> <targetPath> insert <index> from block <sourcePos> [<sourcePath>]data modify storage <target> <targetPath> insert <index> from entity <source> [<sourcePath>]data modify storage <target> <targetPath> insert <index> from storage <source> [<sourcePath>]data modify storage <target> <targetPath> insert <index> string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> insert <index> string entity <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> insert <index> string storage <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> insert <index> value <value>data modify storage <target> <targetPath> merge from block <sourcePos> [<sourcePath>]data modify storage <target> <targetPath> merge from entity <source> [<sourcePath>]data modify storage <target> <targetPath> merge from storage <source> [<sourcePath>]data modify storage <target> <targetPath> merge string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> merge string entity <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> merge string storage <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> merge value <value>data modify storage <target> <targetPath> prepend from block <sourcePos> [<sourcePath>]data modify storage <target> <targetPath> prepend from entity <source> [<sourcePath>]data modify storage <target> <targetPath> prepend from storage <source> [<sourcePath>]data modify storage <target> <targetPath> prepend string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> prepend string entity <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> prepend string storage <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> prepend value <value>data modify storage <target> <targetPath> set from block <sourcePos> [<sourcePath>]data modify storage <target> <targetPath> set from entity <source> [<sourcePath>]data modify storage <target> <targetPath> set from storage <source> [<sourcePath>]data modify storage <target> <targetPath> set string block <sourcePos> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> set string entity <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> set string storage <source> [<sourcePath>] [<start>] [<end>]data modify storage <target> <targetPath> set value <value>data remove block <targetPos> <path>data remove entity <target> <path>data remove storage <target> <path>
参数
<targetPos>:block_pos
<target>:entity(仅entity <target>模式)
- 指定需要改变NBT标签的实体。
- 必须为玩家名、目标选择器或UUID。且目标选择器只允许1个实体。
<target>:resource_location(仅storage <target>模式)
- 指定需要改变NBT标签的存储。
- 必须为命名空间ID。
<path>:nbt_path
- 指定NBT的路径。
- 必须为NBT路径。
<scale>:double
- NBT具体数值的缩放倍率。
- 必须为双精度浮点数。
<nbt>:nbt_compound_tag
- 指定要合并的复合标签。
- 必须为SNBT格式的复合类型NBT。
<targetPath>:nbt_path
- 指定的NBT的合法路径。
- 必须为NBT路径。
<index>:integer
- 指定一个列表中的元素位置。
- 必须为32位整型数值。且必须在-2147483648和2147483647(含)之间。
<sourcePos>:block_pos
<source>:entity(仅entity <source>模式)
- 需要使用其NBT标签的实体。
- 必须为玩家名、目标选择器或UUID。且目标选择器只允许1个实体。
<source>:resource_location(仅storage <source>模式)
- 需要使用其NBT标签的存储。
- 必须为命名空间ID。
<sourcePath>:nbt_path
- 使用NBT的合法路径名。
- 必须为NBT路径。
<start>:integer
- 提取子字符串时需要从源字符串中包含的首个字符的索引值(从0开始)。
- 必须为32位整型数值。且必须在0和2147483647(含)之间。
<end>
- 提取子字符串时需要从源字符串中排除的首个字符的索引值(从0开始)。
- 必须为32位整型数值。且必须在0和2147483647(含)之间。
<value>:nbt_tag
- 修改目标NBT要使用的值。必须符合数据类型。
- 必须为SNBT格式的任意类型NBT。
效果
| 命令 | 触发条件 | Java版 |
|---|---|---|
| 任意 | 参数不正确 | 无法解析 |
<targetPos>位于世界外或未被加载 | 执行失败 | |
位于<targetPos>的方块不是方块实体 | ||
<target>无法解析为单个实体(指定的玩家必须在线) | ||
/data get ... | 获取到了多个标签 | |
/data get ... <path> | <path>不存在 | |
/data get ... <path> <scale> | 指定的不是数字类标签 | |
/data merge ... | 未更改任何NBT | |
| 尝试更改玩家的NBT | ||
/data remove ... | <path>指定了根标签 | |
/data modify ... (from|string) block ... | <sourcePos>位于世界外或未被加载 | |
位于<sourcePos>的方块不是方块实体 | ||
/data modify ... (from|string) entity ... | <source>无法解析为单个实体(指定的玩家必须在线) | |
/data modify ... (from|string) ... <sourcePath> | <sourcePath>不存在 | |
/data modify ... string ... <sourcePath> <start> <end> | <sourcePath>的值不是字符串且无法转换为字符串 | |
<start>或<end>超出范围(0 ~ 231-1) | ||
<start>大于<end> | ||
<end>超出源字符串最大索引值 | ||
/data modify ... append ... | 指定的标签不是数组或列表 | |
| 源数据的类型不适用于列表 | ||
/data modify ... insert <index> ... | 指定的索引无效 | |
/data modify ... merge ... | 指定的NBT不是复合标签 | |
| 来源NBT不是复合标签 | ||
| 任意 | 执行成功时 | 读取、合并、修改或删除指定NBT。 详见下: |
若成功:
/data get-
/data get ...- 返回目标方块或实体的NBT数据,并且带有语法高亮。
- 若适用,成功时的返回值为1。
/data get ... <path>- 返回目标方块或实体的一部分NBT数据,也带有语法高亮。
- 返回值取决于获取的NBT元素的类型。
- 获取一个数字,则返回值为数字。
- 获取一个字符串,则返回该字符串的长度。
- 获取一个列表会返回该列表中元素的个数。
- 获取一个复合标签会返回该标签下一级子元素(不包括子元素的子元素)的数量。
/data get ... <path> <scale>- 返回该标签的值并乘以
<scale>。 - 此时
<path>需要指向一个数字类型的标签,即该标签的类型可以为TAG_byte、TAG_short、TAG_int、TAG_long、TAG_float或TAG_double。
/data merge- 将目标方块或实体的特定NBT数据与指定的
<nbt>数据合并。
/data modify-
append- 在指定列表的末尾增加一个元素。
<targetPath>必须指定一个TAG_list类型的元素,源数据应该适用于作为列表中的一个元素。insert <index>- 将数据以第
<index>个元素插入指定列表,其后的元素的编号自动加一。 <targetPath>必须指定一个TAG_list类型的元素,源数据应该适用于作为列表中的一个元素。merge- 将源数据与指定的对象合并。
<targetPath>必须指定一个TAG_compound类型的元素,源数据必须是TAG_compound类型。prepend- 在指定列表的开头增加一个元素。
<targetPath>必须指定一个TAG_list类型的元素,源数据应该适用于作为列表中的一个元素。set- 将
<targetPath>指定的标签设定为源数据。
- 若适用,成功时的返回值为1。
/data remove- 移除指定方块或实体的
<path>指向的NBT数据。无法移除玩家的NBT数据。 - 若适用,成功时的返回值为1。
输出
| 命令 | 版本 | 条件 | 成功次数 | /execute store success ... | /execute store result ... |
|---|---|---|---|---|---|
| 任意 | Java版 | 执行失败 | 0 | 0 | 0 |
/data get ... | 执行成功 | 1 | 1 | 1 | |
/data get ... <path> | 取得数字类标签 | 1 | 1 | 向下取整后取得的值[1] | |
| 取得列表或数组标签 | 1 | 1 | 此列表或数组含有的元素数量 | ||
| 取得字符串标签 | 1 | 1 | 字符串的长度 | ||
| 取得复合标签 | 1 | 1 | 此复合标签含有的一级子标签的数量 | ||
/data get ... <path> <scale> | 执行成功 | 1 | 1 | 取得的值乘以<scale>后向下取整[2] | |
/data merge ... | 执行成功 | 1 | 1 | 1 | |
/data remove ... | 执行成功 | 1 | 1 | 1 | |
/data modify ... append ... | 执行成功 | 1 | 1 | 被加入新元素的列表或数组的数量 | |
/data modify ... set ... | 执行成功 | 1 | 1 | 成功更改的目标标签的数量 | |
/data modify ... merge ... | 执行成功 | 1 | 1 | 成功更改的目标复合标签的数量 |
NBT路径
存储
使用NBT数据保存的命令存储是访问或储存NBT数据的有效方法,且其无需通过方块实体或实体读取或写入NBT数据。
每个命令存储都保存着通用的键值对。命令存储使用命名空间ID进行区分。
/data get和/data modify可以读取存储,而/data merge、/data modify、/data remove和/execute store可以写入存储。
命令存储也可以通过原始JSON文本读取。
示例
- 获取执行者的饱和度:
/data get entity @s foodSaturationLevel
- 使10格内最近的物品无法被玩家捡起:
/data modify entity @e[type=item,distance=..10,limit=1,sort=nearest] PickupDelay set value -1
- 获取随机物品的Y轴位置:
/data get entity @e[type=item,limit=1,sort=random] Pos[1]
- 获取最近玩家快捷栏第一格物品的命名空间ID:
/data get entity @p Inventory[{Slot:0b}].id
- 将距离坐标(0, 64, 0)最近的海豚的护甲属性设置为20:
/data modify entity @e[x=0,y=64,z=0,type=dolphin,limit=1] Attributes[{Name:"minecraft:generic.armor"}].Base set value 20
- 将位于(1, 64, 1)处容器内的第一个物品设置为钻石(保留原有的其他NBT):
/data modify block 1 64 1 Items[0].id set value "minecraft:diamond_block"
- 将最近的僵尸副手物品的掉落概率调整为80%,主手物品的掉落概率调整为0%:
/data merge entity @e[type=zombie,limit=1,sort=nearest] {HandDropChances: [0f, 0.8f]}
历史
| Java版 | |||||
|---|---|---|---|---|---|
| 1.13 | 17w45b | 加入了/data。 | |||
| 18w03a | 带有路径的/data get现在适用于非数字的值。 | ||||
| 1.14 | 18w43a | 加入了/data modify。 | |||
| 1.15 | 19w38a | 加入了命令存储。 | |||
加入了storage <命名空间ID>作为来源或目标。 | |||||
| 19w39a | 为NBT storage加入了聊天组件。 | ||||
| 1.19.4 | 23w03a | 加入了string数据源。 | |||
注释
语言