execute if entity @e[type=text_display,tag=phantom_cultist_end_crystal] run schedule function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_homing 1t

# Homing Commands
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s anchored eyes facing entity @p[gamemode=survival] eyes positioned ^ ^ ^3 rotated as @s positioned ^ ^ ^4 facing entity @s eyes facing ^ ^-0.05 ^-1 positioned as @s run tp @s ^ ^ ^0.1 ~ ~
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 1.. run particle enchant ~ ~1 ~ 0.5 0.5 0.5 1 3
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 1.. run particle portal ~ ~1 ~ 0.5 0.5 0.5 1 3
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 1.. run scoreboard players remove @s phantom_cultist_end_crystal_timer 1

execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 280 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 260 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 240 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 220 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 200 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 180 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 160 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 140 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 120 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 100 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 80 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 60 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 40 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 20 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 0 run function kiwi2:custom_mobs_fx/phantom_cultist/phantom_cultist_text_update

execute as @e[type=text_display,tag=phantom_cultist_end_crystal,nbt=!{Passengers:[{}]}] run kill @s
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 0 run summon lightning_bolt ~ ~ ~
execute as @e[type=text_display,tag=phantom_cultist_end_crystal] at @s if score @s phantom_cultist_end_crystal_timer matches 0 run kill @s