I don't think this has been asked, if it is, I'm sorry.
I've done some looking, and I can't figure out how to add tags to items. I've tried this: /give @p shield{display:{Name:'[{"text":"Custom Shield","italic":false,"color":"dark_red","bold":true}]',Lore:['[{"text":"Force Field","italic":false,"color":"#ff6600"}]','[{"text":"Saftey","italic":false,"color":"#ff6600"}]'],forcefield:1b}} 1
as well as /give @p shield{display:{Name:'[{"text":"Custom Shield","italic":false,"color":"dark_red","bold":true}]',Lore:['[{"text":"Force Field","italic":false,"color":"#ff6600"}]','[{"text":"Saftey","italic":false,"color":"#ff6600"}]'],tag:[forcefield]}} 1
.
I'm not sure what I did wrong, but I also can't detect the tags. I've tried detection like this: execute as @a[scores={souls=1..},nbt={Inventory:[{Slot:-106b,id:"minecraft:shield",forcefield:1b}]}] run function kits:forcefieldenchant
as well as like this:execute as @a[scores={souls=1..},nbt={Inventory:[{Slot:-106b,id:"minecraft:shield",tag:["forcefield"]}]}] run function kits:forcefieldenchant
I'm not sure where I went wrong, but any help would be very much appreciated. Thanks in advance!
Best Answer
In order for testing for NBT to work, the NBT you provide in the command has to match the NBT Minecraft stores for the player exactly, or the command will not work. The first command does not work because data tags for NBT need to go in a tag called
tag
and you setforceField:1b
inside thedisplay
tag and test for it outside the display tag. Fixing those two errors produces the command: