How do I get armor to add a potion effect?

Is it possible to get a specific piece of armor to add a specific potion effect when worn? Would I be able to make a pair of boots give the jump boost potion effect when worn? Furthermore, am I able to make ONLY that specific pair of boots get that effect? For instance, if you were to kill something and take its diamond boots, they wouldn't have the same effect as the diamond boots that you had with the effect?


You can do this using a scoreboard objective and Data Tags.

To check for worn items, you will need to look at {Inventory:[{Slot:Xb,...}]}, where X is the appropriate slot, as follows: Helmet: 103, Chestplate: 102, Leggings: 101, Boots: 100. Replace the ellipsis with the items data tag, such as id:minecraft_diamond_boots or tag:{display:{Name:"Bob"}} (More info can be found at the wiki article on item structure).

Here's an example with jumping boots called "Rocket Boots", for both 1.9 and 1.8:

1.9

Set up a repeat/chain command block line and run

/scoreboard players tag @a[tag=jumpBoots] remove jumpBoots
/scoreboard players tag @a[tag=!jumpBoots] add jumpBoots {Inventory:[{Slot:100b,tag:{display:{Name:"Rocket Boots"}}}]}
/effect @a[tag=jumpBoots] minecraft:jump_boost 1 2 true

This will add the "jumpBoots" tag to everyone wearing "Rocket Boots". Every player with this tag gets a jump boost effect for 1 second, with magnitude 2 and without swirley particle effects.

1.8

For 1.8, you need to set up a scoreboard objective first:

/scoreboard objective add jumpBoots

You only have to do this once. Now put a some command blocks on a setblock/fill clock, and execute, in this order:

/scoreboard players set @a jumpBoots 0
/scoreboard players set @a jumpBoots 1 {Inventory:[{Slot:100b,tag:{display:{Name:"Rocket Boots"}}}]}
/effect @a[score_jumpBoots_min=1] minecraft:jump_boost 1 2 true

Since tags don't exist in 1.8, we use a scoreboard that is set to 0 or 1 depending on whether or not a player is wearing the boots.