How do I apply potion effects to a player wearing armor with a special name with command blocks

How do I apply potion effects to a player wearing armor with a special name with command blocks - Woman Wearing a Gray Sports Bra Holding a Yoga Mat and Blocks

I am making special classes for my server, and I want to give someone underwater breathing whenever they are wearing a helmet named scuba. How do I do this with command blocks?



Best Answer

What you could do is /testfor a player with a helmet with a custom name scuba. Test for the slot number they have it in, (helmets are 103) This command should do all that:

/testfor @p[r=2] {Inventory:[{Slot:103b,tag:{display:{Name:"scuba"}}}]}

Hook it up to a clock of your choice and if the /testfor command reads true then have a comparator ready to activate a sticky piston that pushes a redstone block to activate the command

/effect @p minecraft:water_breathing

When they leave your set radius or remove there helmet the sticky piston will deactivate pulling the redstone block activating the command

/effect @p clear

enter image description here This is a list of the inventory slot numbers.

enter image description here

The Youtuber Dragnoz also has a great video on how to do things like this.




Pictures about "How do I apply potion effects to a player wearing armor with a special name with command blocks"

How do I apply potion effects to a player wearing armor with a special name with command blocks - A Woman Smiling and Holding Tennis Racket
How do I apply potion effects to a player wearing armor with a special name with command blocks - A Woman in White Shirt Holding a Tennis Racket
How do I apply potion effects to a player wearing armor with a special name with command blocks - Man in Blue Long Sleeves Playing Golf in Fairway



How do you put potion effects on armor?

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: Pavel Danilyuk, Artem Podrez, Artem Podrez, Martin Magnemyr