In Java Edition, I can test for a dropped item on the floor by using NBT:
/execute if entity @e[type=item,nbt={Item:{id:"minecraft:green_wool"}}]
But in Bedrock Edition, NBT is inaccessible from commands. Is there still a way to test for a dropped item on the ground?
What about testing for a named item drop?
This would allow you to run certain commands when a specific item is dropped, for example, if the player drops a compass they could be teleported to the spawn of your world, or have a message shown to them.
See also: Detecting items in the player's inventory
Browse more workarounds for getting/setting NBT in Bedrock Edition
Best Answer
Commands
This command will activate when a ghast tear is dropped.
This command runs when a Lime Wool is dropped.
If you name an item “Spooky Pumpkin” and drop it, this runs.
Notes
This is still compatible with the color formatting codes (
§
), so don’t worry!If your item name does not contain spaces and consists only of the characters in the following line, you may type the name directly, without having to include the quotation marks:
If your name contains a character not in this list, you will need to surround your name with quotation marks
"
, like in the above examples. To include a quotation mark as part of the name, escape them with a\
:Limitations
/testfor
of this may not reflect the number of dropped items, because when two items with the same properties are dropped next to each other, they like to group up into a single entity representing a stack of one or more items.