How to make an armor that gives you potion effects?

How to make an armor that gives you potion effects? - Pink color neon luminous text with inspiring phrase You are flowers on the road on black signage at night

I'm confused about the tag part of the command, I don't know what tag my item has. The item has been renamed.

This is the command I'm using:

execute as @a if entity @s  
[nbt={Inventory:[{Slot:102b,id:"minecraft:leather_tunic",  
tag:{Tags:["**I do not know what the tag is**"],  
display:{Name:"{\"text\":\"Stealth Chestplate\"}"}}}]}]  
run effect give @s minecraft:invisibility 1 1


Best Answer

Using the stuff I found here, I figured out how to do this.

First, you need the item with the appropriate tag.

give @s chainmail_chestplate{tag:{Tags:[sneaky]}}

How tags work in datapacks is they allow commands to locate and isolate items from other items. Datapacks cannot add new content, only modify to make it appear to be differing from it's parent item. All your other NBT data (renaming, lore, enchantments, etc) still work with tags. They are just more reliable when it comes to locating where an item is and who has it.

Now that you have the item with the appropriate tag, we can now detect and execute.

execute as @e[nbt={Inventory:[{id:"minecraft:chainmail_chestplate", tag:{Tags:[sneaky]}, Slot: 102b}]}] run **The effect command with desired effect**

I used the @e target selector so you can use this item on zombies, skeletons, etc. But if this is a player-only item you should change the selector to @a.




Pictures about "How to make an armor that gives you potion effects?"

How to make an armor that gives you potion effects? - An Old Book and Candles on Wooden Table with Glass Bottles
How to make an armor that gives you potion effects? - Graceful young female alchemist with knife in hand in black outfit preparing potion from various herbs among smoke in dark room
How to make an armor that gives you potion effects? - Content female customer with long curly hair wearing casual outfit sitting at wooden table with netbook in classic interior restaurant while making online order



How do I make an item that gives potion effects when held?

ArmorStands can still have potion effects, however potion affects from thrown splash potions or lingering potions are not applied to them (see searge's comment).



Minecraft 1.16+: How to add POTION EFFECTS to Armor! (With command blocks)




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ryutaro Tsukata, RODNAE Productions, murat esibatir, Yan Krukov