0

Basically, I need to make a testifier commands that checks for players to hold Blue or Red wool in the hand. To do this I've tried the following:

/testfor @a[team=Blue] {SelectedItem:{id:minecraft:wool}}

(it says that the UUID is in invalid format, but the team specification is not necessary so I removed it)

/testfor @a {SelectedItem:{id:minecraft:wool}

(It seems it only works with white wool)

/testfor @a {SelectedItem:{id:minecraft:wool 14}

Still not working and

/testfor @a {SelectedItem:{id:minecraft:wool,Data:14}}

But still not recognizing it as red wool... I just can't understand how and where I put the block variation Data...

marked as duplicate by Unionhawk, GodEmperorDune, Robotnik, user106385, Ben Sep 4 '15 at 5:31

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.

  • Also, is there a specific reason you're using testfor instead of a scoreboard objective? The utility of testfor is incredibly limited, and only gains a marginal amount of usefulness in the 1.9 snapshots. – MBraedley Sep 4 '15 at 1:01
2

Your last attempt was close, but the tag that stores an item's data value is called Damage, and is a short (needs an "s" suffix when testing) rather than integer. Your command should look like this:

/testfor @a {SelectedItem:{id:minecraft:wool,Damage:14s}}

The Minecraft wiki has a good page on NBT data, which is a lot easier than just trying to guess the tags.

  • Thanks, it works! Even if "damage" doesn't make much sense, it's misleading. – Lionitow Sep 3 '15 at 20:46
  • Its damage because meatadata is meant to be used as durability aka. damage. – ModDL Sep 3 '15 at 21:10
  • @Lionitow The metadata is often known as the "damage value", as it was originally made to store the damage of tools. Some tags a pretty arbitrary and inconsistent though, which is why I recommend against trying to guess them. – SirBenet Sep 4 '15 at 16:21

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