I've coded a datapack that makes an arrow explode when it lands. However, when hitting a mob it of course doesn't explode. How could I fix this? Right now my code is:
execute as @e[type=arrow,nbt={inGround:1b}, tag=explosive_arrow] at @s run function pack:explode
tag=explosive arrow is added if it is shot from a bow with a custom enchant, and pack:explode just summons a creeper with fuse 0
#Detecting when an arrow shoots a mob
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
Someone will come and help soon!
💬 While you wait, take this time to provide more context and details.
🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
⚠️ You already have a question open!
Don't forget to close or resolve your old questions once you're done with them. It makes our lives much easier! :D
Open question: #1258813614962380900
Arrows that hit a mob instantly disappear as soon as they make contact, making it a lot more difficult to detect.
There are workarounds for this, such as having an invisible armor stand that constantly rides any arrow with the tag=exposive_arrow and checking if its still riding an arrow constantly.
if its not riding an arrow, that would have to mean that it hit a mob, and from there you can run the command.
for that you can use custom tipped arrows. lets say you give the player an arrow with luck (an unused enchantment) level 7, which lasts 1 ticks. You can just execute an explosion command at every entity with the luck effect level 7 since there is no other way to obtain it. This will also let you have normal arrows as well as expldoing arrows. Hope this helps.
use custom enchantment
Which version are you on?
1.21
I'm not sure enchantments can help much here, unless there's a feature of them that I'm not aware of
Is there a way to do this without armour stands?
<@&1166082198152159386> <@&1202694677766348840>
**🙇 Helpers Arise!**
Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)
Well a Marker or something would be better
tipped arrows like was suggested would be another method
But of course that requires ticking as all possible entities that could get hit to detect if they have that effect
I am already ticking all entities for the arrow in ground
Well there ya go then.
Is there a way to hide the effect in the arrow description?
Isn't there NBT data for how many arrows a mob has on it?
Mobs don't display arrows stuck in them, only the player
And I don't think there's NBT for that
Probably, but you wouldn't change the arrow item
You'd only change the entity once the arrow is shot
Well you're already giving the arrow a custom tag right?
Yes