HHZJ
本帖最后由 HHZJ 于 2021-7-2 11:35 编辑

/execute as @a[limit=1] if data entity @s SelectedItem.tag.Tags run effect give @s minecraft:speed 1 1 true
其中"SelectedItem.tag.Tags"结尾的"Tags"或者"Name"


问题:怎么指定自定义的Tags或者Name(或者能否指定自定义文字)?

已知/execute as @a[limit=1] if data entity @s SelectedItem.tag.Tags[0] run effect give @s minecraft:speed 1 1 true 能正常检测并执行

例如
手持一张纸,NBT如下:
Tags:["123"]
Name:[{\"text\":\"123\"}]


使用以下指令检测 (指令无法使用,提示需要整型)
/execute as @a[limit=1] if data entity @s SelectedItem.tag.Tags:["123 run effect give @s minecraft:speed 1 1 true
/execute as @a[limit=1] if data entity @s SelectedItem.tag.display.Name:[{\"text\":\"123\"}] run effect give @s minecraft:speed 1 1 true





2021.12 数据,可能有更多内容/execute as @a[limit=1] if data entity @s SelectedItem.tag.Tags run effect give @s minecraft:speed 1 1 true
其中"SelectedItem.tag.Tags"结尾的"Tags"或者"Name"

问题:怎么指定自定义的Tags或者Name(或者能否指定自定义文字)?

已知/execute as @a[limit=1] if data entity @s SelectedItem.tag.Tags[0] run effect give @s minecraft:speed 1 1 true 能正常检测并执行


例如
手持一张纸,NBT如下:
Tags:["123"]
Name:[{\"text\":\"123\"}]



使用以下指令检测 (指令无法使用,提示需要整型)
/execute as @a[limit=1] if data entity @s SelectedItem.tag.Tags:["123 run effect give @s minecraft:speed 1 1 true
/execute as @a[limit=1] if data entity @s SelectedItem.tag.display.Name:[{\"text\":\"123\"}] run effect give @s minecraft:speed 1 1 true



enderman_JC
检测手持可以用nbt,举个例子
/execute as 玩家名 if data entity @s {SelectedItem:{id:"物品ID"}}

晴路卡
本帖最后由 晴路卡 于 2021-7-2 12:24 编辑
  1. /execute if data entity @s {SelectedItem:{tag:{display:{Name:'[{"text":"123"}]'}}}}
复制代码
     有能力的话最好别用这些生成器,你也看到了实际给的物品会和生成器给的命令中有出入,比如命令中你输入的Name:"[{\"text\":\"123\"}]"最终无论如何也会被拍成单引号的格式。
      另外开一个Tags来存自定义NBT也很蠢,你可以这样给自己带自定义NBT的物品:
  1. /give @s minecraft:paper{123:1b}
复制代码
然后通过输入
  1. /execute if data entity @s {SelectedItem:{tag:{123:1b}}}
复制代码
来检测的。

第一页 上一页 下一页 最后一页