How do i test for a item with a name in a players inventory? Like an identity card for each player that has to verify correctly to open the doors.

1 Answer 1


The following will test for a piece of paper renamed to "Card" in the player's inventory:

/testfor @a {Inventory:[{id:"minecraft:paper",tag:{display:{Name:"Card"}}}]}

If you want to keep track of who has the card (to select them later), you can give players with the card a tag based on the NBT test:

/scoreboard players tag @a remove HasCard
/scoreboard players tag @a add HasCard {Inventory:[{id:"minecraft:paper",tag:{display:{Name:"Card"}}}]}

Running the above commands on a clock in that order will allow you to select people with the card with @a[tag=HasCard].

You can read about the NBT format for players and items on this wiki page:

You must log in to answer this question.

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