I need help specifying a testfor command!

As of right now the command is /testfor @e[type=Item,r=4] {Item:{id:minecraft:anvil}}

How can I test this anvil for a damage, enchant, or name tag?

  • 2
    What version of Minecraft are you using?
    – Jason_
    Mar 27 '16 at 3:58
  • There's 3 variations of anvil; Anvil, Damaged_anvil, very_damaged_anvil use these tags Mar 27 '16 at 4:05
  • No it does not seem to work can u plz rewrite the command but with the tag included?
    – JP2K
    Mar 27 '16 at 5:05

To testfor the Item's damage, use the "Damage" tag.

/testfor @e[type=Item,r=4] {Item:{id:"minecraft:anvil",Damage:0s}}

To test for a custom name, you can use the "tag" tag. With this tag you can define NBT tags for non-entity items. (Items in a player's inventory) In this case, you need the "display" tag

/testfor @e[type=Item,r=4] {Item:{id:"minecraft:anvil",Damage:0s,tag:{display:{Name:"Custom Name Here"}}}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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