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?
1 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
This is a list of the inventory slot numbers.
The Youtuber Dragnoz also has a great video on how to do things like this.