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

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

# --> Randomize max usage time

# -> Healthcare 0
execute if score @s OverlyRealistic.Player.WisdomStats.Healthcare matches 0 \
    store result score @s OverlyRealistic.Player.UseItem_Bandage_Max run \
        random value 10..20

# -> Healthcare 1
execute if score @s OverlyRealistic.Player.WisdomStats.Healthcare matches 1..2 \
    store result score @s OverlyRealistic.Player.UseItem_Bandage_Max run \
        random value 8..15

# -> Healthcare 3
execute if score @s OverlyRealistic.Player.WisdomStats.Healthcare matches 3 \
    store result score @s OverlyRealistic.Player.UseItem_Bandage_Max run \
        random value 7..12

# -> Healthcare 4
execute if score @s OverlyRealistic.Player.WisdomStats.Healthcare matches 4.. \
    store result score @s OverlyRealistic.Player.UseItem_Bandage_Max run \
        random value 6..10

# -> Set title time
title @s times 0 15 0

# -> If there is a player in front of the user then set title
tag @s add OverlyRealistic.Player.TempBandagePlayer
title @s title ""
execute if score @s OverlyRealistic.PredicateValue.IsSneaking matches 1 \
    anchored eyes \
    positioned ^ ^ ^1 \
    positioned ~-1 ~-1 ~-1 \
    if entity @p[tag=!OverlyRealistic.Player.TempBandagePlayer,dx=1,dy=1,dz=1] run \
        return run \
            function overly_realistic:players/operations/player_use_bandage_shifting
tag @s remove OverlyRealistic.Player.TempBandagePlayer

# -> Remove bleeding
scoreboard players set @s OverlyRealistic.Player.BleedingTimer 0

# -> Mental health increase RNG
scoreboard players set #or.central_value_set_mental_health OverlyRealistic.General.ArbitraryData 2
execute if predicate overly_realistic:player/damage/potent_direct_damage_rng run \
    function overly_realistic:players/mental_health/add_to_mental_health

# -> Sound
playsound minecraft:block.wool.step player @a ~ ~ ~ 0.5 2

# -> Remove effect
#effect clear @s luck

# -> Remove item
execute if items entity @s weapon.mainhand *[custom_data~{IsBandage:1b}] run \
    return run \
        item modify entity @s weapon.mainhand overly_realistic:multipurpose/remove_one_item
item modify entity @s weapon.offhand overly_realistic:multipurpose/remove_one_item
