PT-BR EN
Channel Icon

Crazy Ozz

Official Channel Website

Command Block

How to Detect Items on the Ground in Minecraft

Version 1.21+ Java Edition

Do you want to detect the item by ID, name, or tag? This applies to all cases. Let's start by detecting it by ID only:

execute if entity @e[type=item,nbt={Item:{id:"minecraft:diamond"}}] run

The command above detects any diamond item on the ground and works with any entity. After run, you can choose the command to execute. The same logic applies to the next commands.

Now let’s detect it by tag:

execute if entity @e[type=item,nbt={Item:{components:{"minecraft:custom_data":{Teste:1b}}}}] run

By name:

execute if entity @e[type=item,nbt={Item:{components:{"minecraft:custom_name":"Testando"}}}] run

And we can also combine all of them like this:

execute if entity @e[type=item,nbt={Item:{components:{"minecraft:custom_data":{Teste:1b},"minecraft:custom_name":"Testando"},id:"minecraft:diamond"}}] run

This way, we can detect a diamond item in a very specific way.

Still have questions? Watch the video below