3

I want to test if a player has the following item:

minecraft:bow 1 0 {display:{Name:Bow I},ench:[{id:48,lvl:1}]}

A bow with a name of "Bow 1" and has a Power I enchantment.

I know this command works with normal items:

/testfor @p {Inventory:[{id:"minecraft:bow"}]}

I don't know how to add the attributes. Is it possible to search for a specific item name? For example, test to see if I have the item "Bow I" in my inventory?

4
  • Half the answer is here: hypixel.net/threads/testfor-snowball-with-custom-name.71759 Commented Jan 9, 2015 at 16:58
  • 1
    Possible duplicate of Command for spawning chest with a CanPlaceOn tag
    – pppery
    Commented May 18, 2020 at 0:44
  • @pppery The linked question, under no circumstances, could be considered a proper duplicate target. They are asking completely different questions that happen to be slightly related.
    – MBraedley
    Commented May 19, 2020 at 11:06
  • No, both questions are asking how to include NBT for an item within a broader NBT tag. This user clearly knows how to give the player an item with a custom name (they even specirfy it in the question), and is asking how to test for an item with known NBT. If that isn't good enough, this is unambiguously a duplicate of How to test for specific potions in inventories, which was closed as a duplicate of my suggested target in December.
    – pppery
    Commented May 19, 2020 at 12:57

1 Answer 1

3

You have to nest additional data tags in tag compound:

/testfor @p {Inventory:[{id:"minecraft:bow",tag:{display:{Name:"Bow I"},ench:[{id:48,lvl:1}]}}]}

Learn more about item format here.

1
  • ahh ty, that worked ^^
    – Wilmz
    Commented Jan 9, 2015 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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