########################################################################
#                                                                      #
#                This Datapack was created by DinoBrik                 #
#                                                                      #
#     Channel:https://www.youtube.com/channel/UCIp3cX9qknsCvGuEHu6Z7qw #
#     Discord: https://discord.gg/XTAJhU9                              #
#                                                                      #
# -------------------------------------------------------------------- #
#                            DATAPACK INFO                             #
# -------------------------------------------------------------------- #
#                                                                      #
#          Author: DinoBrik                                            #
#          URL: Listed Above                                           #
#                                                                      #
########################################################################
scoreboard players operation @s spiderShowHealth = @s spiderRealHealth
scoreboard players operation @s spiderShowHealth -= Spider+ spiderMinusHealth
execute store result bossbar minecraft:spiderqueen value run scoreboard players get @s spiderShowHealth
execute store result score @s spiderRealHealth run data get entity @s Health

bossbar set minecraft:spiderqueen players @a[distance=..64]

execute unless entity @s[tag=dead] if entity @s[nbt={HurtTime:10s}] run playsound minecraft:entity.spider_queen.hit hostile @a ~ ~ ~ 0.8 1
execute if entity @s[nbt={Motion:[0.0,0.0,0.0]},tag=!scream,tag=!dead] run function spider_queen:idle
execute unless entity @s[nbt={Motion:[0.0,0.0,0.0]},tag=!scream,tag=!dead] run function spider_queen:walk
execute unless entity @s[tag=dead] positioned ^ ^ ^1 as @e[nbt={HurtTime:9s},distance=..1.2,type=!#spider_queen:arthropods] run function spider_queen:venom

execute unless entity @s[tag=dead] unless entity @s[tag=webed] positioned ^ ^ ^-3 if entity @p[distance=..1] run function web
execute unless entity @s[tag=dead] unless entity @e[type=#spider_queen:arthropods,distance=0.1..24] if entity @a[distance=..7] run function spider_queen:makespawn
execute unless entity @s[tag=dead] unless entity @s[tag=webed] if entity @p[distance=24..64] at @s run function spider_queen:web

execute if score @s[tag=!dead] spiderRealHealth matches ..823 run function spider_queen:death
