#KyuDummy3 = CURRENT_HEALTH, KyuDummy2 = MAX_HEALTH
#KyuDummy4 = the scoreboard used for the bossbar's current value



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

#take the shulker's damage taken since last check
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
scoreboard players operation @s KyuDummy4 -= @s KyuDummy2
execute store result bossbar minecraft:corruptshulker value run scoreboard players get @s KyuDummy4

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