scoreboard players set global exitEnabled 0

#progression
#area 1
execute if block 4 4 2 redstone_block if block 5 4 2 redstone_block if block 6 4 2 redstone_block if block 7 4 2 redstone_block run setblock 2 4 2 redstone_block
execute if block 4 4 3 redstone_block if block 5 4 3 redstone_block if block 6 4 3 redstone_block if block 7 4 3 redstone_block run setblock 2 4 3 redstone_block
execute if block 4 4 4 redstone_block if block 5 4 4 redstone_block if block 6 4 4 redstone_block if block 7 4 4 redstone_block run setblock 2 4 4 redstone_block
execute if block 4 4 5 redstone_block if block 5 4 5 redstone_block if block 6 4 5 redstone_block if block 7 4 5 redstone_block run setblock 2 4 5 redstone_block

#won game? all levels open, always
execute if score #fingermaps wonGame matches 1 run function bd:__open_all_levels

execute unless block 5 4 3 redstone_block run fill 9 81 15 11 81 16 grass_block
execute unless block 5 4 3 redstone_block run setblock 11 82 15 grass

#blocks to get further in hub
execute if block 2 4 2 redstone_block run setblock 21 80 16 piston[facing=up]
execute if block 2 4 3 redstone_block run setblock 11 81 20 piston[facing=up]
execute if block 2 4 4 redstone_block run fill 3 82 9 5 82 13 stripped_oak_wood
execute if block 2 4 5 redstone_block run setblock 3 83 26 ice
execute if block 2 4 5 redstone_block run setblock 24 80 12 smooth_stone

#level entry points
#area 1
scoreboard players set global setLevel 101
execute unless block 4 4 2 redstone_block positioned 22 81 20 run function bd:levels/entities/level_entry_face1
scoreboard players set global setLevel 102
execute unless block 5 4 2 redstone_block positioned 30 81 24 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 103
execute unless block 6 4 2 redstone_block positioned 29 81 30 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 104
execute unless block 7 4 2 redstone_block positioned 31 81 13 run function bd:levels/entities/level_entry_face3

#area 2
scoreboard players set global setLevel 201
execute if block 2 4 2 redstone_block unless block 4 4 3 redstone_block positioned 16 82 20 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 202
execute if block 2 4 2 redstone_block unless block 5 4 3 redstone_block positioned 10 81 16 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 203
execute if block 2 4 2 redstone_block unless block 6 4 3 redstone_block positioned 20 81 31 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 204
execute if block 2 4 2 redstone_block unless block 7 4 3 redstone_block positioned 21 81 25 run function bd:levels/entities/level_entry_face5

#area 3
scoreboard players set global setLevel 301
execute if block 2 4 3 redstone_block unless block 4 4 4 redstone_block positioned 25 82 29 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 302
execute if block 2 4 3 redstone_block unless block 5 4 4 redstone_block positioned 1 83 20 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 303
execute if block 2 4 3 redstone_block unless block 6 4 4 redstone_block positioned 7 83 16 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 304
execute if block 2 4 3 redstone_block unless block 7 4 4 redstone_block positioned 7 83 28 run function bd:levels/entities/level_entry_face1

#area 4
scoreboard players set global setLevel 401
execute if block 2 4 4 redstone_block unless block 4 4 5 redstone_block positioned 4 83 4 run function bd:levels/entities/level_entry_face1
scoreboard players set global setLevel 402
execute if block 2 4 4 redstone_block unless block 5 4 5 redstone_block positioned 10 83 11 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 403
execute if block 2 4 4 redstone_block unless block 6 4 5 redstone_block positioned 18 82 7 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 404
execute if block 2 4 4 redstone_block unless block 7 4 5 redstone_block positioned 17 81 0 run function bd:levels/entities/level_entry_face3

#title for final challenge
execute if block 2 4 5 redstone_block if score #fingermaps wonGame matches 0 run title @a subtitle ["",{"text":"Go For Gold","color":"white"}]
execute if block 2 4 5 redstone_block if score #fingermaps wonGame matches 0 run title @a title ["",{"text":"5-1","color":"yellow","bold":"false"}]

#final challenge
scoreboard players set global setLevel 999
execute if block 2 4 5 redstone_block positioned 29 83 2 run function bd:levels/entities/level_entry_face1

#make sure water doesn't mess with the concrete powder
execute positioned 0 80 0 run fill ~ ~ ~ ~31 ~ ~31 light_gray_concrete_powder replace light_gray_concrete