
# -> Sound
playsound minecraft:entity.zombie.break_wooden_door neutral @a ~ ~ ~ 1 1.7

# -> Damage spear
execute store result score #or.global OverlyRealistic.General.ArbitraryData run \
    data get entity @s item.components.minecraft:damage
execute store result entity @s item.components.minecraft:damage int 1 run \
    scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 1

# -> Break spear if its damage is over its max_damage
execute store result score #or.equation_part_1 OverlyRealistic.General.ArbitraryData run \
    data get entity @s item.components.minecraft:max_damage
execute if score #or.global OverlyRealistic.General.ArbitraryData >= #or.equation_part_1 OverlyRealistic.General.ArbitraryData run \
    return run \
        function overly_realistic:general/spears/spear_remove_self

# -> Drop itself
#loot spawn ~ ~ ~ loot overly_realistic:items/wooden_spear
summon item ~ ~ ~ {Tags:["OverlyRealistic.TempEnt"],Item:{id:"stick",count:1}}
item replace entity @n[type=item,tag=OverlyRealistic.TempEnt,distance=..1] contents from entity @s contents
tag @n[type=item,tag=OverlyRealistic.TempEnt,distance=..1] remove OverlyRealistic.TempEnt
#tellraw @a {entity:"@s",nbt:"item"}

# -> Remove self
execute on vehicle run \
    kill @s
kill @s