
# 00000001-0000-002b-0000-00010000002b

# -> Do spear-dependent operations
function overly_realistic:players/misc/spear/spear_damage_instant/get_spear_type

# -> Damage spear
execute store result score #or.global OverlyRealistic.General.ArbitraryData run \
    data get entity 00000001-0000-002b-0000-00010000002b item.components.minecraft:damage
execute store result entity 00000001-0000-002b-0000-00010000002b 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 00000001-0000-002b-0000-00010000002b item.components.minecraft:max_damage
execute if score #or.global OverlyRealistic.General.ArbitraryData >= #or.equation_part_1 OverlyRealistic.General.ArbitraryData run \
    return fail

# -> Drop itself
summon item ~ ~ ~ {Tags:["OverlyRealistic.TempEnt"],Item:{id:"stick",count:1}}
item replace entity @n[type=item,tag=OverlyRealistic.TempEnt,distance=..1] contents from entity 00000001-0000-002b-0000-00010000002b contents
tag @n[type=item,tag=OverlyRealistic.TempEnt,distance=..1] remove OverlyRealistic.TempEnt
