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

# -> Debug particles
#particle flame ~ ~ ~ 0 0 0 0.001 1 force @a

# -> If lifetime is maxxed then return and destroy self
execute if score @s OverlyRealistic.General.ArbitraryData matches 3600.. run \
    return run \
        function overly_realistic:general/spears/spear_remove

# -> Set existence
#scoreboard players set #or.spears_exist OverlyRealistic.General.ArbitraryData 1

# -> If spear does not have base ent then return and operate accordingly
execute unless predicate overly_realistic:global/entity_is_on_vehicle run \
    return run \
        function overly_realistic:general/spears/spear_remove

# -> If spear hit an entity then operate accordingly
execute positioned ~-1 ~-1 ~-1 \
    if entity @n[type=!#overly_realistic:spear_cant_damage,dx=1,dz=1,dy=1] \
    at @s run \
        function overly_realistic:general/spears/spear_hit_entity

# -> Check if spear hit a block
execute unless block ^ ^ ^0.5 #overly_realistic:spear_can_passthrough run \
    return run \
        function overly_realistic:general/spears/spear_remove

# -> If spear is going downwards then rotate model down
execute on vehicle \
    at @s \
    if predicate overly_realistic:global/entity_downward_velocity \
    on passengers \
    at @s run \
        rotate @s ~ ~10
