Detect items in a chest using command blocks

Detect items in a chest using command blocks - Assorted-color Bricks

I'm trying to detect a chest with coal blocks and I entered in:

/testforblock -673 57 -195 chest 2 {Items:[{id:173s,Damage:0s,Slot:1b,Count:1b}]}

But below that it says:

-673,57,-195 did not have the required NBT keys

I'm running Minecraft 1.8.



Best Answer

Item IDs are saved in 1.8+ as strings containing the name IDs. You should not be using numerical IDs anymore.

/testforblock -673 57 -195 chest 2 {Items:[{id:"minecraft:coal_block",Damage:0s,Slot:1b,Count:1b}]}



Pictures about "Detect items in a chest using command blocks"

Detect items in a chest using command blocks - Crop hacker silhouette typing on computer keyboard while hacking system
Detect items in a chest using command blocks - From above of crop anonymous male hacker typing on netbook with data on screen while sitting at desk
Detect items in a chest using command blocks - From below of ethnic boy in hoodie controlling robot using panel while standing in light room



How do you find items in a chest in Minecraft?

Item IDs can be found by pressing F3 and H at the same time (which reveals advanced tooltips) and hovering over the item in your inventory. An emerald, for example, would be "minecraft:emerald".

How do you find items with command blocks?

How to Enter the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.


  • How do you Testfor with command blocks?

    detectPos is the x y z coordinate to detect the block. command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.



    how to detect item in a chest! I minecraft chest detection tutorial 1.16.5!




    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Sharon McCutcheon, Anete Lusina, Sora Shimazaki, Vanessa Loring