#Execute as specific item entity

1 messages · Page 1 of 1 (latest)

latent hamlet
#

Hey, I think there's a way to do this but I'm not smart enough to figure it out from reading the wiki.

Can I execute a command as an item entity? For example, in my data pack I want to be able to run a command as every tnt item entity. If this is possible, how would I go about doing it? Thanks!

I assume it will be something like execute as @e[type=item{<idk_what_goes_here>} run <commands>

The @e[type=item{<idk_what_goes_here>} is what I need help with.

magic apexBOT
#
**Someone will come and help soon!**

💬 While you wait, take this time to provide more context and details. What are you trying to achieve overall - maybe there's an easier way to solve this problem

🙇 If it's been 30 minutes and you're still waiting for someone to help, hit the Summon Helpers button to call the official helpers here

✅ Once your question has been resolved (or you no longer need it), hit the Resolve Question button or run /resolve

latent hamlet
#

Now that I've posted this I realize that this may be the incorrect place to ask questions about this, since it's more of a commands question than a data pack one. If so, my apologies

shy karma
#

the bare minimum way to do this is just an "execute as @e[type=item,nbt={Item:{id:"minecraft:tnt"}}] run ..."

tho running an nbt check on every item in the world can be expensive so itd probably do the classic trick of something like this:

execute as @e[type=item,tag=!scanned,nbt={Item:{id:"minecraft:tnt"}}] run tag @s add tnt_item
tag @e[type=item] add scanned```
then in a seperate command block:
```hs
execute as @e[type=item,tag=tnt_item] run <the commands you wanted to run>```
#

item entities store the data of the item they are as an Item nbt tag that looks like this:

latent hamlet
#

Okay, thank you so much for the help!