Basically I want to make pillagers friendly to the player until the player hits them, at which point all pillagers in the world kill the player on sight
Most of it works just fine but for some reasons I cant get the event to trigger when pillagers take damage
I tried damage sensor, on_hurt_by_player, but neither worked
using /event the event works just fine
#How do I trigger an event if a mob takes damage?
1 messages · Page 1 of 1 (latest)
If you want this to apply to all pillagers not just the one you’re attacking you’re gonna need to use scripts to trigger the event on each entity as this would only ever work for the individual you attack. For the issue you’re experiencing, try adding subject other to the filter like the bad omen example below
"minecraft:damage_sensor": {
"triggers": {
"on_damage": {
"filters": {
"all_of": [
{
"test": "has_damage",
"value": "fatal"
},
{
"test": "is_family",
"subject": "other",
"value": "player"
}
]
},
"event": "minecraft:gain_bad_omen",
"target": "other"
}
}
}
Oh actually I almost forgot about the broadcast anger behaviour, check out the zombie pigmen entity behaviour, should be able to add that anger to achieve your goal
To make it permanent and worldwide, I'd probably recommend adding a tag to the player with the method indyfficient mentioned, and then have the pillagers attack anyone with that tag using the has_tag filter
yeah thats what I did but it doesnt work
as in the event doesnt run
Ah, gotcha. I think I might know why
Setting it to other tries to trigger the event in the player's file
If it's in the mob's file, remove the "target":"other"
and then inside of the queue_command, add "target":"other"
So like json "example:event":{ "queue_command":{ "command":[ "tag @s add L:pillager_target" ], "target":"other" } }
ohhh ill try that thank you
I tried it and it still didnt add any tags to the player
for what its worth heres the entire modified pillager file, maybe im missing something obvious
Ah, the filter is the issue there
You need to set the subject to other
{
"test": "is_family",
"subject": "other",
"value": "player"
}```
hm yeah that didnt work
the command doesnt seem to trigger no matter what, changing it to something like "say Hello" wont do anything
also since I added the "target":"other" tag to the queue command it doesnt work through /event either, not sure if thats important or not
hmm, any content log errors?
I kid you not it started working as soon as I turned content log on lmfao
thanks for all of your help
Glad it does now!