
# -> Sound
playsound minecraft:entity.warden.sonic_boom player @s ~ ~ ~ 2 0

# -> Remove player inventory
item replace entity 00000001-0000-002b-0000-00010000002b contents from entity @s armor.body
clear @s *
item replace entity @s armor.body from entity 00000001-0000-002b-0000-00010000002b contents

# -> Set gamemode
gamemode spectator @s

# -> If player is down and 'player corpses' is off then spawn the player death loot
execute if score #or.setting.player_corpses OverlyRealistic.Settings.ArbitrarySetting matches 0 \
    at @s run \
        loot spawn ~ ~ ~ loot overly_realistic:players/player_death

# -> Tag entity
tag @s add OverlyRealistic.Player.IsGhost

# -> Globalize death ID
scoreboard players operation #or.current_death_id OverlyRealistic.Player.DeathID = @s OverlyRealistic.Player.DeathID

# -> Remove downed player parent ent
execute as @e[type=armor_stand,tag=OverlyRealistic.Entity.IsDowningEntity] \
    if score @s OverlyRealistic.Player.DeathID = #or.current_death_id OverlyRealistic.Player.DeathID \
    at @s run \
        function overly_realistic:general/downing/downing_parent_ent_remove

# -> Remove attributes
#attribute @s movement_speed modifier remove overly_realistic:downed_player_movement_speed
#attribute @s jump_strength modifier remove overly_realistic:downed_player_jump_strength
#attribute @s gravity base reset

# -> Remove downed tags
tag @s remove OverlyRealistic.Player.HasBeenDownedBefore
tag @s remove OverlyRealistic.Player.IsDowned

# -> Remove misc tags
tag @s remove OverlyRealistic.Player.IsDeaf
tag @s remove OverlyRealistic.Player.IsSick

# -> Effects
effect give @s blindness 10 0 true

