Minecraft Java Edition Commands – How to Detect If Nothing Is in an Item Frame?

minecraft-commandsminecraft-java-edition

I want to know, if it's possible, how I would go about detecting if an item frame has nothing in it. I've looked online a lot and haven't found anything yet. I would say what I've got so far, but I don't really know where to start. I have

/testfor @e[type=item_frame] {TileX:4,TileY:101,TileZ:37,{id:}}

but I don't know where to go or what to do from here.

Best Answer

You can tag all item frames that have an item in them, then test if any don't have that tag:

/scoreboard players tag @e[type=item_frame] add HasItem {Item:{}}
/testfor @e[type=item_frame,tag=!HasItem]