
命令
/item
将物品放入实体或容器方块的指定物品栏槽位,在槽位之间复制物品,或修改已有的物品。
| /item (fill|override|replace) (block <target>|entity <target>) <slots> from (block <source>|entity <source>) <sourceSlots> [<modifier>] |
| /item (fill|override|replace) (block <target>|entity <target>) <slots> with <item> [<count>] |
| /item modify (block <target>|entity <target>) <slots> <modifier> |
| 参数 | 值的类型 | 输入内容 |
|---|---|---|
| <target> | 方块位置 | 物品的去向:block 之后的方块位置,或 entity 之后的一个或多个实体。 |
| <slots> | 物品槽位 | 要更改的槽位:槽位名称(如weapon.mainhand)、槽位组(如hotbar.*),或来自数据包或直接写出的槽位来源。 |
| <source> | 方块位置 | 对于 from:复制物品的来源方块位置或实体。 |
| <sourceSlots> | 物品槽位 | 对于 from:复制物品的来源栏位,写法与 slots 相同。 |
| <modifier> | 物品修饰器 | 数据包中某个物品修饰器的ID,或直接写出的物品修饰器。 |
| <item> | 物品 | 对于with:物品ID,后面可跟方括号中的组件。 |
| <count> | 整数 | 对于with:堆叠的大小,从1到99。默认为1。 |
| 权限等级 | 2:管理员、开启作弊的世界、命令方块和函数 |
| 适用于 | 多人服务器上的管理员、启用作弊的单人世界,以及命令方块和函数。 |
| 结果 | 提示“已替换...个槽位”或“已修改...个槽位”,并附上实体或方块的位置。/execute store 保存的数字是被更改的槽位数量。 |
| replace | 将指定物品依次放入选定槽位,物品用完时停止。只有一个物品但有多个栏位时,每个目标只有第一个栏位会收到它。 |
| fill | 将指定物品放入每个选定槽位,物品用完时从第一个物品重新开始。 |
| override | 将指定物品依次放入选定槽位,并清空剩余的选定槽位。 |
| modify | 对所选栏位中的物品应用物品修饰器。空槽位会被跳过。 |
| with | 使用写在命令中的新物品,数量可选,范围为1到99。 |
| from | 复制另一个方块或实体槽位中的物品。放置之前,会对副本应用可选的物品修饰器。源保留其物品。 |
| 槽位名称 | 单个槽位:contents、container.0到container.53、hotbar.0到hotbar.8、inventory.0到inventory.26、enderchest.0到enderchest.26、mob.inventory.0到mob.inventory.7、horse.0到horse.14、weapon、weapon.mainhand、weapon.offhand、armor.head、armor.chest、armor.legs、armor.feet、armor.body、 saddle、horse.chest、player.cursor以及player.crafting.0到player.crafting.3。整组:container.*、hotbar.*、inventory.*、enderchest.*、mob.inventory.*、horse.*、weapon.*、armor.* 和 player.crafting.*。 |
| 方块必须是容器 | 方块目标或来源必须是带有物品栏的方块,例如箱子。否则命令会失败并提示“不是容器”。 |
| 缺失的栏位 | 如果没有目标拥有所选栏位,则失败,并提示“目标没有栏位 ...”;如果来源没有其中任何栏位,则提示“来源没有栏位 ...”。 |
| 无变化 | 如果没有任何槽位被更改,则会失败并提示“没有对象在指定槽位接受物品”。 |
/item replace entity @s weapon.mainhand with minecraft:diamond_sword在你的主手放入:钻石剑,并替换你手中的物品。
/item replace block ~ ~-1 ~ container.0 with minecraft:diamond 16将16x 钻石放入你下方容器的第一个槽位。
/item fill entity @s hotbar.* with minecraft:torch 64用一组64x火把填满你快捷栏的每个栏位。
/item replace entity @s armor.head from entity @s weapon.mainhand将你手持物品的副本戴到你的头上。
/item override block ~ ~-1 ~ container.* from entity @s hotbar.*将你的快捷栏复制到脚下的容器中,并清空其余槽位。



