Minecraft – How to test for a dropped item in Minecraft

minecraft-java-edition

I want to test for a dropped Spruce Log, for example. So what I have is:

execute at @e[type=minecraft:item,name="spruce_log"] run summon minecraft:pig ~ ~ ~

I also tried:

execute at @e[type=minecraft:item,nbt={id:"spruce_log"}] run summon minecraft:pig ~ ~ ~

The pig summoning is just to see if it works. Which it doesn't. The Command Block doesn't give me any errors either. I just don't know how to test for the Spruce Log item, or any item in specific. I'm using Minecraft 1.13.1.

Best Answer

You'll want to do this:

/execute at @e[type=item,nbt={Item:{id:"minecraft:spruce_log"}}] run summon minecraft:pig ~ ~ ~