
# -> Get entity attacker status
scoreboard players set #or.animal_attacker_status_horse OverlyRealistic.General.ArbitraryData 0
execute on attacker \
    if entity @s[tag=OverlyRealistic.Player.TempPlayerHitCorpse] run \
        scoreboard players set #or.animal_attacker_status_horse OverlyRealistic.General.ArbitraryData 1
execute if score #or.animal_attacker_status_horse OverlyRealistic.General.ArbitraryData matches 0 run \
    return fail

# -> Particles
particle block{block_state:"redstone_block"} ~ ~0.5 ~ 0.1 0.5 0.1 0.1 20 normal @a

# -> Tag animal
tag @s add OverlyRealistic.Animal.AnimalCorpseHasBeenHit

# -> Loot
execute as @p[tag=OverlyRealistic.Player.TempPlayerHitCorpse,distance=..16] run \
    loot spawn ~ ~1 ~ kill @n[type=horse,tag=OverlyRealistic.Animal.AnimalCorpseHasBeenHit,dx=0,dy=0,dz=0]

# -> Untag animal
tag @s remove OverlyRealistic.Animal.AnimalCorpseHasBeenHit

# -> Add to hurt value
scoreboard players add @s OverlyRealistic.General.ArbitraryData 1

# -> If hurt value is not above max then return
execute unless score @s OverlyRealistic.General.ArbitraryData matches 10.. run \
    return fail

# -> Particles
particle block_crumble{block_state:"redstone_block"} ~ ~0.5 ~ 0.3 0.5 0.3 0.1 30 normal @a

# -> Remove entity
tp @s ~ ~-9999 ~
kill @s