########################################################################
#                                                                      #
#                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                                           #
#                                                                      #
########################################################################

effect clear @e[tag=webdeath]
tag @a remove webdeath
execute as @a[nbt={Inventory:[{tag:{spiderqueenhead:1b},Slot:103b}]}] at @s as @e[type=#spider_queen:arthropods,tag=!spider_queen,distance=..24] run attribute @s minecraft:generic.attack_damage base set 0
execute as @e[type=#spider_queen:arthropods,tag=!spider_queen] at @s unless entity @a[nbt={Inventory:[{tag:{spiderqueenhead:1b},Slot:103b}]},distance=..24] run attribute @s minecraft:generic.attack_damage base set 2.04
execute as @e[type=spider,tag=aj.spider_queen_ani.root,tag=!spiderqueen] at @s run function spider_queen:summon
execute as @e[type=spider,tag=aj.spider_queen_ani.root,tag=spiderqueen,tag=!dead] at @s run function spider_queen:brain

execute if entity @e[type=spider,tag=aj.spider_queen_ani,tag=spiderqueen,tag=!dead] run bossbar set minecraft:spiderqueen visible true
execute unless entity @e[type=spider,tag=aj.spider_queen_ani,tag=spiderqueen,tag=!dead] run bossbar set minecraft:spiderqueen visible false
kill @e[type=item,nbt={Item:{tag:{killme:1b}}}]

execute as @a[gamemode=!creative,nbt={Inventory:[{tag:{spiderqueenhead:1b},Slot:-106b}]}] run tag @s add sqhand
execute as @a[gamemode=!creative,nbt={SelectedItem:{tag:{spiderqueenhead:1b}}}] run tag @s add sqhand
execute as @a[tag=sqhand] if entity @s[nbt={SelectedItem:{tag:{spiderqueenhead:1b}}}] run gamemode adventure @s
execute as @a[tag=sqhand] unless entity @s[nbt={SelectedItem:{tag:{spiderqueenhead:1b}}}] unless entity @s[nbt={Inventory:[{tag:{spiderqueenhead:1b},Slot:-106b}]}] run function spider_queen:notholdsqhead
execute as @e[type=item,nbt={Item:{id:"minecraft:wooden_sword",Count:1b,tag:{Enchantments:[{id:"minecraft:bane_of_arthropods",lvl:5s}]}}}] at @s if entity @e[type=item,nbt={Item:{id:"minecraft:spider_eye",Count:8b}},distance=..5] unless entity @e[tag=spiderqueen] run function spider_queen:spawn