跳转到内容
WikilyWIKILY
全部游戏23 个 Wiki · 选择你的游戏
命令与作弊所有命令

切换游戏

23 个 Wiki · 选择你的游戏
物品组件

命令参考

物品组件

命令中的物品写作一个 id,后面跟方括号中的组件。组件保存物品的所有特殊之处,例如名称、附魔和耐久。

详细信息

物品语法id[component=value,component=value].ID和组件名称中的 minecraft: 部分可以省略。
移除组件在没有值的名称前加!可移除该组件,例如minecraft:diamond_sword[!attribute_modifiers]。
重复每个物品上每种组件只能出现一次。
值以数据格式书写:数字、带引号的文本、[ ] 中的列表和 { } 中的命名值。
组件类型119个可在命令中使用。
物品测试由/clear和/execute if items使用。以物品id、带#的物品标签或代表任意物品的*开头,然后是[ ]中的可选测试。
组合测试逗号表示两个测试都必须通过,|表示任意一个通过即可,测试前的!表示取反。
精确测试component=value 在物品恰好具有该值时通过。
部分测试name~value检查组件的一部分。适用于attribute_modifiers、bundle_contents、container、custom_data、damage、enchantments、firework_explosion、fireworks、jukebox_playable、potion_contents、stored_enchantments、trim、villager/variant、writable_book_content和written_book_content。
数量检测count=5 表示精确的堆叠数量,count~{min:..,max:..} 表示范围。
花括号中的数据仍然适用的位置实体与方块数据:/summon、/data、nbt 选择器参数,以及方块 ID 之后的方块数据。

常用组件

enchantments物品上的附魔及其等级/give @s minecraft:diamond_sword[enchantments={sharpness:5,unbreaking:3}]
stored_enchantments附魔书所含的附魔/give @s minecraft:enchanted_book[stored_enchantments={mending:1}]
custom_name物品显示的名称,为文本组件/give @s minecraft:stick[custom_name={text:"Magic Wand",color:"gold",italic:false}]
item_name物品的基础名称,以文本组件表示/give @s minecraft:stick[item_name="Wand"]
lore额外的提示框行,一个文本组件列表/give @s minecraft:stick[lore=["First line",{text:"Second line",color:"gray"}]]
damage已消耗的耐久/give @s minecraft:diamond_pickaxe[damage=100]
max_damage总耐久度/give @s minecraft:diamond_pickaxe[max_damage=5000]
unbreakable物品永不损失耐久度/give @s minecraft:diamond_pickaxe[unbreakable={}]
max_stack_size最大堆叠数,1至99/give @s minecraft:ender_pearl[max_stack_size=64]
attribute_modifiers物品在栏位中时的属性变化/give @s minecraft:stick[attribute_modifiers=[{type:"minecraft:attack_damage",amount:10,id:"example:bonus",operation:"add_value",slot:"mainhand"}]]
potion_contents药水的类型、颜色和自定义效果/give @s minecraft:potion[potion_contents={custom_color:16711680,custom_effects:[{id:"minecraft:speed",amplifier:1,duration:600}]}]
dyed_color染料颜色,一个数或[red,green,blue],范围从0到1/give @s minecraft:leather_chestplate[dyed_color=16711680]
fireworks烟花火箭的飞行时间和爆炸/give @s minecraft:firework_rocket[fireworks={flight_duration:2,explosions:[{shape:"large_ball",colors:[I;16711680],fade_colors:[I;255],has_trail:true,has_twinkle:true}]}]
firework_explosion烟火之星的爆炸/give @s minecraft:firework_star[firework_explosion={shape:"star",colors:[I;65280]}]
written_book_content成书的标题、作者和页面/give @s minecraft:written_book[written_book_content={title:"Guide",author:"Steve",pages:["Page one",{text:"Page two",bold:true}]}]
writable_book_content书与笔的页面/give @s minecraft:writable_book[writable_book_content={pages:["Notes"]}]
food进食时恢复的饥饿和饱和度/give @s minecraft:stick[food={nutrition:4,saturation:2.4,can_always_eat:true},consumable={}]
consumable使物品可以通过食用或饮用来使用/give @s minecraft:stick[consumable={consume_seconds:0.8,animation:"eat"}]
tooltip_display隐藏工具提示或其中的单个组件/give @s minecraft:diamond_sword[enchantments={sharpness:5},tooltip_display={hidden_components:["minecraft:enchantments"]}]
enchantment_glint_override强制开启或关闭附魔光效/give @s minecraft:stick[enchantment_glint_override=true]
rarity名称颜色类别:common、uncommon、rare 或 epic/give @s minecraft:stick[rarity="epic"]
custom_data供数据包使用的自由数据/give @s minecraft:stick[custom_data={quest_item:1b}]
custom_model_data资源包用来选择模型的值/give @s minecraft:stick[custom_model_data={floats:[1.0f],strings:["wand"]}]
item_model用于绘制物品的模型/give @s minecraft:stick[item_model="minecraft:blaze_rod"]
can_break在冒险模式下该物品可破坏的方块/give @s minecraft:diamond_pickaxe[can_break={blocks:"#minecraft:logs"}]
can_place_on在冒险模式下可放置该物品的方块/give @s minecraft:stone[can_place_on={blocks:"minecraft:grass_block"}]
container存放在容器物品内的物品/give @s minecraft:chest[container=[{slot:0,item:{id:"minecraft:diamond",count:3}}]]
bundle_contents收纳袋内的物品/give @s minecraft:bundle[bundle_contents=[{id:"minecraft:arrow",count:16}]]
profile玩家头颅显示其皮肤的玩家/give @s minecraft:player_head[profile={name:"Notch"}]
trim盔甲纹饰材料与图案/give @s minecraft:iron_chestplate[trim={material:"minecraft:gold",pattern:"minecraft:coast"}]
equippable允许将物品穿戴在某个栏位/give @s minecraft:stick[equippable={slot:"head"}]
use_cooldown使用后的等待时间(秒)/give @s minecraft:ender_pearl[use_cooldown={seconds:5}]
repair_cost额外的铁砧花费(等级)/give @s minecraft:diamond_sword[repair_cost=10]
block_entity_data放置方块时应用的方块数据/give @s minecraft:spawner[block_entity_data={id:"minecraft:mob_spawner",Delay:20s}]
entity_data物品生成实体时应用的实体数据/give @s minecraft:armor_stand[entity_data={id:"minecraft:armor_stand",Small:1b}]

物品测试

id该物品/clear @s minecraft:diamond
#tag标签中的任意物品/clear @s #minecraft:planks
*任意物品/clear @s *
[component]有该组件的物品/clear @s *[damage]
[!component]没有该组件的物品/clear @s *[!damage]
[component=value]组件恰好等于该值的物品/clear @s minecraft:diamond_sword[damage=0]
[name~value]通过部分测试的物品/clear @s *[enchantments~[{enchantments:"minecraft:sharpness",levels:{min:3}}]]
[count=n]恰好为该大小的物品堆/clear @s minecraft:stick[count=5]
[count~{min:n}]大小在某个范围内的物品堆/clear @s *[count~{min:32}]
[a|b]通过其中一项测试的物品/clear @s *[damage|unbreakable]
[a,b]通过两项测试的物品/clear @s #minecraft:swords[enchantments~[{}],!custom_name]

数据值类型

字节带 b 的整数1b
简短带 s 的整数20s
整数整数,或带 i5
long带 L 的整数4L
浮点数带 f 的数字5.5f
双精度浮点数带小数点的数字,或带 d 的数字6.5d
真或假true或false,存储为1b或0btrue
文本用双引号或单引号括起。简单的词不需要引号“Steve”
列表[ ]中以逗号分隔的值[1,2,3]
命名值{ }中的key:value对{id:"minecraft:diamond",count:3}
字节列表[B; ...][B;1b,2b]
整数列表[I; ...][I;1,2]
long 列表[L; ...][L;1L,2L]
十六进制或二进制数前面带0x或0b0x1F
未签名或已签名类型字母前的u或s255ub
数位分组数字之间的下划线1_000
bool(...)将数字转换为真或假bool(1)
uuid(...)将UUID文本转换为其存储形式uuid("dd12be42-52a9-4a91-a8a1-11c01849e498")

花括号中的数据的使用位置

召唤时的实体数据/summon minecraft:pig ~ ~ ~ {NoAI:1b}
更改实体数据/data merge entity @n[type=minecraft:zombie] {NoAI:1b,CustomName:"Bob"}
通过数据路径读取/data get entity @s Inventory[{id:"minecraft:diamond"}].count
数据路径中的组件/data get entity @s SelectedItem.components."minecraft:damage"
方块数据/data get block ~ ~ ~ Items[0]
命令存储/data modify storage my_pack:data name set value "Steve"
选择器过滤器/kill @e[type=minecraft:zombie,nbt={NoAI:1b}]

示例

/give @s minecraft:diamond_sword[custom_name={text:"Excalibur",color:"gold",italic:false},enchantments={sharpness:5},unbreakable={}]

给予一把带锋利 V、金色名称的无法破坏的剑。

/give @s minecraft:diamond_sword[!attribute_modifiers]

给予一把没有攻击伤害和攻击速度加成的钻石剑。

/give @s minecraft:potion[potion_contents={potion:"minecraft:strong_healing"}]

给予:治疗药水 II。

/item replace entity @s weapon.mainhand with minecraft:diamond_sword[enchantments={sharpness:5}]

在你的主手放入一把带有锋利V的钻石剑。

/clear @s *[damage~{durability:{max:10}}]

移除耐久度剩余10或更少的所有物品。

/execute if items entity @s weapon.mainhand minecraft:diamond_sword run say yes

如果你手持钻石剑,就会说出yes。

/execute if items entity @s container.* *[custom_data~{key:1b}] run say yes

如果任何物品栏格子中的物品,其自定义数据中key被设为1b,就会说出yes。

/data merge storage my_pack:data {a:1,b:2b,c:3s,d:4L,e:5.5f,f:6.5d,g:"text",h:[1,2,3],i:[B;1b,2b],j:[I;1,2],k:[L;1L,2L],l:{m:true}}

存储每种数据类型的一个值。

加入创作者社区建设 Minecraft Java Edition Wiki 的伙伴们都在我们的 Discord。欢迎提问或推荐页面。加入 Discord (在新标签页打开 Discord)