#Killing an entity if it has custom model data

1 messages · Page 1 of 1 (latest)

pure bridge
#

How would I go about killing an item if it has the custom model data I am looking for. I am making a new smithing table upgrade and it works but when I break it with the items inside it will drop the completed item and all the components because it hasnt been taken out yet so I was going to make it so that if the armor stand that allows the table to works has a tag that is it crafting it will delete the completed drop on break and only drop the components but I dont know how to kill an entity with a custom model data if thats even possible.

I didnt post any code because its not an issue with the code I have but rather a question if its possible to kill entities based off of custom model data or not. I am assuming there is a way since the item still has the model data when it is an entity on the ground I just cant figure it out

crisp leafBOT
#
**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

sharp lynx
#

You can select the select an are at the block where the smithing table was and kill all items that have the CustomModeData.

Something like this (executed as and at the armor stand):

execute align xyz run kill @e[type=item,dx=0,nbt={Item:{tag:{CustomModelData:123}}}]
#

However I suggest using a marker or item display instead of an armor stand.

#

Another tip. If possible, use custom tags to identify the items and not CustomModelData

pure bridge
#

kill @e[type=item, nbt={CustomModelData:33300}, distance=0..2, sort=nearest, limit = 1]
When doing this I get Unknown key CustomModelData

sharp lynx
#

wait I forgot something

#

fixed it

#

One more thing, if you use distance=..2 you might accidentally delete items that are just nearby but have nothing to do with the smiting table.

pure bridge
#

Would I be able to apply a custom block texture with block bench to a marker because im using the armor stand for the the table and the texture?

sharp lynx
#

in this case, use an item display

#

it's much easier to make the model the right size

pure bridge
#

I have the armor stand holding an item frame with the model item frame inside it

sharp lynx
#

?

#

you mean if you would place the item frame that the armor stand is holding it has the custom model inside?

pure bridge
#

Yes

#

That way it appears in my inventory and when I place it it runs a function to spawn the armor stand and deletes the original placement

#

Ive got to run to work but I will try some of your recomendations when I get home and hope I can get this working thanks for the help

sharp lynx
#

no problem

finite lotus