I've been watching video tutorials for using command blocks and browsed a bit on here before forming this question.

I've been trying to make a shop where a player puts a few emeralds, let's say 8, in a chest and they receive something, let's say an obsidian block. After a good amount of experimenting, the command that has come close to my solution is:

execute if block ~ ~ ~ chest{Items:[{id:"minecraft:emerald", count:8b}]}

I also used the variation: execute unless block...

I have a button to press it but it only registers the chest; regardless of whatever is inside of it (even executing if the chest is empty). I'm on 1.16, so I don't think the "/testforblock" command (as seen in other questions) works. Is there something I'm missing?

  • 1
    Hey, next time when you want to put specific text in a line in code formatting, you can select the text and press the brackets icon found in the editor. When you want to put a specific line in code formatting, you can add 4 spaces at the beginning of the line or, again, select the entire line and press the brackets icon found in the editor (does the same thing).
    – ahmettrPro
    Jul 20, 2020 at 22:04
  • Oh, thank you lol I just made this account today so I didn't know how that worked. Will do that next time.
    – tegopole
    Jul 21, 2020 at 1:14

1 Answer 1


So I tried this in 1.16.5 and the only thing I changed was the c in count to uppercase:

execute if block ~ ~ ~ minecraft:chest{Items:[{id:"minecraft:emerald", Count:8b}]} run say hi

That works perfectly for me.

You must log in to answer this question.

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