Minecraft Commands – How to Test for a Specific Item with a Unique Name in a Chest

minecraft-commandsminecraft-java-edition

I have looked at several questions that are close, but I still cannot get this. One question talks about checking a chest for any item, but I need to test for a specific item with a unique name.

I'm creating a quest. The player needs to bring back an Apple with the name "InnKeeper Apple".

I have tried this, but it is not working.

/testforblock 7652 62 744 minecraft:chest -1 {Item:{id:minecraft:apple,tag:{display:{Lore:["InnKeeper Apple"]}}}}

Any ideas?

Best Answer

Chests use an Items list to store their items. Lists surround their data with square brackets, and the data stored in this case are compounds (which surrounds data with curly brackets).

/testforblock 7652 62 744 minecraft:chest -1 {Items:[{id:minecraft:apple,tag:{display:{Lore:["InnKeeper Apple"]}}}]}