1

This question already has an answer here:

I'm trying to make a kit pvp map in vanilla Minecraft, but I ran into a problem. I want specific people to get a certain effect. So I got a /testfor command:

/testfor @a{SelectedItemSlot:0,Inventory:[{Slot:0b,tag:{display:{Name:"Fire Wand"}}}]}

This command tests if any person has this specified item name in slot 0. It then turns on a comparator which activates the second command once it finds that person:

/execute @p ~ ~ ~ summon Fireball ~2 ~1 ~ {ExplosivePower:10,direction:[0.0,0.0,0.0]}

How can I specify this command to the person holding the named item?

So Skylinerw suggested this command which seems to solve all my problems!

You have to use a command to apply a label to the player based on their data rather than using /testfor. For example, /scoreboard can assign a label:

/scoreboard players tag @a[tag=HasItem] remove HasItem
/scoreboard players tag @a[tag=!HasItem] add HasItem {SelectedItemSlot:0,Inventory:[{Slot:0b,tag:{display:{Name:"Fire Wand"}}}]}

And you'd then target players based on their label. The correct tag for fireball damage is ExplosionPower:

/execute @a[tag=HasItem] ~ ~ ~ /summon Fireball ~2 ~1 ~ {ExplosionPower:10,direction:[0.0,0.0,0.0]}

I thought this is really cool! But how does the scoreboard command activate the execute command? Is it with a comparator? Do both command blocks have to be on a clock?

marked as duplicate by MrLemon, Adam Lobo, Studoku, Ave, nine Mar 3 '16 at 16:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This is a clarification request to a specific answer to a question and should be a comment on said answer. – MrLemon Mar 3 '16 at 12:31
0

You're right. Both commands must be on a clock.

Not the answer you're looking for? Browse other questions tagged or ask your own question.