scoreboard objectives add mtp_high dummy

# Create marker
summon area_effect_cloud ~ ~ ~ {Tags:["unspellable","mt_spawn_spot","init","mt"],Duration:27,Rotation:[0F,90F]}
execute as @e[tag=mt_spawn_spot,tag=init,limit=1] run function olink:ch1/join_link

# ----- Hit check down -------
# Move and face down
scoreboard players set pos mtp_high 1
scoreboard players set @e[tag=mt_spawn_spot,tag=init,limit=1] mrcd_y0 -1000
tp @e[tag=mt_spawn_spot,tag=init,limit=1] ~ ~ ~ 0 90
execute as @e[tag=mt_spawn_spot,tag=init,limit=1] at @s run function items:obj/meteor_rain/mt_spawn_point/hit_check_down
# execute if entity @e[tag=mt_spawn_spot] run tellraw @a {"score":{"name":"pos","objective":"mtp_high"}}

# ----- Hit check up -------
# Move and face up
scoreboard players set @e[tag=mt_spawn_spot,tag=init,limit=1] mrcd_y0 1000
execute as @e[tag=mt_spawn_spot,tag=init,limit=1] at @s run tp @s ~ ~ ~ 0 -90
execute if score pos mtp_high matches ..-4 as @e[tag=mt_spawn_spot,tag=init,limit=1] run function items:obj/meteor_rain/mt_spawn_point/hit_up_pre
# execute if entity @e[tag=mt_spawn_spot] run tellraw @a {"score":{"name":"pos","objective":"mtp_high"}}

# ----- Find top -------
execute if score pos mtp_high matches -3.. as @e[tag=mt_spawn_spot,tag=init,limit=1] at @s run function items:obj/meteor_rain/mt_spawn_point/hit_top_find
# execute if entity @e[tag=mt_spawn_spot] run tellraw @a {"score":{"name":"pos","objective":"mtp_high"}}

# ----- Spawn check -----
execute as @e[tag=mt_spawn_spot,tag=init,limit=1] at @s run function items:obj/meteor_rain/mt_spawn_point/spawn_check

execute as @e[tag=mt_spawn_spot,tag=init,limit=1] at @s run tp @s ~ ~ ~ 0 90

# Clear tag
tag @e[tag=mt_spawn_spot,tag=init,limit=1] remove init

scoreboard objectives remove mtp_high
