tag @s add FirstContact
effect give @e[type=shulker,tag=CorruptionShulker,limit=1,sort=nearest] glowing 999999 0 true




#one-time commands as the bossbar is set up
bossbar add corruptshulker {"text":"Corruption Core","color":"#FF9D0A"}
bossbar set minecraft:corruptshulker color purple
bossbar set minecraft:corruptshulker players @a[distance=..30]
bossbar set minecraft:corruptshulker max 100
bossbar set minecraft:corruptshulker value 100
scoreboard players set @s KyuDummy4 100



#reset the maxhp scoreboard
scoreboard players set @s KyuDummy2 900

#take the shulker's damage taken since last check
#KyuDummy3 = CURRENT_HEALTH, KyuDummy2 = MAX_HEALTH
execute as @s store result score @s KyuDummy3 run data get entity @s Health 1
scoreboard players operation @s KyuDummy2 -= @s KyuDummy3

#subtract the bossbar's health by the shulker's damage taken from above
#KyuDummy4 = the scoreboard used for the bossbar's current value
scoreboard players operation @s KyuDummy4 -= @s KyuDummy2
execute store result bossbar minecraft:corruptshulker value run scoreboard players get @s KyuDummy4

#heal cadeyrn
execute as @e[type=shulker,tag=CorruptionShulker,limit=1,sort=nearest] run data merge entity @s {Health:900f}