
# -> If player has iron armor and is in water then drag them down
execute if items entity @s armor.* #overly_realistic:iron_armor \
    if block ~ ~-0.5 ~ water run \
        scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 2

# -> Nausea harsh illness effect
execute if entity @s[tag=OverlyRealistic.Harsh_Illness.Nausea] run \
    effect give @s nausea 5 0 true

# -> Slowness harsh illness effect
execute if entity @s[tag=OverlyRealistic.Harsh_Illness.Slowness] run \
    effect give @s slowness 5 0 true

# -> Weakness harsh illness effect
execute if entity @s[tag=OverlyRealistic.Harsh_Illness.Weakness] run \
    effect give @s weakness 5 0 true

# -> Weakness harsh illness effect
execute if entity @s[tag=OverlyRealistic.Harsh_Illness.Poison] run \
    effect give @s poison 5 2 true

# -> Decrease illness cooldown timer
execute unless score @s OverlyRealistic.Player.IllnessCooldownTime matches ..0 run \
    scoreboard players remove @s OverlyRealistic.Player.IllnessCooldownTime 1

# -> If player is under the rain then add to WetTime
execute if predicate overly_realistic:world/weather/can_get_wet \
    if function overly_realistic:mobs_general/sky_check/is_exposed_to_sky run \
        scoreboard players add @s OverlyRealistic.Player.WetTime 60

# -> If player is near a campfire then dry them off
execute if entity @n[type=marker,tag=OverlyRealistic.CampfireBlock,scores={OverlyRealistic.World.CampfireFireTime=1..},distance=..3] run \
    scoreboard players remove @s OverlyRealistic.Player.WetTime 9

# -> If player is underwater then add to UnderwaterTime
execute anchored eyes \
    if block ^ ^ ^ water run \
        scoreboard players add @s OverlyRealistic.Player.UnderwaterTime 1

# -> If player has spent time underwater then add to underwater endurance
execute if score @s OverlyRealistic.Player.UnderwaterTime matches 12000.. run \
    function overly_realistic:players/misc/water/add_to_underwater_endurance

# -> If player is underwater then add to UnderwaterTime
execute if predicate overly_realistic:player/actions/player_is_swimming run \
    scoreboard players add @s OverlyRealistic.Player.SwimmingTime 1

# -> If player has spent time swimming then add to swimming speed
execute if score @s OverlyRealistic.Player.SwimmingTime matches 24000.. run \
    function overly_realistic:players/misc/water/add_to_swim_speed

# -> If player is wet then display particles
execute if score @s OverlyRealistic.Player.WetTime matches 1.. \
    unless block ~ ~ ~ water \
    anchored eyes \
    unless block ~ ~ ~ water \
    anchored feet run \
        particle minecraft:falling_water ~ ~1 ~ 0.2 0.5 0.2 0.1 5 normal @a