########################################################################################################## *** PHASE 8 - OCEAN *** #########################################################################################################



# 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 execute in simply_oneblock:phase_8 run tp @s 5 80 0



# Dungeon set #

execute as @a in simply_oneblock:phase_8 run execute if block 0 76 0 minecraft:water run place template simply_oneblock:phase_8 -1 70 -15



execute in simply_oneblock:phase_8 run execute if block 29 78 0 minecraft:water unless block 30 76 0 minecraft:clay run setblock 29 78 0 minecraft:vault[facing=west]{config: {key_item: {components: {"minecraft:custom_name": "Drowned Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute in simply_oneblock:phase_8 run execute if block 59 78 0 minecraft:water if block 59 77 0 barrier run setblock 59 78 0 minecraft:vault[facing=west]{config: {key_item: {components: {"minecraft:custom_name": "Guardian Key"}, count: 1, id: "minecraft:trial_key"}, loot_table: "simply_oneblock:trial_gate"}}

execute in simply_oneblock:phase_8 run execute if block 89 78 0 minecraft:water if block 89 77 0 barrier run setblock 89 78 0 minecraft:vault[facing=west,ominous=true]{config: {key_item: {components: {"minecraft:custom_name": "Elder Guardian Key"}, count: 1, id: "minecraft:ominous_trial_key"}, loot_table: "simply_oneblock:trial_gate"}}



execute in simply_oneblock:phase_8 run execute if block 29 78 0 minecraft:vault{server_data:{total_ejections_needed: 3}} run place template simply_oneblock:phase_8_drowned 29 70 -15
execute in simply_oneblock:phase_8 run execute if block 29 78 0 minecraft:vault{server_data:{total_ejections_needed: 3}} run playsound minecraft:entity.lightning_bolt.thunder block @a 29 78 0

execute in simply_oneblock:phase_8 run execute if block 59 78 0 minecraft:vault{server_data:{total_ejections_needed: 3}} run place template simply_oneblock:phase_8_guardian 59 70 -15
execute in simply_oneblock:phase_8 run execute if block 59 78 0 minecraft:vault{server_data:{total_ejections_needed: 3}} run playsound minecraft:entity.lightning_bolt.thunder block @a 59 78 0

execute in simply_oneblock:phase_8 run execute if block 89 78 0 minecraft:vault{server_data:{total_ejections_needed: 3}} run place template simply_oneblock:phase_8_boss 89 70 -15
execute in simply_oneblock:phase_8 run execute if block 89 78 0 minecraft:vault{server_data:{total_ejections_needed: 3}} run playsound minecraft:entity.lightning_bolt.thunder block @a 89 78 0



# Portal_out creation #

execute as @a in simply_oneblock:phase_8 unless block 105 77 2 minecraft:end_gateway if data entity @s Inventory[{id:"minecraft:heart_of_the_sea"}] run tellraw @a {"text":"A portal has appeared !","italic":true,"color":"yellow"}
execute as @a in simply_oneblock:phase_8 unless block 105 77 2 minecraft:end_gateway if data entity @s Inventory[{id:"minecraft:heart_of_the_sea"}] run playsound minecraft:entity.illusioner.cast_spell block @a 15 76 -2

execute as @a in simply_oneblock:phase_8 unless block 105 77 2 minecraft:end_gateway if data entity @s Inventory[{id:"minecraft:heart_of_the_sea"}] run execute in simply_oneblock:phase_8 run fill 103 77 -2 105 77 -2 minecraft:end_gateway
execute as @a in simply_oneblock:phase_8 unless block 105 77 2 minecraft:end_gateway if data entity @s Inventory[{id:"minecraft:heart_of_the_sea"}] run execute in simply_oneblock:phase_8 run fill 102 77 -1 106 77 2 minecraft:end_gateway
execute as @a in simply_oneblock:phase_8 unless block 105 77 2 minecraft:end_gateway if data entity @s Inventory[{id:"minecraft:heart_of_the_sea"}] run execute in simply_oneblock:phase_8 run fill 103 77 2 105 77 2 minecraft:end_gateway



# Teleportation_back #

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