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

# -> Add to bucket timer
scoreboard players add @s OverlyRealistic.Player.UseItem_WaterBucket 1

# -> Sound
playsound entity.boat.paddle_water player @a ~ ~ ~ 0.5 2

# -> Particles
execute anchored eyes \
    positioned ^ ^ ^ \
    anchored feet run \
        particle falling_water ^ ^ ^0.8 0.1 0 0.1 0.1 5 normal @a

# -> If timer is less than the max then return
execute unless score @s OverlyRealistic.Player.UseItem_WaterBucket matches 40.. run \
    return fail

# -> Reset timer
scoreboard players reset @s OverlyRealistic.Player.UseItem_WaterBucket

# -> If player used item while looking upwards then drink it
execute if entity @s[x_rotation=-90..-80] run \
    return run \
        function overly_realistic:players/items/water_bucket/water_drink

# -> Reset raycast values
scoreboard players set @s OverlyRealistic.General.LocalRaycastRange 0
scoreboard players set @s OverlyRealistic.General.LocalRaycastRangeMax 8

# -> Perform raycast
execute anchored eyes \
    positioned ^ ^ ^ \
    anchored feet run \
        function overly_realistic:players/items/water_bucket/raycast_travel
