
# -> Reset adv trigger
advancement revoke @s only overly_realistic:player/player_tick

# -> Manage triggers
scoreboard players enable @s OverlyRealistic.Player.OrTriggers
execute if score @s OverlyRealistic.Player.OrTriggers matches 1.. run \
    function overly_realistic:main/settings/player/player_activate_trigger

# -> If player is on spectator then return
execute if entity @s[gamemode=spectator] run \
    return fail

# -> If player has had exhaustion applied then operate
execute if entity @s[tag=OverlyRealistic.Player.ExhaustionHasBeenApplied] run \
    function overly_realistic:players/hunger/exhaustion_application/apply_ex_remove_ex

# -> If inventory changed then modify items
execute if entity @s[tag=OverlyRealistic.Player.InventoryChanged] run \
    function overly_realistic:general/items/player/player_inv_change

# -> If player has a modifiable item in their cursor then modify it
execute if items entity @s player.cursor *[!custom_data] run \
    function overly_realistic:general/items/player/inv_slots/edit_cursor

# -> If player is using a HUI item then operate
execute if entity @s[tag=OverlyRealistic.Player.IsUsingHuiItem] run \
    function overly_realistic:players/items/multipurpose/hold_down_use_interaction/hui_item_operate

# -> If player is a deity then return and operate accordingly
execute if entity @s[tag=OverlyRealistic.Player.IsDeity] run \
    return run \
        function overly_realistic:general/godhood/deity_ticked

# -> If player is sprinting then operate
#scoreboard players set @s OverlyRealistic.PredicateValue.IsSprinting 0
#execute if predicate overly_realistic:player/actions/player_is_sprinting run \
    function overly_realistic:players/sprinting/player_is_sprinting

# -> Remove XP
#xp set @s 0 levels
#xp set @s 0 points

# -> Check if player used a glass bottle
#execute if score @s OverlyRealistic.Player.UsedGlassBottle matches 1.. \
    if items entity @s weapon.* potion run \
        function overly_realistic:players/thirst/used_glass_bottle

# -> Check if player who was previously in water is out of the water
execute if entity @s[tag=OverlyRealistic.Player.IsInWater] \
    anchored eyes \
    positioned ^ ^ ^ \
    anchored feet \
    unless block ~ ~ ~ water run \
        function overly_realistic:players/misc/water/player_got_off_water

# -> Check if player is in water
execute if entity @s[tag=!OverlyRealistic.Player.IsInWater] \
    anchored eyes \
    positioned ^ ^ ^ \
    anchored feet \
    if block ~ ~ ~ water run \
        tag @s add OverlyRealistic.Player.IsInWater

# -> Check if player is falling
#execute if score @s OverlyRealistic.Player.FallTime matches 1.. \
    unless predicate overly_realistic:player/actions/player_is_falling run \
        function overly_realistic:players/water_fall_damage/player_fell
#execute if predicate overly_realistic:player/actions/player_is_falling run \
    scoreboard players add @s OverlyRealistic.Player.FallTime 10000

# -> If player is standing on leaves then fall
#execute if predicate overly_realistic:player/misc/standing_on_leaves run \
    tp ~ ~-0.01 ~

# -> If player is standing on a lilypad then break it
#execute if predicate overly_realistic:player/misc/standing_on_lilypad run \
    function overly_realistic:players/misc/water/break_lilypad

# -> If player is deaf then remove sounds
stopsound @s[tag=OverlyRealistic.Player.IsDeaf]

# -> Wet checks
#execute if block ~ ~ ~ water \
    unless predicate overly_realistic:global/entity_is_on_vehicle run \
        scoreboard players add @s OverlyRealistic.Player.WetTime 4
#execute anchored eyes \
    if block ^ ^ ^ water run \
        scoreboard players add @s OverlyRealistic.Player.WetTime 4
#execute if score @s OverlyRealistic.Player.WetTime matches 1201.. run \
    scoreboard players set @s OverlyRealistic.Player.WetTime 1200

# -> Decrease WetTime
#scoreboard players remove @s OverlyRealistic.Player.WetTime 1
#execute unless score @s OverlyRealistic.Player.WetTime matches 0.. run \
    scoreboard players set @s OverlyRealistic.Player.WetTime 0

# --> (@NOTE: DEPRECATED)

# -> Check for drinking water
#execute if score @s[tag=OverlyRealistic.Player.IsHoldingWater] OverlyRealistic.Player.DrankPotion matches 1.. run \
    function overly_realistic:players/thirst/drank_liquid

# -> Check for player holding water
#tag @s remove OverlyRealistic.Player.IsHoldingWater
#execute if items entity @s weapon.* potion[potion_contents={potion:"water"}] run \
    tag @s add OverlyRealistic.Player.IsHoldingWater