TransWikia.com

Can you tell if a specific item is dropped? What about its name?

Arqade Asked on January 14, 2021

.

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.


Browse more workarounds for getting/setting NBT in Bedrock Edition

One Answer

Commands

/testfor @e[type=item,name="Ghast Tear"]

This command will activate when a ghast tear is dropped.

/kill @e[type=item,name="Lime Wool"]

This command runs when a Lime Wool is dropped.

/testfor @e[type=item,name="Spooky Pumpkin"]

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:

    +-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
    

    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 :

    /testfor @e[type=item,name="some name with spaces and "quotation marks""]
    

Limitations

  • If you name an item “Ghast Tear”, the ghast tear command will run even if it were something else, like dirt.
  • If someone has their language set to something else (i.e. Spanish) then this might not work, although you could make two command blocks testing for the Spanish name and another for the English name.
  • If someone has a resource pack enabled that modifies the language files (i.e. maybe change the name Cooked Beef to Steak), this might not work
  • The entity count returned by a /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.

Correct answer by Penguin on January 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP