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

# -> Add to usage time
scoreboard players add @s OverlyRealistic.Player.UseItem_IronBucket 1

# -> If usage time < max then return
execute unless score @s OverlyRealistic.Player.UseItem_IronBucket matches 50.. run \
    return fail

# -> Reset time
scoreboard players reset @s OverlyRealistic.Player.UseItem_IronBucket

# -> If player is looking at a cow then return and set item
execute if predicate overly_realistic:player/actions/player_looking_at_cow run \
    return run \
        function overly_realistic:players/items/iron_bucket/empty/get_milk

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

# CONTENTS TYPES:
# 1 = dirty water
# 2 = clean water
# 3 = sea water
# 4 = lava
# 5 = powder snow

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

# -> Raycast
execute anchored eyes \
    positioned ^ ^ ^ \
    anchored feet run \
        function overly_realistic:players/items/iron_bucket/empty/raycast_travel
