#How to detect when an entity takes damage by an arrow
1 messages · Page 1 of 1 (latest)
Depends a little bit about what all you want to be checking. The most consistent and reliable way is to make a custom enchantent that you either apply to the bow, or modify the data of the arrows to make them think they were shot by a how with that enchantment, but either may not be ideal for your given usecase
I just want it to play a function that deals damage to surrounding entities
What is "it"
...okay, that doesn't give me any new or useful information to provide a different answer than what I already have
I'll try out what you said
Oh yeah, I'm using /summon for the arrows
with a music disc
How do I do the modifying data of the arrow and which effect do I use
So how do i modify the data?
If you're summoning the arrows, just define the NBT of it when you do so
You care about the weapon nbt
It isn't working
summon arrow ~ ~ ~ {Tags:["test_arrow"],weapon:{id:bow,components:{enchantments:{"trial_by_combat:test":1}}}}
This is what it's using currently
Looks like correct NBT, so let's see the enchantment
{
"criteria": {
"example": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"damage": {
"type": {
"direct_entity": {
"type": "minecraft:arrow",
"nbt": "{Tags:"test_arrow"}"
}
}
}
}
}
},
"rewards": {
"function": "trial_by_combat:test/test_tell"
}
}
that's player hurt entity
you want to detect when an entity hurts a player
Something like this: https://misode.github.io/advancement/?share=NEJfVtuilJ
It doesnt load the shared one
the link
No wait it does
It still doesnt work even with that enchantment
any errors in the logs?
Not sure if this is mod stuff since Im launching with modrinth with mods
pretty sure it isnt though
Nope
It isnt detecting the damage
i gave myself the advancement manually and it worked
oh ok
You could try removing the tag check and hitting yourself with a normal arrow
when mobs hit you?
When the arrow hits a mob
This is an advancement, not an enchantment
Yeah, i know that
I have an enchantment too
{
"description": "",
"supported_items": [
"minecraft:music_disc_11"
],
"weight": 1,
"max_level": 1,
"min_cost": {
"base": 0,
"per_level_above_first": 0
},
"max_cost": {
"base": 0,
"per_level_above_first": 0
},
"anvil_cost": 0,
"slots": [
"mainhand"
],
"effects": {
"minecraft:post_attack": [
{
"effect": {
"type": "minecraft:run_function",
"function": "trial_by_combat:test/test_tell"
},
"enchanted": "attacker",
"affected": "attacker"
}
]
}
}
this is the enchantment
So you want the function to run as the entity that shot the arrow?
It should run at the entity
The entity that got hit?
Yes
Then you need to change the affected field
Cause right now it's trying to run the function as the entity that shot the arrow, but since you're summoning the arrow, no one shot it
Did you exit and reopen the world?
Forgot about that but i just did it and it still doesnt work
Are you positive the function isn't running? What's in the function?
advancement revoke @a only trial_by_combat:summon_projectile
tell @a Test
Well revoking an advancement isn't gonna do anything here
And try say instead of tell
Show the current enchantment?
{
"description": "",
"supported_items": [
"minecraft:music_disc_11",
"minecraft:bow"
],
"weight": 1,
"max_level": 1,
"min_cost": {
"base": 0,
"per_level_above_first": 0
},
"max_cost": {
"base": 0,
"per_level_above_first": 0
},
"anvil_cost": 0,
"slots": [
"mainhand"
],
"effects": {
"minecraft:post_attack": [
{
"effect": {
"type": "minecraft:run_function",
"function": "trial_by_combat:test/test_tell"
},
"enchanted": "attacker",
"affected": "victim"
}
]
}
}
Could be because there's no attacker, try doing damaging_entity for the enchanted field
Didn't work
Hm, not sure then
It works when the arrow hits me but not for mobs
Doesn't seem right, what's in your function now?