execute unless score global availableResets matches ..0 run scoreboard players remove global availableResets 1

execute if score global undoStackHead matches 1..10 positioned -1 78 -1 run function bd:game/perform_undo/_index_1_10
execute if score global undoStackHead matches 11..20 positioned -1 78 -1 run function bd:game/perform_undo/_index_11_20
execute if score global undoStackHead matches 21..30 positioned -1 78 -1 run function bd:game/perform_undo/_index_21_30
execute if score global undoStackHead matches 31..40 positioned -1 78 -1 run function bd:game/perform_undo/_index_31_40
execute if score global undoStackHead matches 41..50 positioned -1 78 -1 run function bd:game/perform_undo/_index_41_50
execute if score global undoStackHead matches 51..60 positioned -1 78 -1 run function bd:game/perform_undo/_index_51_60
execute if score global undoStackHead matches 61..70 positioned -1 78 -1 run function bd:game/perform_undo/_index_61_70
execute if score global undoStackHead matches 71..80 positioned -1 78 -1 run function bd:game/perform_undo/_index_71_80
execute if score global undoStackHead matches 81..90 positioned -1 78 -1 run function bd:game/perform_undo/_index_81_90
execute if score global undoStackHead matches 91..100 positioned -1 78 -1 run function bd:game/perform_undo/_index_91_100

setblock -1 77 -1 redstone_block

scoreboard players operation global hitCone = @s hitCone

scoreboard players operation global hasArm = @s hasArm

scoreboard players operation global true_x = global char_set_x
scoreboard players operation global true_y = global char_set_y
scoreboard players operation global true_z = global char_set_z
scoreboard players operation global true_set_face = global char_set_face

scoreboard players operation global char_set_x = @s char_set_x
scoreboard players operation global char_set_y = @s char_set_y
scoreboard players operation global char_set_z = @s char_set_z
scoreboard players operation global char_set_face = @s faceDirection

scoreboard players remove global undoStackHead 1
execute if score global undoStackHead matches ..0 run scoreboard players set global undoStackHead 100

function bd:control/warp/warp_to_saved_coords/_go_undo

scoreboard players operation global char_set_x = global true_x
scoreboard players operation global char_set_y = global true_y
scoreboard players operation global char_set_z = global true_z
scoreboard players operation global char_set_face = global true_set_face

execute if score global hasArm matches 1 run tag @e[tag=player_char,type=area_effect_cloud] remove arm_disconnected
execute if score global hasArm matches 0 run tag @e[tag=player_char,type=area_effect_cloud] add arm_disconnected

title @a[tag=inControl] actionbar [""]

#kill @e[tag=player_model]
function bd:game/check_for_win