#execute as @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run execute at @s positioned ~ 255 ~ run setblock ~ ~ ~ minecraft:brown_shulker_box
execute as @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run execute at @s positioned ~ 255 ~ run setblock ~ ~ ~ minecraft:chest destroy
execute as @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run execute at @s positioned ~ 255 ~ run data modify block ~ ~ ~ Items append from entity @s SelectedItem
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=CobbleSpell] run data modify block ~ 255 ~ Items[0].tag.pages[4] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[4]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=GlassGen] run data modify block ~ 255 ~ Items[0].tag.pages[5] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[5]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=HasteSpell] run data modify block ~ 255 ~ Items[0].tag.pages[6] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[6]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=SlowFallSpell] run data modify block ~ 255 ~ Items[0].tag.pages[7] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[7]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=ResistSpell] run data modify block ~ 255 ~ Items[0].tag.pages[8] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[8]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=EscapeSpell] run data modify block ~ 255 ~ Items[0].tag.pages[9] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[9]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=LocateSpell] run data modify block ~ 255 ~ Items[0].tag.pages[10] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[10]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=HorseSpell] run data modify block ~ 255 ~ Items[0].tag.pages[11] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[11]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=WeatherSpell] run data modify block ~ 255 ~ Items[0].tag.pages[12] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[12]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=InvisSpell] run data modify block ~ 255 ~ Items[0].tag.pages[13] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[13]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=PortalSpell] run data modify block ~ 255 ~ Items[0].tag.pages[14] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[14]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=AnimalSpell] run data modify block ~ 255 ~ Items[0].tag.pages[15] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[15]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=ExpSpell] run data modify block ~ 255 ~ Items[0].tag.pages[16] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[16]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=BasicRevSpell] run data modify block ~ 255 ~ Items[0].tag.pages[31] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[31]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=ResurrectSpell] run data modify block ~ 255 ~ Items[0].tag.pages[32] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[32]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=ImbueSpell] run data modify block ~ 255 ~ Items[0].tag.pages[42] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[42]
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate,tag=RageSpell] run data modify block ~ 255 ~ Items[0].tag.pages[43] set from entity @e[name=BookCopy,limit=1,type=minecraft:armor_stand] HandItems[0].tag.pages[43]
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=CobbleSpell,tag=BookInHand] remove CobbleSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=GlassGen,tag=BookInHand] remove GlassGen
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=HasteSpell,tag=BookInHand] remove HasteSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=HasteUpgrade,tag=BookInHand] remove HasteUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=SlowFallSpell,tag=BookInHand] remove SlowFallSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=SlowfallUpgrade,tag=BookInHand] remove SlowfallUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=ResistSpell,tag=BookInHand] remove ResistSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=ResistUpgrade,tag=BookInHand] remove ResistUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=EscapeSpell,tag=BookInHand] remove EscapeSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=EscapeUpgrade,tag=BookInHand] remove EscapeUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=LocateSpell,tag=BookInHand] remove LocateSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=LocatorUpgrade,tag=BookInHand] remove LocatorUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=HorseSpell,tag=BookInHand] remove HorseSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=HorseUpgrade,tag=BookInHand] remove HorseUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=WeatherSpell,tag=BookInHand] remove WeatherSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=InvisSpell,tag=BookInHand] remove InvisSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=InvisUpgrade,tag=BookInHand] remove InvisUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=PortalSpell,tag=BookInHand] remove PortalSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=AnimalSpell,tag=BookInHand] remove AnimalSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=FarmUpgrade,tag=BookInHand] remove FarmUpgrade
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=ExpSpell,tag=BookInHand] remove ExpSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BasicRevSpell,tag=BookInHand] remove BasicRevSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BasicRevSpell,tag=BookInHand] remove ResurrectSpell

tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=ImbueSpell,tag=BookInHand] remove ImbueSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=RageSpell,tag=BookInHand] remove RageSpell
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookInHand] add SpellUpdateRemove
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookInHand] remove SpellUpdate
tag @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookInHand,tag=BookUpdate] add BookUpdate2
#execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run loot replace entity @p weapon.mainhand mine ~ 255 ~ air{drop_contents:true}
execute as @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},nbt=!{SelectedItem:{tag:{kyunewbook:1b,display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run function zzzzdonotuse:spell/updateold
execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run fill ~ 255 ~ ~ 255 ~ air destroy
execute as @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run item replace entity @s weapon.mainhand with air
execute as @a[tag=BookUpdate] run execute at @s positioned ~ 255 ~ run tp @e[distance=..8,sort=nearest,limit=1,nbt=!{Item:{id:"minecraft:chest"}}] @s
execute as @a[tag=BookUpdate] run execute at @s positioned ~ 255 ~ run kill @e[distance=..8,sort=nearest,limit=1,nbt={Item:{id:"minecraft:chest"}}]
#execute at @a[nbt={SelectedItem:{tag:{display:{Lore:["\"A book of spells\""]}}}},tag=BookUpdate] run setblock ~ 255 ~ air
tag @a[tag=BookUpdate2] remove BookUpdate
tag @a[tag=BookUpdate2] remove BookUpdate2