######################################################################################################## *** PHASE 15 - DEEP DARK *** ######################################################################################################



# Portal_in creation #

execute unless block 0 65 0 minecraft:end_gateway run tellraw @a {"text":"A portal has appeared !","italic":true,"color":"yellow"}
execute unless block 0 65 0 minecraft:end_gateway run playsound minecraft:entity.illusioner.cast_spell block @a 0 66 0
execute run fill 0 65 0 0 66 0 minecraft:end_gateway
execute run setblock 0 64 0 minecraft:bedrock



# Teleportation_in #

execute as @a at @s in minecraft:overworld if predicate simply_oneblock:portal run tellraw @a {"text":"Find the keys, open the vaults, beware of the Warden","italic":true,"color":"yellow"}
execute as @a at @s in minecraft:overworld if predicate simply_oneblock:portal run execute in simply_oneblock:phase_15 run tp @s 0 80 0



# Dungeon set #

execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_mm -1 70 -15
execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_mr -1 70 16
execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_ml -1 70 -46

execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_tm 30 70 -15
execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_tr 30 70 16
execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_tl 30 70 -46

execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_bm -32 70 -15
execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_br -32 70 16
execute as @a in simply_oneblock:phase_15 run execute if block -20 83 -31 minecraft:sculk run place template simply_oneblock:phase_15_bl -32 70 -46



# Vault set #

execute as @a in simply_oneblock:phase_15 run execute if block 52 79 -39 minecraft:red_concrete run setblock 52 79 -39 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block 39 84 -28 minecraft:red_concrete run setblock 39 84 -28 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block 9 85 -33 minecraft:red_concrete run setblock 9 85 -33 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block -19 77 -30 minecraft:red_concrete run setblock -19 77 -30 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block -22 77 -6 minecraft:red_concrete run setblock -22 77 -6 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block -25 84 22 minecraft:red_concrete run setblock -25 84 22 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block -7 79 35 minecraft:red_concrete run setblock -7 79 35 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block 14 77 39 minecraft:red_concrete run setblock 14 77 39 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block 46 78 34 minecraft:red_concrete run setblock 46 78 34 minecraft:vault{config: {key_item: {components: {"minecraft:custom_name": "Deep_Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}



# Vault removal #

execute as @a in simply_oneblock:phase_15 run execute if block 52 79 -39 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock 52 79 -39 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block 39 84 -28 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock 39 84 -28 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block 9 85 -33 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock 9 85 -33 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block -19 77 -30 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock -19 77 -30 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block -22 77 -6 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock -22 77 -6 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block -25 84 22 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock -25 84 22 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block -7 79 35 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock -7 79 35 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block 14 77 39 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock 14 77 39 minecraft:air
execute as @a in simply_oneblock:phase_15 run execute if block 46 78 34 minecraft:vault{server_data:{total_ejections_needed: 3}} run setblock 46 78 34 minecraft:air



# Final door set #

execute as @a in simply_oneblock:phase_15 run execute if block 30 79 0 minecraft:sculk if block 52 79 -39 minecraft:air if block 39 84 -28 minecraft:air if block 9 85 -33 minecraft:air if block -19 77 -30 minecraft:air if block -22 77 -6 minecraft:air if block -25 84 22 minecraft:air if block -7 79 35 minecraft:air if block 14 77 39 minecraft:air if block 46 78 34 minecraft:air run playsound minecraft:entity.lightning_bolt.thunder block @a 30 79 0

execute as @a in simply_oneblock:phase_15 run execute if block 30 79 0 minecraft:sculk if block 52 79 -39 minecraft:air if block 39 84 -28 minecraft:air if block 9 85 -33 minecraft:air if block -19 77 -30 minecraft:air if block -22 77 -6 minecraft:air if block -25 84 22 minecraft:air if block -7 79 35 minecraft:air if block 14 77 39 minecraft:air if block 46 78 34 minecraft:air run tellraw @a {"text":"The last gate awaits it's special key","italic":true,"color":"yellow"}

execute as @a in simply_oneblock:phase_15 run execute if block 30 79 0 minecraft:sculk if block 52 79 -39 minecraft:air if block 39 84 -28 minecraft:air if block 9 85 -33 minecraft:air if block -19 77 -30 minecraft:air if block -22 77 -6 minecraft:air if block -25 84 22 minecraft:air if block -7 79 35 minecraft:air if block 14 77 39 minecraft:air if block 46 78 34 minecraft:air run setblock 30 79 0 minecraft:vault[ominous=true,facing=west]{config: {key_item: {components: {"minecraft:custom_name": "Warden_Key"}, count: 1, id: "minecraft:ominous_trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute as @a in simply_oneblock:phase_15 run execute if block 30 79 0 minecraft:vault[ominous=true]{server_data:{total_ejections_needed: 3}} run fill 30 78 -1 30 81 1 minecraft:air



# Final key set #

execute as @a in simply_oneblock:phase_15 run execute if block 30 79 0 minecraft:vault[ominous=true]{config: {key_item: {components: {"minecraft:custom_name": "Warden_Key"}, count: 1, id: "minecraft:ominous_trial_key"}, loot_table: "simply_oneblock:trial_gate"}} if data entity @s Inventory[{id:"minecraft:trial_key"}] run give @s minecraft:ominous_trial_key[minecraft:custom_name=Warden_Key]

execute as @a in simply_oneblock:phase_15 run execute if block 30 79 0 minecraft:vault[ominous=true]{config: {key_item: {components: {"minecraft:custom_name": "Warden_Key"}, count: 1, id: "minecraft:ominous_trial_key"}, loot_table: "simply_oneblock:trial_gate"}} if data entity @s Inventory[{id:"minecraft:trial_key"}] run clear @s minecraft:trial_key



# Portal_out creation #

execute in simply_oneblock:phase_15 unless block 52 85 -7 minecraft:end_gateway unless block 40 78 0 minecraft:chest{LootTable:"simply_oneblock:deep_dark_trophy"} run tellraw @a {"text":"The portal has appeared !","italic":true,"color":"yellow"}

execute in simply_oneblock:phase_15 unless block 52 85 -7 minecraft:end_gateway unless block 40 78 0 minecraft:chest{LootTable:"simply_oneblock:deep_dark_trophy"} run playsound minecraft:entity.illusioner.cast_spell block @a 52 87 0

execute in simply_oneblock:phase_15 unless block 52 85 -7 minecraft:end_gateway unless block 40 78 0 minecraft:chest{LootTable:"simply_oneblock:deep_dark_trophy"} run execute in simply_oneblock:phase_15 run fill 52 85 -7 52 89 7 minecraft:end_gateway



# Teleportation_back #

execute as @a at @s in simply_oneblock:phase_15 if predicate simply_oneblock:portal if score fake_player ib_minedcount matches 6500 run execute in minecraft:overworld run fill 0 64 0 0 66 0 minecraft:air