#teleport to saves coords
execute if score @s controlState matches 1.. at @s run function bd:control/warp/warp_to_saved_coords/_go_player_only


#gimme an input stack
execute at @s rotated ~ ~ positioned ^ ^ ^1 unless entity @e[tag=input_base,distance=..2] run function bd:control/summon_input_stack


scoreboard players set @s controlState 0
scoreboard players set @s controlAnimate 0

clear @s
scoreboard players set @s inputCooldown 30

#go up high until we get in the minecart
#fill ~-1 253 ~-1 ~1 253 ~1 barrier
#fill ~-1 255 ~-1 ~1 255 ~1 barrier

#effects
effect give @s[tag=!noblind] blindness 5 100 true
effect give @s resistance 5 100 true
effect give @s slow_falling 5 100 true

scoreboard players add @s input 1
scoreboard players set @s[scores={input=5..}] input 0

execute at @s store result score @s active_x run data get entity @s Pos[0] 1
execute at @s store result score @s active_z run data get entity @s Pos[2] 1

#don't strafe away please
scoreboard players operation @s active_x -= global char_set_x
scoreboard players operation @s active_z -= global char_set_z
execute if entity @s[scores={active_x=7..}] run tp @s ~-7 ~ ~
execute if entity @s[scores={active_x=..-7}] run tp @s ~7 ~ ~
execute if entity @s[scores={active_z=7..}] run tp @s ~ ~ ~-7
execute if entity @s[scores={active_z=..-7}] run tp @s ~ ~ ~7

tp @s[scores={input=4}] ~ 100 ~ 180 45
gamemode adventure @s[gamemode=!adventure]

title @s subtitle ["",{"text":"Hold "},{"keybind":"key.use","color":"gold"},{"text":" to enter the game."}]
title @s title [""]
title @s actionbar [""]