execute if score game tutorial matches 1.. run tp @a -69.36 24.97 -38.92 65.10 40.42

execute at @e[type=falling_block,nbt={BlockState:{Name:"minecraft:black_concrete_powder"}},limit=1] positioned ~ ~-0.7 ~ run tp @p ~ ~ ~
kill @e[type=falling_block,nbt={BlockState:{Name:"minecraft:black_concrete_powder"}},limit=1]
execute at @e[type=falling_block,nbt={BlockState:{Name:"minecraft:white_concrete_powder"}},limit=1] positioned ~ ~-0.7 ~ run summon armor_stand ~ ~ ~ {NoGravity:1b,Invulnerable:1b,Marker:1b,Invisible:1b,PersistenceRequired:1b,DisabledSlots:4144959,ArmorItems:[{},{},{},{id:"minecraft:gold_block",Count:1b}],CustomName:"{\"text\":\"endlevel\"}"}
kill @e[type=falling_block,nbt={BlockState:{Name:"minecraft:white_concrete_powder"}},limit=1]

scoreboard players remove @e[scores={entitylife=1..}] entitylife 1
scoreboard players remove game entitylife 1
kill @e[scores={entitylife=0}]
execute as @e[name=turnparticles] at @s run tp @s ~ ~0.07 ~ ~-7 ~
execute as @e[name=turnparticles] at @s run particle dust 1 0.5 0 1 ^2 ^ ^ 0 0 0 0 3
execute as @e[name=turnparticles] at @s run particle dust 1 0.5 0 1 ^-2 ^ ^ 0 0 0 0 3
execute as @e[name=turnparticles] at @s run particle dust 1 0.5 0 1 ^ ^ ^2 0 0 0 0 3
execute as @e[name=turnparticles] at @s run particle dust 1 0.5 0 1 ^ ^ ^-2 0 0 0 0 3

execute if score game entitylife matches 0 if score game dimension matches 0 run give @p minecraft:carrot_on_a_stick{display:{Name:"{\"text\":\"Switch to YZW\",\"color\":\"gold\",\"bold\":\"true\",\"italic\":\"false\"}"},CustomModelData:1} 1
execute if score game entitylife matches 0 if score game dimension matches 1 run give @p minecraft:carrot_on_a_stick{display:{Name:"{\"text\":\"Switch to XYZ\",\"color\":\"red\",\"bold\":\"true\",\"italic\":\"false\"}"},CustomModelData:1} 1
execute if score game entitylife matches 0 if score game dimension matches 0 if score game level matches 6.. run give @p minecraft:carrot_on_a_stick{display:{Name:"{\"text\":\"Teleport to/Create Checkpoint\",\"color\":\"gold\",\"bold\":\"true\",\"italic\":\"false\"}"},CustomModelData:2} 1
execute if score game entitylife matches 0 run give @p minecraft:carrot_on_a_stick{display:{Name:"{\"text\":\"Restart Level\",\"color\":\"yellow\",\"bold\":\"true\",\"italic\":\"false\"}"},CustomModelData:4} 1
execute if score game entitylife matches 0 run give @p minecraft:carrot_on_a_stick{display:{Name:"{\"text\":\"Hub\",\"color\":\"white\",\"bold\":\"true\",\"italic\":\"false\"}"},CustomModelData:5} 1


execute store result score w display run data get entity @e[name=marker,limit=1] Pos[1]
scoreboard players operation w display /= 16 n

execute store result score @e[name=corner,limit=1] display run data get entity @e[name=corner,limit=1] Pos[2]
execute store result score @p display run data get entity @p Pos[2]
scoreboard players operation @p display -= @e[name=corner,limit=1] display
scoreboard players operation z display = @p display

execute store result score @e[name=corner,limit=1] display run data get entity @e[name=corner,limit=1] Pos[1]
execute store result score @p display run data get entity @p Pos[1]
scoreboard players operation @p display -= @e[name=corner,limit=1] display
scoreboard players operation y display = @p display

execute store result score @e[name=marker,limit=1] display run data get entity @e[name=marker,limit=1] Pos[0]
execute store result score @e[tag=currentcorner,limit=1] display run data get entity @e[tag=currentcorner,limit=1] Pos[0]
scoreboard players operation @e[name=marker,limit=1] display -= @e[tag=currentcorner,limit=1] display
scoreboard players operation x display = @e[name=marker,limit=1] display






execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] run scoreboard players reset @p checkpoint
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] run scoreboard players add game dimension 1
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] run effect give @p slowness 1000000 100 true
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] run effect give @p jump_boost 1000000 200 true
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] if score game dimension matches 2.. run scoreboard players set game dimension 0
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] at @p run playsound minecraft:block.beacon.ambient master @a ~ ~ ~ 1 2
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] at @p run summon armor_stand ~ ~ ~ {NoGravity:1b,Invulnerable:1b,Marker:1b,Invisible:1b,PersistenceRequired:1b,DisabledSlots:4144959,CustomName:"{\"text\":\"previouspos\"}"}
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] at @p run tp @e[name=previouspos] @p
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:1}}}] run function game:drawmaster

execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:3}}}] run function game:tutorialdialogue

execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:4}}}] run function game:startlevel
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:5}}}] run kill @e[name=checkpoint]
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:5}}}] run tp @p -1003 40 -16
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:5}}}] run scoreboard players set game gameactive 0
execute if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:5}}}] run clear @p

execute at @p if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:2}}}] run scoreboard players enable @p checkpoint
execute at @p if entity @p[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",Count:1b,tag:{CustomModelData:2}}}] run tellraw @a ["",{"text":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"},{"text":"[Place Checkpoint]","bold":true,"color":"gold","clickEvent":{"action":"run_command","value":"/trigger checkpoint add 1"}},{"text":" ","bold":true,"color":"gold"},{"text":"[TP to Checkpoint]","bold":true,"color":"gold","clickEvent":{"action":"run_command","value":"/trigger checkpoint add 2"}}]


execute if score @p checkpoint matches 1 at @p run function game:spawncheckpoint
execute if score @p checkpoint matches 2 if entity @e[name=checkpoint] at @p run function game:tptocheckpoint

scoreboard players set @p checkpoint 0

scoreboard players set @a rightclick 0


execute as @e[type=item] run data merge entity @s {PickupDelay:1,Item:{}}
tp @e[type=item] @p



execute if score game dimension matches 0 if score w display = w checkcoord run scoreboard players set exist checkcoord 1
execute unless score game dimension matches 0 run scoreboard players set exist checkcoord 0
execute unless score w display = w checkcoord run scoreboard players set exist checkcoord 0

execute if score exist checkcoord matches 1 run data merge entity @e[name=checkpoint,limit=1] {ArmorItems:[{},{},{},{id:"minecraft:iron_block",Count:1b}]}
execute if score exist checkcoord matches 0 run data merge entity @e[name=checkpoint,limit=1] {ArmorItems:[{},{},{},{}]}



scoreboard players operation x prox = x display
scoreboard players operation y prox = y display
scoreboard players operation z prox = z display
scoreboard players operation w prox = w display

scoreboard players operation x prox -= x checkcoord
scoreboard players operation y prox -= y checkcoord
scoreboard players operation z prox -= z checkcoord
scoreboard players operation w prox -= w checkcoord

scoreboard players operation x prox *= x prox
scoreboard players operation y prox *= y prox
scoreboard players operation z prox *= z prox
scoreboard players operation w prox *= w prox

scoreboard players set distance prox 0
scoreboard players operation distance prox += x prox
scoreboard players operation distance prox += y prox
scoreboard players operation distance prox += z prox
scoreboard players operation distance prox += w prox
scoreboard players operation distance prox *= 10000 n
scoreboard players set 32 n 32

scoreboard players set d prox 0

execute if entity @e[name=checkpoint] run function game:sqrt
scoreboard players remove d prox 1
scoreboard players operation d prox /= 100 n

scoreboard players operation 32 n -= d prox

execute store result bossbar minecraft:proximity value run scoreboard players get 32 n



execute unless entity @e[name=checkpoint] run bossbar set minecraft:proximity visible false
execute if entity @e[name=checkpoint] run bossbar set minecraft:proximity visible true
execute if entity @e[name=checkpoint] run bossbar set minecraft:proximity players @a











execute if score game gameactive matches 1 run title @a actionbar ["",{"text":"X: ","color":"red"},{"score":{"name":"x","objective":"display"},"color":"red"},{"text":" "},{"text":"Y: ","color":"green"},{"score":{"name":"y","objective":"display"},"color":"green"},{"text":" "},{"text":"Z: ","color":"blue"},{"score":{"name":"z","objective":"display"},"color":"blue"},{"text":" "},{"text":"W: ","color":"gold"},{"score":{"name":"w","objective":"display"},"color":"gold"}]

execute if score game level matches 1 at @e[name=corner] run particle dust 0.5 1 0.5 3 ~8 ~8 ~8 10 10 10 0 1
execute if score game level matches 2 at @e[name=corner] run particle dust 1 0.7 0 3 ~8 ~8 ~8 10 10 10 0 1
execute if score game level matches 3 at @e[name=corner] run particle dust 0 1 0.7 3 ~8 ~8 ~8 10 10 10 0 1
execute if score game level matches 4 at @e[name=corner] run particle dust 1 0 1 3 ~8 ~8 ~8 10 10 10 0 1
execute if score game level matches 5 at @e[name=corner] run particle end_rod ~8 ~8 ~8 10 10 10 0 50
execute if score game level matches 6 at @e[name=corner] run particle dust 1 0.7 0.5 3 ~8 ~8 ~8 10 10 10 0 3


execute at @e[name=endlevel] run particle dust 1 0.7 0 1 ~ ~1 ~ 0.3 0.5 0.3 0 3
execute at @e[name=checkpoint] if score exist checkcoord matches 1 run particle dust 1 0.5 0 1 ~ ~0.85 ~ 0.2 0.2 0.2 0 3
execute as @e[name=endlevel] at @s run tp @s ~ ~ ~ ~2 ~
execute as @e[name=checkpoint] at @s run tp @s ~ ~ ~ ~2 ~
execute at @p if entity @e[name=endlevel,distance=..0.5] run scoreboard players add game level 1
execute at @p if entity @e[name=endlevel,distance=..0.5] run playsound minecraft:entity.player.levelup block @a ~ ~ ~ 1 0.5
execute at @p if entity @e[name=endlevel,distance=..0.5] run data merge entity @e[name=endlevel,limit=1] {ArmorItems:[{},{},{},{}]}
execute at @p if entity @e[name=endlevel,distance=..0.5] if score game level matches ..7 run function game:startlevel
execute at @p if entity @e[name=endlevel,distance=..0.5] if score game level matches 8.. run function game:finish

execute as @e[name=rotary] at @s run tp @s ~ ~ ~ ~3 ~

execute as @p at @s if block ~ ~-0.1 ~ barrier run function game:restart


execute if entity @p[tag=!start] run tp @p -1003 40 -16
execute if entity @p[tag=!start] run effect give @p resistance 1000000 250 true
execute if entity @p[tag=!start] run effect give @p saturation 1000000 250 true
execute if entity @p[tag=!start] run spawnpoint @p -1003 40 -16
execute if entity @p[tag=!start] run scoreboard players set game gameactive 0
execute if entity @p[tag=!start] run scoreboard players set game level 1
execute if entity @p[tag=!start] run clear @p
execute if entity @p[tag=!start] run time set 6000
execute if entity @p[tag=!start] run kill @e[name=checkpoint]
execute if entity @p[tag=!start] run gamemode adventure @p
execute if entity @p[tag=!start] run tag @p add start



