#particles
execute as @s[scores={shulker_bosstime=3..4}] at @s run fill ~ ~-1 ~ ~ ~1 ~ air
execute as @s[scores={shulker_bosstime=3..4}] at @s run particle end_rod ~ ~-4 ~ 0 15 0 .06 100 force
execute as @s[scores={shulker_bosstime=3..30}] at @s run particle flash ~ ~-4 ~
execute as @s[scores={shulker_bosstime=3}] at @s run playsound block.beacon.activate ambient @a[distance=..30] ~ ~ ~ 1 .5

execute as @s[scores={shulker_bosstime=5}] at @s run data merge entity @s {Invulnerable:1b}
execute as @s[scores={shulker_bosstime=129..133}] at @s run data merge entity @s {Invulnerable:0b}

execute as @s[scores={shulker_bosstime=8..20}] at @s run setblock ~ ~-1 ~ air


#spirals
execute as @s[scores={shulker_bosstime=3}] at @s run execute align xz run summon minecraft:area_effect_cloud ~-1 ~51.5 ~.5 {Age:-2147483648,Duration:-1,WaitTime:-2147483648,Tags:["creatures_nonvariant","spellbound_spawnattempted","ultris_swirling_particle2","ultris_area_effect_cloud"]}
execute as @s[scores={shulker_bosstime=3}] at @s run execute align xz run summon minecraft:area_effect_cloud ~-1 ~52 ~.5 {Age:-2147483648,Duration:-1,WaitTime:-2147483648,Tags:["creatures_nonvariant","spellbound_spawnattempted","ultris_swirling_particle2","ultris_area_effect_cloud"]}

execute as @s[scores={shulker_bosstime=3}] at @s run execute align xz run summon minecraft:area_effect_cloud ~1 ~52.5 ~.5 {Age:-2147483648,Duration:-1,WaitTime:-2147483648,Tags:["creatures_nonvariant","spellbound_spawnattempted","ultris_swirling_particle","ultris_area_effect_cloud"]}
execute as @s[scores={shulker_bosstime=3}] at @s run execute align xz run summon minecraft:area_effect_cloud ~1 ~52 ~.5 {Age:-2147483648,Duration:-1,WaitTime:-2147483648,Tags:["creatures_nonvariant","spellbound_spawnattempted","ultris_swirling_particle","ultris_area_effect_cloud"]}



execute as @s[scores={shulker_bosstime=2}] at @s as @e[tag=shulkerstone_towerpos,sort=nearest,limit=1] at @s if data entity @s {HandItems: [{id: "minecraft:stick", Count: 1b, tag: {CustomModelData: 87005, display: {Lore: ['{"translate":""}', '{"translate":"A strange, yellowish key","color":"yellow"}', '{"translate":"","color":"yellow"}'], Name: '{"translate":"Endstone Key","color":"yellow"}'}, Enchantments: [{lvl: 1s, id: "minecraft:unbreaking"}]}}, {}]} run data merge entity @s {HandItems:[]}

#teleport them ENDSTONE BLOCKS!!!
execute as @s[scores={shulker_bosstime=60}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s run particle cloud ~ ~1 ~ .6 .2 .6 .1 10 force
execute as @s[scores={shulker_bosstime=60..80}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s run tp @s ~ ~.13 ~
execute as @s[scores={shulker_bosstime=80..95}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s run tp @s ~ ~.04 ~

execute as @s[scores={shulker_bosstime=80..150}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s facing entity @e[tag=shulkerstone,sort=nearest,limit=1] feet run tp @s ^ ^ ^.05
execute as @s[scores={shulker_bosstime=106..150}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s facing entity @e[tag=shulkerstone,sort=nearest,limit=1] feet run tp @s ^ ^ ^.15
execute as @s[scores={shulker_bosstime=120..150}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s facing entity @e[tag=shulkerstone,sort=nearest,limit=1] feet run tp @s ^ ^ ^.15
execute as @s[scores={shulker_bosstime=125..150}] at @s as @e[tag=shulkerstone_stone1,distance=..15] at @s facing entity @e[tag=shulkerstone,sort=nearest,limit=1] feet run tp @s ^ ^ ^.25



execute as @s[scores={shulker_bosstime=120}] at @s as @e[distance=..16,type=armor_stand,tag=shulkerstone_towerpos] at @s positioned ~ ~-3 ~ run function 1_splatus:ultris/other/boss_attacks/summon_spready2
execute as @s[scores={shulker_bosstime=122}] at @s as @e[distance=..16,type=armor_stand,tag=shulkerstone_towerpos] at @s positioned ~ ~-3 ~ run function 1_splatus:ultris/other/boss_attacks/summon_spready2
execute as @s[scores={shulker_bosstime=124}] at @s as @e[distance=..16,type=armor_stand,tag=shulkerstone_towerpos] at @s positioned ~ ~-3 ~ run function 1_splatus:ultris/other/boss_attacks/summon_spready2
execute as @s[scores={shulker_bosstime=126}] at @s as @e[distance=..16,type=armor_stand,tag=shulkerstone_towerpos] at @s positioned ~ ~-3 ~ run function 1_splatus:ultris/other/boss_attacks/summon_spready2
execute as @s[scores={shulker_bosstime=128}] at @s as @e[distance=..16,type=armor_stand,tag=shulkerstone_towerpos] at @s positioned ~ ~-3 ~ run function 1_splatus:ultris/other/boss_attacks/summon_spready2

#Bye decoration blocks!
execute as @s[scores={shulker_bosstime=130}] at @s run kill @e[tag=shulkerstone_stone1]
execute as @s[scores={shulker_bosstime=130}] at @s run particle end_rod ~ ~1 ~ .3 .3 .3 .2 100 force
#lightning
execute as @s[scores={shulker_bosstime=130}] at @s store result score @s ultris_count run gamerule doFireTick
execute as @s[scores={shulker_bosstime=130}] at @s run gamerule doFireTick false
execute as @s[scores={shulker_bosstime=130}] at @s run summon lightning_bolt ~ ~-5 ~
execute as @s[scores={shulker_bosstime=0..138}] at @s run data merge entity @s {Health:500f}
execute as @s[scores={shulker_bosstime=133}] at @s if score @s ultris_count matches 1 run gamerule doFireTick true
execute as @s[scores={shulker_bosstime=133}] at @s if score @s ultris_count matches 0 run gamerule doFireTick false
execute as @s[scores={shulker_bosstime=133}] at @s run scoreboard players reset @s ultris_count



#new blocks
execute as @s[scores={shulker_bosstime=130..300}] run function 1_splatus:ultris/shulker_stone/events/summon_blocks
