Minecraft Test If A Chest Contains An Item

I’ve seen a lot of questions for finding specific items in chests using commands using testforblock but how would you test if any block/item has been placed in a chest?

Thanks

  • How do I make the comparator work and then stop?
  • How do I get to The Nether in Minecraft?
  • Craftbook Collect: Sort enchanted Books/Items
  • How do friends come to my ftb server?
  • How do you make bows set things on fire?
  • What's the maximum number of powered rails in a row that's useful?
  • In Minecraft how do I randomise the output in a redstone circuit?
  • How would I make something spawn when and where a snowball hits something?
  • How do I progress in Ars Magica 2?
  • Minecraft crashes on launch with EXCEPTION_ACCESS_VIOLATION, Problematic frame: ig4dev32.dll or ig4dev64.dll or ig4icd32.dll or ig4icd64.dll
  • How do you find your home bed?
  • How to make custom player heads without making multiple accounts?
  • One Solution collect form web for “Minecraft Test If A Chest Contains An Item”

    You can use

    /testforblock x y z minecraft:chest -1 {Items:[{}]}
    

    Note the extra {} in the Items list. {Items:[{}]} checks if the list of item tags contains an item that matches all the tags present in {}. Obviously, {} does not contain any tags, meaning every item in the game matches this1.

    You can achieve the opposite behavior using {Items:[]}, which will test for an empty list of items.

    1 Technically, everything matches {}, including Creepers, but the Items tag limits the scope for us.

    We love Playing Games, especially Video Games.