I am trying to use the command:

/testfor @a {SelectedItem:minecraft:fire_charge,display:{Name:"Fireball"},ench:[{id:60,lvl:10}]}

In a command block it always ends up saying player did not match the required data structure. This is making me so angry not knowing what I'm doing wrong.

In order to obtain the fire charge I use the command:

/give @p minecraft:fire_charge 1 0 {display:{Name:"Fireball"},ench:[{id:60,lvl:10}]}

This one always works and gives me the correct item. It just can't find when I have it as a selected item in my hotbar (item in my hand so it can be used).

Please help me out. Thank you for taking your time to help (in advance).

1 Answer 1


The SelectedItem tag is a compound, which surrounds data in curly brackets. You've declared it as a string instead with the remainder of the item data at the root of the player entity data.

You need to place the item data inside, along with the id tag. As well, the item format dictates that all data that is not the root id, Damage, Slot, or Count, must be placed within a single tag compound.

On top of that, be aware that most extra item data will not be auto-corrected for datatypes. You've declared the enchantment's id and lvl tags tags as integers, but when the enchantments are obtained through normal means these tags will be shorts. You would end up needing multiple commands to check for the varied datatypes if you do not declare it as a short as well (which is done by appending a whole numerical value with an "s").

Revised /give command:

/give @p minecraft:fire_charge 1 0 {display:{Name:"Fireball"},ench:[{id:60s,lvl:10s}]}

Resulting /testfor command (if not for example, I recommend not relying on /testfor and instead use multi-target friendly methods such as adding labels with /scoreboard):

/testfor @a {SelectedItem:{id:"minecraft:fire_charge",tag:{display:{Name:"Fireball"},ench:[{id:60s,lvl:10s}]}}}

To make detection easier, you can use custom item data instead of trying to detect every single tag on the item. This way you can change the actual data for balancing purposes without having to go back to fix all commands relying on that data.

For example, the following adds a "specialFireCharge" byte tag with a value of 1 to the item:

/give @p minecraft:fire_charge 1 0 {specialFireCharge:1b,display:{Name:"Fireball"},ench:[{id:60s,lvl:10s}]}

And the following would be what you'd use to label the player as a result:

/scoreboard players tag @a[tag=HoldingCharge] remove HoldingCharge
/scoreboard players tag @a[tag=!HoldingCharge] add HoldingCharge {SelectedItem:{tag:{specialFireCharge:1b}}}
  • Thank you for helping me out, I will try the /scoreboard method out thanks. Apr 8, 2016 at 4:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .