
# -> Cache entity data
data modify storage overly_realistic:bow_operations arrow_data set from entity @s

# -> If shot from short bow then set data
execute if data storage overly_realistic:bow_operations {arrow_data:{weapon:{id:"minecraft:bow",components:{"minecraft:custom_data":{IsShortBow:1b}}}}} run \
    function overly_realistic:players/misc/short_bow/short_bow_shot

# -> If arrow is a wooden arrow then set data
execute if data storage overly_realistic:bow_operations {arrow_data:{item:{id:"minecraft:arrow",components:{"minecraft:custom_data":{ArrowType:"wooden_arrow"}}}}} \
    store result entity @s Motion[1] double 0.9 run \
        data get storage overly_realistic:bow_operations arrow_data.Motion[1]

# -> Operate on origin player
execute on origin run \
    function overly_realistic:players/misc/bows/bow_shot_operation_from_player

# -> If origin player's stamina is low then decrease damage
execute if score #or.origin_stamina OverlyRealistic.General.ArbitraryData matches ..10 \
    store result entity @s damage double 0.5 run \
        data get entity @s damage

# --> Wisdom skill

# -> If origin player does not have >= 1 archery level then return
execute unless score #or.origin_archery_skill_level OverlyRealistic.General.ArbitraryData matches 1.. run \
    return fail

# -> Re-store data
data modify storage overly_realistic:bow_operations arrow_data set from entity @s

# -> Level 1 buffs
execute if score #or.origin_archery_skill_level OverlyRealistic.General.ArbitraryData matches 1..2 run \
    function overly_realistic:players/misc/bows/archery_wisdom/level_1_data

# -> Level 2 buffs
execute if score #or.origin_archery_skill_level OverlyRealistic.General.ArbitraryData matches 2 run \
    data modify entity @s crit set value 1b

# -> Level 3 buffs
execute if score #or.origin_archery_skill_level OverlyRealistic.General.ArbitraryData matches 3..4 run \
    function overly_realistic:players/misc/bows/archery_wisdom/level_3_data

# -> Level 4 buffs
execute if score #or.origin_archery_skill_level OverlyRealistic.General.ArbitraryData matches 4 run \
    data modify entity @s PierceLevel set value 1b

# -> Level 5 buffs
execute if score #or.origin_archery_skill_level OverlyRealistic.General.ArbitraryData matches 5 run \
    function overly_realistic:players/misc/bows/archery_wisdom/level_5_data