scoreboard players set @s AttackTimer 0
data merge block ~ ~ ~ {auto:0b}

execute as @e[type=armor_stand,name=CadeyrnFight] run scoreboard players operation @s KyuDummy = @s CadeyrnPlayers
tag @e[type=armor_stand,tag=CadeyrnOreStand] remove CadyOre
tag @e[type=armor_stand,tag=CadeyrnOreStand,limit=10,sort=random] add CadyOre
execute as @e[type=armor_stand,tag=CadeyrnOreStand,tag=CadyOre] run function zzzzdonotuse:misc/replacegoldblockcadeyrn
execute as @e[type=armor_stand,tag=CadeyrnOreStand,tag=CadyOre] run execute at @s run tp @s ~ ~1 ~
execute as @e[type=armor_stand,tag=CadeyrnOreStand,tag=CadyOre] run execute at @s run execute if block ~ ~1 ~ shroomlight run kill @s
function zzzzdonotuse:cadeyrn/attacks/deathanim/fillores
kill @e[type=armor_stand,tag=CadeyrnOreStand]

execute as @e[type=armor_stand,name=CadeyrnFight] run scoreboard players operation @s KyuDummy = @s CadeyrnPlayers
function zzzzdonotuse:cadeyrn/attacks/deathanim/spawnchests

tag @a remove ChestedCadeyrn
tag @a remove ChestMeCadeyrn

kill @e[type=armor_stand,tag=CadeyrnCheStand]
kill @e[type=armor_stand,tag=CadeyrnCheStand2]
kill @e[tag=DeathAnimLava]
tag @e[name=DayQ] add CadeyrnDefeated
kill @e[type=armor_stand,tag=IndolentParticle]
bossbar remove minecraft:cadeyrn

execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run execute store result block ~ ~ ~ ExitPortal.X int 1 run scoreboard players get @e[name=DayQ,limit=1,tag=CadeyrnDefeated] CadeyrnShopX
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run execute store result block ~ ~ ~ ExitPortal.Y int 1 run scoreboard players get @e[name=DayQ,limit=1,tag=CadeyrnDefeated] CadeyrnShopY
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run execute store result block ~ ~ ~ ExitPortal.Z int 1 run scoreboard players get @e[name=DayQ,limit=1,tag=CadeyrnDefeated] CadeyrnShopZ
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run data merge block ~ ~ ~ {ExactTeleport:1b}
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run clone ~ ~ ~ ~ ~ ~ ~-1 ~ ~
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run clone ~-1 ~ ~ ~ ~ ~ ~-1 ~1 ~
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~1 ~20 run clone ~-1 ~ ~ ~ ~ ~ ~-1 ~2 ~
execute at @e[type=minecraft:armor_stand,tag=CadeyrnRewStand] positioned ~ ~ ~ run fill ~-30 ~-3 ~-30 ~30 ~4 ~30 water replace minecraft:dried_kelp_block

execute at @e[type=minecraft:armor_stand,tag=NetherShopMid] positioned ~ 7 ~ run kill @e[type=item,distance=..30,tag=NetherShopText]
execute at @e[type=minecraft:armor_stand,tag=NetherShopMid] positioned ~ 7 ~ run kill @e[type=armor_stand,distance=..30,tag=NetherShopText]
execute at @e[type=minecraft:armor_stand,tag=NetherShopMid] positioned ~ 7 ~ run tp @e[type=slime,distance=..30,tag=ShopSlime] ~ ~-500 ~

execute at @e[type=minecraft:armor_stand,tag=NetherShopMid] positioned ~ 5 ~ run setblock ~ ~ ~ minecraft:structure_block[mode=load]{name:"suhc:nethershop",posX:-18,posZ:-16,posY:-5,rotation:"",mirror:NONE,mode:LOAD,ignoreEntities:0b} destroy
execute at @e[type=minecraft:armor_stand,tag=NetherShopMid] positioned ~ 5 ~ run setblock ~ ~1 ~ minecraft:redstone_block


scoreboard players set @e[type=armor_stand,name=CadeyrnFight] KyuDummy 0