Minecraft – How to see if a chest been emptied by the player

minecraft-commandsminecraft-java-edition

I would like to make a command that checks if a chest have been emptied by the player. If the chest is empty, I want to run this command:

/setblock x y z 

Best Answer

When you test for an empty list (e.g. Items:[]), it will only match if the target had an empty list as well.

The following only outputs if the chest had no items:

/testforblock ~ ~1 ~ minecraft:chest -1 {Items:[]}