tp @e[name=corner,limit=1] 1001 32 10
kill @e[name=endlevel]
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace grass
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace oak_wall_sign
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace oak_sign
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace wall_torch
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace torch
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace snow
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace dead_bush
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air replace cactus
execute at @e[name=corner,limit=1] run fill ~-10 ~ ~ ~25 ~15 ~15 air
scoreboard players set game repeat 16
tag @e remove currentcorner
execute as @e[tag=corner] if score @s level = game level run tag @s add currentcorner
execute if score game dimension matches 0 as @e[name=marker] store result score @s y run data get entity @s Pos[1]
execute if score game dimension matches 0 as @e[name=marker] run scoreboard players operation @s y /= 16 n
execute if score game dimension matches 0 as @e[name=marker] run scoreboard players operation @s y *= 16 n
execute if score game dimension matches 0 as @e[name=ray] run tp @e[tag=currentcorner,limit=1]
execute if score game dimension matches 0 store result entity @e[name=ray,limit=1] Pos[1] double 1 run scoreboard players get @e[name=marker,limit=1] y

execute if score game dimension matches 1 as @e[name=ray] run tp @e[name=marker,limit=1]
execute if score game dimension matches 1 as @e[name=ray] at @s run tp ~ 0 32
execute if score game dimension matches 1 run scoreboard players operation game movecorner = game x_difference
execute if score game dimension matches 1 as @e[name=marker] store result score @s y run data get entity @s Pos[1]
execute if score game dimension matches 1 as @e[name=marker] run scoreboard players operation @s y /= 16 n
execute if score game dimension matches 1 run scoreboard players operation game movecorner -= @e[name=marker,limit=1] y
execute if score game dimension matches 1 run scoreboard players operation game tempcorner = game x_difference



scoreboard players set game entitylife 40
clear @p carrot_on_a_stick

execute if score game dimension matches 0 run function game:draw/draw3d
execute if score game dimension matches 1 run function game:draw/draw4d
tp @p @e[name=previouspos,limit=1]
execute if score game dimension matches 0 as @p at @s run tp 1001 ~ ~
execute if score game dimension matches 1 run function game:moveplayer
execute if score game dimension matches 0 run function game:moveplayer2
execute if score game dimension matches 0 run fill 1017 31 26 1000 53 9 barrier outline
execute if score game dimension matches 0 run fill 1001 48 10 1016 50 25 air replace barrier
execute if score game dimension matches 1 run clone 1001 47 10 1016 47 25 1001 48 10 filtered barrier
execute if score game dimension matches 1 run clone 1001 47 10 1016 47 25 1001 49 10 filtered barrier
execute if score game dimension matches 1 run clone 1001 47 10 1016 47 25 1001 50 10 filtered barrier
execute if score game levelstarted matches 1 run fill 1017 31 26 1000 48 9 air replace diamond_block
execute if score game dimension matches 0 run fill 1017 31 26 1000 48 9 white_concrete_powder replace gold_block
execute if score game dimension matches 1 run fill 1017 31 26 1000 48 9 air replace gold_block

execute if score game levelstarted matches 1 at @p run summon armor_stand ~ ~ ~ {NoGravity:1b,Invulnerable:1b,Marker:1b,Invisible:1b,NoBasePlate:0b,PersistenceRequired:1b,DisabledSlots:4144959,CustomName:"{\"text\":\"turnparticles\"}"}
execute at @p run scoreboard players set @e[name=turnparticles,sort=nearest,limit=1] entitylife 30
effect clear @p slowness
effect clear @p jump_boost
effect clear @p levitation
execute if score game levelstarted matches 1 at @p run playsound minecraft:block.end_portal_frame.fill master @a ~ ~ ~ 10 1.3
execute if score game levelstarted matches 1 at @p run playsound minecraft:block.end_portal_frame.fill master @a ~ ~ ~ 10 0.5
execute if score game levelstarted matches 1 at @p run playsound minecraft:block.beacon.activate master @a ~ ~ ~ 10 2
execute if score game levelstarted matches 1 at @p run playsound minecraft:block.ender_chest.open master @a ~ ~ ~ 3 0.7
execute if score game levelstarted matches 1 at @p run playsound minecraft:block.ender_chest.open master @a ~ ~ ~ 3 0.7
stopsound @a master minecraft:block.beacon.ambient


function game:timeset

execute if score red keyused matches 1 run fill 1017 31 26 1000 48 9 air replace red_terracotta
execute if score orange keyused matches 1 run fill 1017 31 26 1000 48 9 air replace orange_terracotta
execute if score yellow keyused matches 1 run fill 1017 31 26 1000 48 9 air replace yellow_terracotta
execute if score green keyused matches 1 run fill 1017 31 26 1000 48 9 air replace lime_terracotta
execute if score cyan keyused matches 1 run fill 1017 31 26 1000 48 9 air replace light_blue_terracotta
execute if score blue keyused matches 1 run fill 1017 31 26 1000 48 9 air replace blue_terracotta
execute if score purple keyused matches 1 run fill 1017 31 26 1000 48 9 air replace purple_terracotta
execute if score magenta keyused matches 1 run fill 1017 31 26 1000 48 9 air replace magenta_terracotta







kill @e[name=previouspos]












