
# -> Tag player
tag @s[tag=!OverlyRealistic.Player.NeedsAttributeRestoration] add OverlyRealistic.Player.RestoredModifiersPostDeath

# -> Re-apply death attributes
#attribute @s[tag=!OverlyRealistic.Player.NeedsAttributeRestoration] movement_speed modifier add overly_realistic:downed_player_movement_speed -100.0 add_value
#attribute @s[tag=!OverlyRealistic.Player.NeedsAttributeRestoration] jump_strength modifier add overly_realistic:downed_player_jump_strength -100.0 add_value
#attribute @s[tag=!OverlyRealistic.Player.NeedsAttributeRestoration] gravity base set 0

# -> If player has NeedsAttributeRestoration then run patch
execute if entity @s[tag=OverlyRealistic.Player.NeedsAttributeRestoration] \
    at @s run \
        function overly_realistic:general/downing/attribute_restoration/normal_respawn_restore_patch

# -> Reset attribute data
data modify storage overly_realistic:player_attributes local_pre_death_attributes set value []

# -> Save last attributes to storage
item replace block -29999985 2 -29999985 container.0 from entity @s armor.body
data modify storage overly_realistic:player_attributes local_pre_death_attributes set from block -29999985 2 -29999985 Items[{Slot:0b}].components.minecraft:custom_data.attribute_modifiers_on_death

# -> Start loop
function overly_realistic:general/downing/attribute_restoration/restoration_loop
