
# -> Reset adv trigger
advancement revoke @s only overly_realistic:items/use_hide_waterskin

# -> Reset vars
scoreboard players set #or.Raycast.RayRange OverlyRealistic.General.ArbitraryData 0
scoreboard players set #or.global OverlyRealistic.General.ArbitraryData 0

# -> Get max raycast range
execute store result score #or.Raycast.RayRangeMax OverlyRealistic.General.ArbitraryData run \
    attribute @s block_interaction_range get 10

# -> Do raycast
execute anchored eyes \
    positioned ^ ^ ^ \
    anchored feet run \
        function overly_realistic:players/foods/waterskin/waterskin_raycast_travel

# -> If water hasn't been picked up then return
execute if score #or.global OverlyRealistic.General.ArbitraryData matches 0 run \
    return fail

# -> Sound
playsound item.bucket.fill player @a ~ ~ ~ 0.65 1

# -> If ocean water was picked up then return and operate
execute if score #or.global OverlyRealistic.General.ArbitraryData matches 2 run \
    return run \
        function overly_realistic:players/foods/waterskin/waterskin_fill_with_sea_water

# -> Set waterskin contents (dirty water)
execute if items entity @s weapon.mainhand poisonous_potato[custom_data~{IsHideWaterskin:1b}] run \
    return run \
        item modify entity @s weapon.mainhand overly_realistic:items/hide_waterskin_get_water_dirty
item modify entity @s weapon.offhand overly_realistic:items/hide_waterskin_get_water_dirty
