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

# -> Particles
particle minecraft:block{block_state:"minecraft:redstone_block"} ~ ~ ~ 0 0.8 0 0.001 50 normal @a

# -> Bleeding RNG
execute if predicate overly_realistic:player/damage/direct_damage_bleeding_rng_small run \
    function overly_realistic:players/bleeding/start_bleeding

# -> Mental health decrease RNG
execute if predicate overly_realistic:player/damage/potent_direct_damage_rng run \
    function overly_realistic:players/mental_health/edit_mental_health {type:"remove",value:1}

# -> If player is on ground then create blood splatter
execute at @s if predicate overly_realistic:global/is_on_ground run \
    summon minecraft:block_display ~ ~0.5 ~ {Tags:["OverlyRealistic.GroundBloodSplatter","OverlyRealistic.GroundMarking"], block_state: {Name: "minecraft:redstone_wire", Properties: {east: "none", north: "none", power: "0", south: "none", west: "none"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [-0.5f, -0.5f, -0.5f]}}

# -> If player is wearing metal armor then play sound
execute if items entity @s armor.* #overly_realistic:non_leather_armor run \
    playsound minecraft:item.mace.smash_ground player @a ~ ~ ~ 0.3 2

# -> Get if attacker was using a tool
scoreboard players set #or.was_attacker_using_tool OverlyRealistic.General.ArbitraryData 0
execute on attacker \
    if items entity @s weapon.mainhand #overly_realistic:armor_damage_sound_tools run \
        scoreboard players set #or.was_attacker_using_tool OverlyRealistic.General.ArbitraryData 1

# -> If player is wearing metal armor then play sounds
execute if items entity @s armor.* #overly_realistic:non_leather_armor run \
    playsound minecraft:item.mace.smash_ground player @a ~ ~ ~ 0.3 2

# -> If player is wearing metal armor and the attacker was using a metal tool then play extra sound
execute if items entity @s armor.* #overly_realistic:iron_armor \
    if score #or.was_attacker_using_tool OverlyRealistic.General.ArbitraryData matches 1 run \
        playsound minecraft:entity.zombie.attack_iron_door player @a ~ ~ ~ 1 2

# -> Breaking bone sound
execute if predicate overly_realistic:player/damage/breaking_bone_sound_rng run \
    playsound minecraft:entity.player.big_fall player @a ~ ~ ~ 0.85 0

# ---> Body damage

# -> Create a marker on the head
execute anchored eyes \
    positioned ^ ^ ^ \
    anchored feet run \
        summon marker ~ ~ ~ {Tags:["OverlyRealistic.Player.BodyMarker","OverlyRealistic.Player.BodyPartHead"]}

# -> Tag player
tag @s add OverlyRealistic.Player.TempPlayerHurt

# -> Get scale
execute store result score #or.player_scale OverlyRealistic.General.ArbitraryData run \
    attribute @s scale get 100

# -> Create a marker on the torso and legs, then continue operations
execute if score #or.player_scale OverlyRealistic.General.ArbitraryData matches ..60 run \
    return run \
        function overly_realistic:players/body_damage/torso_legs_markers/create_markers_0
execute if score #or.player_scale OverlyRealistic.General.ArbitraryData matches 61..90 run \
    return run \
        function overly_realistic:players/body_damage/torso_legs_markers/create_markers_1
execute if score #or.player_scale OverlyRealistic.General.ArbitraryData matches 91..130 run \
    return run \
        function overly_realistic:players/body_damage/torso_legs_markers/create_markers_2
execute if score #or.player_scale OverlyRealistic.General.ArbitraryData matches 140.. run \
    function overly_realistic:players/body_damage/torso_legs_markers/create_markers_3

