import { ActionFormData, MessageFormData } from "mojang-minecraft-ui"
import { world } from "mojang-minecraft"




world.events.tick.subscribe(() => {
    try {
        for (let sender of world.getPlayers()) {
            let container = sender.getComponent("minecraft:inventory").container
            let item = container.getItem(sender.selectedSlot)
            
            if (item.getLore()[0].includes('Scope')) {
                sender.runCommand(`tag @s add Scope`)
                
            }
            
            if (item.getLore()[0].includes('Faster Reload')) {
                sender.runCommand(`scoreboard players set @s[scores={reload=10..}] reload 10`)
                
            }
            
            if (item.getLore()[0].includes('Stability')) {
                sender.runCommand(`scoreboard players set @s sway 0`)
                
            }
            
            if (item.getLore()[0].includes('Recoil')) {
                sender.runCommand(`tag @s add Recoil`)
                
            }
            
            if (item.getLore()[0].includes('Power')) {
                sender.runCommand(`tag @s add Power`)
                
            }
            
            if (item.getLore()[0].includes('Damage')) {
                sender.runCommand(`tag @s add Damage`)
            }
            
        }
        
    } catch { }
})





world.events.itemUseOn.subscribe(v => {
    let player = v.source
    
    let container = player.getComponent("minecraft:inventory").container
    
    let item = container.getItem(player.selectedSlot)
    
    if (player.dimension.getBlock(v.blockLocation).id == "wizardry:weapon_upgrade") {
        
        let formWeapon = new ActionFormData()
        formWeapon.title("Weapon Upgrade Station")
        
        
        if (player.hasTag("hasScope")) {
            formWeapon.button("Scope","textures/ui/yes")
        }
        if (!player.hasTag("hasScope")) {
            formWeapon.button("Scope","textures/ui/no")
        }
        
        
        if (player.hasTag("hasReload")) {
            formWeapon.button("Faster Reload","textures/ui/yes")
        }
        if (!player.hasTag("hasReload")) {
            formWeapon.button("Faster Reload","textures/ui/no")
        }
        
        if (player.hasTag("hasSway")) {
            formWeapon.button("Stability","textures/ui/yes")
        }
        
        if (!player.hasTag("hasSway")) {
            formWeapon.button("Stability","textures/ui/no")
        }
        
        
        if (player.hasTag("hasRecoil")) {
            formWeapon.button("Recoil","textures/ui/yes")
        }
        
        if (!player.hasTag("hasRecoil")) {
            formWeapon.button("Recoil","textures/ui/no")
        }
        
        if (player.hasTag("hasPower")) {
            formWeapon.button("Power","textures/ui/yes")
        }
        
        if (!player.hasTag("hasPower")) {
            formWeapon.button("Power","textures/ui/no")
        }
        
        if (player.hasTag("hasDamage")) {
            formWeapon.button("Damage","textures/ui/yes")
        }
        
        if (!player.hasTag("hasDamage")) {
            formWeapon.button("Damage","textures/ui/no")
        }
        
        
        formWeapon.show(player).then((response) => {
            
            if (response.selection == 0 && player.hasTag("hasScope")) {
                item.setLore([item.getLore()[0] + '\nScope'])
                
                container.setItem(player.selectedSlot, item)
                
                player.runCommand(`clear @s wizardry:scope 0 1`)
                
            }
            
            if (response.selection == 1 && player.hasTag("hasReload")) {
                item.setLore([item.getLore()[0] + '\nFaster Reload'])
                container.setItem(player.selectedSlot, item)
                player.runCommand(`clear @s wizardry:pouch_2 0 1`)
            }
            
            if (response.selection == 2 && player.hasTag("hasSway")) {
                item.setLore([item.getLore()[0] + '\nStability'])
                container.setItem(player.selectedSlot, item)
                player.runCommand(`clear @s wizardry:leather_strips 0 5`)
            }
                
                if (response.selection == 3 && player.hasTag("hasRecoil")) {
                item.setLore([item.getLore()[0] + '\nRecoil'])
                container.setItem(player.selectedSlot, item)
                player.runCommand(`clear @s iron_ingot 0 3`)
            }
            
            if (response.selection == 4 && player.hasTag("hasPower")) {
                item.setLore([item.getLore()[0] + '\nPower'])
                container.setItem(player.selectedSlot, item)
                player.runCommand(`clear @s iron_ingot 0 5`)
            }
            
            if (response.selection == 5 && player.hasTag("hasDamage")) {
                item.setLore([item.getLore()[0] + '\nDamage'])
                container.setItem(player.selectedSlot, item)
                player.runCommand(`clear @s netherite_scrap 0 1`)
            }
        })
    }
})




world.events.beforeItemUse.subscribe(data => {
    
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:alchemy_journal") {
        
      ui(player)
    }
})



function ui(player) {
    let form = new ActionFormData()
        form.title("Alchemy Journal") 
        
    
        form.button(`Alchemy Basics`,`textures/alchemy/alchemy_misc/alchemy_symbole`) // Button 1 Text
        form.button("Ingredient Research",`textures/alchemy/larfor_berrys`) // Button 2 Text
        


        form.show(player).then((response) => {
            if(response.selection == 0) return page2(player)
            
            
            if (response.selection == 1) return page3(player)
        })
    }



function page2(player) {
    let form2 = new ActionFormData()
    
        form2.title("Basics of Alchemy")
        
        form2.button(`Alchemists Equipment`,`textures/items/pamobile/wizardry_mortar_and_pestle`)
        
        form2.button(`back`)

        
        form2.show(player).then((response) => {  
            if (response.selection === 1) return ui(player)
        })
    }
    
    
function page3(player) {
    let form3 = new ActionFormData()
    
        form3.title("Ingredient Research")

        if (player.hasTag("ingredient1")) {
            form3.button(`Larfor Berrys`,`textures/alchemy/larfor_berrys`) 
        }
        else {
            if (!player.hasTag("ingredient1")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient2")) {
            form3.button(`Death Cap`,`textures/alchemy/death_cap`) 
        }
        else {
            if (!player.hasTag("ingredient2")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        if (player.hasTag("ingredient3")) {
            form3.button(`4 Leaf Clover`,`textures/alchemy/4_leaf_clover`) 
        }
        else {
            if (!player.hasTag("ingredient3")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient4")) {
            form3.button(`Wolfsbane`,`textures/alchemy/wolfsbane_pedal`) 
        }
        else {
            if (!player.hasTag("ingredient4")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        

        
        if (player.hasTag("ingredient5")) {
            form3.button(`Adders Fork`,`textures/alchemy/adders_fork_leaf`) 
        }
        else {
            if (!player.hasTag("ingredient5")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient6")) {
            form3.button(`Alihostly`,`textures/alchemy/alihosty_leaf`) 
        }
        else {
            if (!player.hasTag("ingredient6")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient7")) {
            form3.button(`Salamander Foot`,`textures/alchemy/salamander_foot`) 
        }
        else {
            if (!player.hasTag("ingredient7")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient8")) {
            form3.button(`Ambulan`,`textures/alchemy/ambulan_head`) 
        }
        else {
            if (!player.hasTag("ingredient8")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient9")) {
            form3.button(`Asphodel`,`textures/alchemy/asphodel_head`) 
        }
        else {
            if (!player.hasTag("ingredient9")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        if (player.hasTag("ingredient10")) {
            form3.button(`Boom Berry`,`textures/alchemy/boom_berrys`) 
        }
        else {
            if (!player.hasTag("ingredient10")) {
                form3.button('Unknown',`textures/alchemy/alchemy_misc/unknown`)
            }
        }
        
        
        

        
        form3.show(player).then((response) => {
            if (response.selection === 0 && player.hasTag("ingredient1")) return page4(player)
            
            else if (response.selection === 1 && player.hasTag("ingredient2")) return page5(player)
            
            else if (response.selection === 2 && player.hasTag("ingredient3")) return page6(player)
            
            
            else if (response.selection === 3 && player.hasTag("ingredient4")) return page7(player)
            
            
            else if (response.selection === 4 && player.hasTag("ingredient5")) return page8(player)
            
            
            else if (response.selection === 5 && player.hasTag("ingredient6")) return page9(player)
            
            
            else if (response.selection === 6 && player.hasTag("ingredient7")) return page10(player)
            
            
            else if (response.selection === 7 && player.hasTag("ingredient8")) return page11(player)
            
            
            else if (response.selection === 8 && player.hasTag("ingredient9")) return page12(player)
            
            
            else if (response.selection === 9 && player.hasTag("ingredient10")) return page13(player)
            
            
            
            
        })
}
    

function page4(player) {
    
    let form4 = new ActionFormData()
    
        form4.title("Larfor Berrys")
        
        if (!player.hasTag("ingredientLearned1")) {
        
        form4.body("Larfor berrys are sweet with a chilly after taste.\n\nProperties\n1. Cold\n2. Unknown\n")
        }

        
        if (player.hasTag("ingredientLearned1")) {
            
            form4.body("Larfor berrys are sweet with a chilly after taste.\n\nProperties\n1. Cold\n2. Rids of slowness, the berrys seem to take around 15 seconds until they take affect")
        }

            
        
        form4.button("Picked from larfor bushes",`textures/alchemy/larfor_bush_stage_2`)
        
        form4.button("back")
        
        form4.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page4(player)
            
            
        })
}




function page5(player) {
    
    let form5 = new ActionFormData()
    
        form5.title("Death Cap")
        
        
        form5.body("Death Caps are deadly poisonous.\n\nProperties\n1. Deadly Poisonous")

            
        
        form5.button("Can be found growing in forests",`textures/alchemy/death_cap`)
        
        form5.button("back")
        
        form5.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page5(player)
            
            
        })
}
            
            
            
function page6(player) {
    
    let form6 = new ActionFormData()
    
        form6.title("4 Leaf Clover")
        
        
        form6.body("4 leaf clovers seem to sway traders into making better trades with me.\n\nProperties\n1. Makes trades cheaper")

            
        
        form6.button("Can be found growing in forests",`textures/alchemy/4_leaf_clover`)
        
        form6.button("back")
        
        form6.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page6(player)
            
            
        })
}


function page7(player) {
    
    let form7 = new ActionFormData()
    
        form7.title("Wolfsbane")
        
        
        form7.body("Makes wolves within the vicinity calm.\n\nProperties\n1. Calms Wolves")

            
        
        form7.button("Can be found growing in forests",`textures/alchemy/wolfsbane`)
        
        form7.button("back")
        
        form7.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page7(player)
            
            
        })
}


function page8(player) {
    
    let form8 = new ActionFormData()
    
        form8.title("Adders Fork")
        
        
        form8.body("Has strong healing properties.\n\nProperties\n1. Increases duration\n2. Instant Health\n3. Regeneration")

            
        
        form8.button("Can be found growing in forests",`textures/alchemy/adders_fork`)
        
        form8.button("back")
        
        form8.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page8(player)
            
            
        })
}


function page9(player) {
    
    let form9 = new ActionFormData()
    
        form9.title("Alihostly")
        
        
        form9.body("Causes uncontrollable laughing.\n\nProperties\n1. Uncontrollable Laughter")

            
        
        form9.button("Can be found growing in forests",`textures/alchemy/alihosty`)
        
        form9.button("back")
        
        form9.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page9(player)
            
            
        })
}



function page10(player) {
    
    let form10 = new ActionFormData()
    
        form10.title("Salamander Foot")
        
        if (!player.hasTag("ingredientLearned7")) {
        
        form10.body("Belonged to a Marvelous creature with great fire related properties.\n\nProperties\n1. Heat\n2. Unknown\n")
        }

        
        if (player.hasTag("ingredientLearned7")) {
            
            form10.body("Marvelous creature with great fire related properties.\n\nProperties\n1. Heat\n2. Fire resistance")
        }
            
        
        form10.button("Obtained from a salamander.",`textures/alchemy/salamander_foot`)
        
        form10.button("back")
        
        form10.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page10(player)
            
            
        })
}



function page11(player) {
    
    let form11 = new ActionFormData()
    
        form11.title("Ambulan")
        
        
        form11.body("Puts the person to sleep\n\nProperties\n1. Sleepiness")

            
        
        form11.button("Can be found growing in forests",`textures/alchemy/ambulan`)
        
        form11.button("back")
        
        form11.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page11(player)
            
            
        })
}


function page12(player) {
    
    let form12 = new ActionFormData()
    
        form12.title("Asphodel")
        
        
        form12.body("Causes wither\n\nProperties\n1. Wither")

            
        
        form12.button("Can be found growing in forests",`textures/alchemy/asphodel`)
        
        form12.button("back")
        
        form12.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page12(player)
            
            
        })
}


function page13(player) {
    
    let form13 = new ActionFormData()
    
        form13.title("Boom Berry")
        
        
        form13.body("Gives absorption\n\nProperties\n1. Absorption")

            
        
        form13.button("Can be found growing in forests",`textures/alchemy/boom_berry_bush_stage_4`)
        
        form13.button("back")
        
        form13.show(player).then((response) => {
            
            if (response.selection === 1) return ui(player)
            
            if (response.selection === 0) return page13(player)
            
            
        })
}




//Spell Books

world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_1") {
        
      spell1(player)
    }
})
    
    
function spell1(player) {
    let form88 = new ActionFormData()
        form88.title("Mythic Dart")
        form88.body("Element: §dPure§r\n\nRarity: Common\n\nType: Projectile\n\nDamage: 1/2 a Heart\n\nCooldown: None\n\nSpecials: None")
        
        if (!player.hasTag("spell1")) {
            form88.button('Learn')
            
        }
        
        if (player.hasTag("spell1")) {
            form88.button('Learned')
        }
    
        
        form88.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell 1`)
        })
    }

//Spell 2

world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_2") {
        
      spell2(player)
    }
})
    
    
function spell2(player) {
    let form89 = new ActionFormData()
        form89.title("Ice Shard")
        form89.body("Element: §bCold§r\n\nRarity: §aUncommon§r\n\nType: Projectile\n\nDamage: 2 Hearts\n\nCooldown: None\n\nSpecials: Slowness")
        
        if (!player.hasTag("spell2")) {
            form89.button('Learn')
            
        }
        
        if (player.hasTag("spell2")) {
            form89.button('Learned')
        }
    
        
        form89.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell2 1`)
        })
}
    
    
world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_3") {
        
      spell3(player)
    }
})
    
    
function spell3(player) {
    let form91 = new ActionFormData()
        form91.title("Fire Bolt")
        form91.body("Element: §5Heat§r\n\nRarity: §aUncommon§r\n\nType: Projectile\n\nDamage: 2 Hearts\n\nCooldown: None\n\nSpecials: Sets Victim On Fire")
        
        if (!player.hasTag("spell3")) {
            form91.button('Learn')
            
        }
        
        if (player.hasTag("spell3")) {
            form91.button('Learned')
        }
    
        
        form91.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell3 1`)
        })
}


world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_4") {
        
      spell4(player)
    }
})


    
function spell4(player) {
    let form92 = new ActionFormData()
        form92.title("Lightning Bolt")
        form92.body("Element: §eElectric§r\n\nRarity: §1Rare§r\n\nType: Summon\n\nDamage: 2 Hearts\n\nCooldown: None\n\nSpecials: Summons a Bolt of Lightning")
        
        if (!player.hasTag("spell4")) {
            form92.button('Learn')
            
        }
        
        if (player.hasTag("spell4")) {
            form92.button('Learned')
        }
    
        
        form92.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell4 1`)
        })
}
    




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_5") {
        
      spell5(player)
    }
})


    
function spell5(player) {
    let form93 = new ActionFormData()
        form93.title("Storm Call")
        form93.body("Element: §1Water§r\n\nRarity: §5Epic§r\n\nType: World\n\nDamage: 0 Hearts\n\nCooldown: None\n\nSpecials: Summons a Storm")
        
        if (!player.hasTag("spell5")) {
            form93.button('Learn')
            
        }
        
        if (player.hasTag("spell5")) {
            form93.button('Learned')
        }
    
        
        form93.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell5 1`)
        })
}
    

world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_6") {
        
      spell6(player)
    }
})


    
function spell6(player) {
    let form94 = new ActionFormData()
        form94.title("Telekinesis")
        form94.body("Element: §5Pure§r\n\nRarity: §1Rare§r\n\nType: World\n\nDamage: 0 Hearts\n\nCooldown: None\n\nSpecials: Pulls items to the caster within 10 blocks away")
        
        if (!player.hasTag("spell6")) {
            form94.button('Learn')
            
        }
        
        if (player.hasTag("spell6")) {
            form94.button('Learned')
        }
    
        
        form94.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell6 1`)
        })
}




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_7") {
        
      spell7(player)
    }
})


    
function spell7(player) {
    let form95 = new ActionFormData()
        form95.title("Lightning Carnage")
        form95.body("Element: §eElectric§r\n\nRarity: §6Legendary§r\n\nType: World\n\nDamage: Up to 5 hearts with fire damage\n\nCooldown: 25 Seconds\n\nSpecials: Summons a bolt of lightning at all entitys within 30 blocks")
        
        if (!player.hasTag("spell7")) {
            form95.button('Learn')
            
        }
        
        if (player.hasTag("spell7")) {
            form95.button('Learned')
        }
    
        
        form95.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell7 1`)
        })
}
    
    
    
    
world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_8") {
        
      spell8(player)
    }
})


    
function spell8(player) {
    let form96 = new ActionFormData()
        form96.title("Levitation")
        form96.body("Element: §5Pure§r\n\nRarity: §aUncommon§r\n\nType: World\n\nDamage: None\n\nCooldown: None\n\nSpecials: When looking down while casted will cause the caster to levitate")
        
        if (!player.hasTag("spell8")) {
            form96.button('Learn')
            
        }
        
        if (player.hasTag("spell8")) {
            form96.button('Learned')
        }
    
        
        form96.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell8 1`)
        })
}



world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_9") {
        
      spell9(player)
    }
})


    
function spell9(player) {
    let form97 = new ActionFormData()
        form97.title("Blackhole")
        form97.body("Element: §1Astrology§r\n\nRarity: §6Legendary§r\n\nType: World\n\nDamage: 1 Heart Per Second\n\nCooldown: 100 Seconds\n\nSpecials: Pulls in entitys within 30 blocks")
        
        if (!player.hasTag("spell9")) {
            form97.button('Learn')
            
        }
        
        if (player.hasTag("spell9")) {
            form97.button('Learned')
        }
    
        
        form97.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell9 1`)
        })
}




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_10") {
        
      spell10(player)
    }
})


    
function spell10(player) {
    let form98 = new ActionFormData()
        form98.title("Ice Golem")
        form98.body("Element: §bCold§r\n\nRarity: §6Legendary§r\n\nType: Summon\n\nDamage: Up to 5 Hearts with fire damage\n\nCooldown: 100 Seconds\n\nSpecials: Summons a golem made of ice and snow")
        
        if (!player.hasTag("spell10")) {
            form98.button('Learn')
            
        }
        
        if (player.hasTag("spell10")) {
            form98.button('Learned')
        }
    
        
        form98.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell10 1`)
        })
}




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_11") {
        
      spell11(player)
    }
})


    
function spell11(player) {
    let form99 = new ActionFormData()
        form99.title("Mage Light")
        form99.body("Element: §5Pure§r\n\nRarity: §aUncommon§r\n\nType: Summon\n\nDamage: None\n\nCooldown: None Seconds\n\nSpecials: Summons a ball of light")
        
        if (!player.hasTag("spell11")) {
            form99.button('Learn')
            
        }
        
        if (player.hasTag("spell11")) {
            form99.button('Learned')
        }
    
        
        form99.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell11 1`)
        })
}



world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_12") {
        
      spell12(player)
    }
})


    
function spell12(player) {
    let form103 = new ActionFormData()
        form103.title("Fireball")
        form103.body("Element: §5Heat§r\n\nRarity: §1Rare§r\n\nType: Projectile\n\nDamage: 3 Hearts\n\nCooldown: None Seconds\n\nSpecials: Sets fire")
        
        if (!player.hasTag("spell12")) {
            form103.button('Learn')
            
        }
        
        if (player.hasTag("spell12")) {
            form103.button('Learned')
        }
    
        
        form103.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell12 1`)
        })
}




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_13") {
        
      spell13(player)
    }
})


    
function spell13(player) {
    let form104 = new ActionFormData()
        form104.title("Healing Sigil")
        form104.body("Element: §5Pure§r\n\nRarity: §5Epic§r\n\nType: Summon\n\nDamage: None\n\nCooldown: 40 Seconds\n\nSpecials: Heals entitys within it")
        
        if (!player.hasTag("spell13")) {
            form104.button('Learn')
            
        }
        
        if (player.hasTag("spell13")) {
            form104.button('Learned')
        }
    
        
        form104.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell13 1`)
        })
}




//Spell 14

world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_14") {
        
      spell14(player)
    }
  })

function spell14(player) {
    let form100 = new ActionFormData()
        form100.title("Mythic Beam")
        form100.body("Element: §5Pure§r\n\nRarity: §5Epic§r\n\nType: Beam\n\nDamage: 4 Hearts Per Second\n\nCooldown: None\n\nSpecials: None")
        
        if (!player.hasTag("spell14")) {
            form100.button('Learn')
            
        }
        
        if (player.hasTag("spell14")) {
            form100.button('Learned')
        }
    
        
        form100.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell14 1`)
        })
}



world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_15") {
        
      spell15(player)
    }
  })

function spell15(player) {
    let form106 = new ActionFormData()
        form106.title("Frostbite")
        form106.body("Element: §bCold§r\n\nRarity: §1Rare§r\n\nType: Effect\n\nDamage: wither for 5 seconds\n\nCooldown: None\n\nSpecials: Gives slowness for 20 seconds")
        
        if (!player.hasTag("spell15")) {
            form106.button('Learn')
            
        }
        
        if (player.hasTag("spell15")) {
            form106.button('Learned')
        }
    
        
        form106.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell15 1`)
        })
}



world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_16") {
        
      spell16(player)
    }
  })

function spell16(player) {
    let form107 = new ActionFormData()
        form107.title("Mind Control")
        form107.body("Element: §5Pure§r\n\nRarity: §5Epic§r\n\nType: Control\n\nDamage: None\n\nCooldown: None\n\nSpecials: Makes any entity fight any entity besides the caster")
        
        if (!player.hasTag("spell16")) {
            form107.button('Learn')
            
        }
        
        if (player.hasTag("spell16")) {
            form107.button('Learned')
        }
    
        
        form107.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell16 1`)
        })
}




//Spell 17

world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_17") {
        
      spell17(player)
    }
  })

function spell17(player) {
    let form90 = new ActionFormData()
        form90.title("Flamethrower")
        form90.body("Element: §5Heat§r\n\nRarity: §5Epic§r\n\nType: Beam\n\nDamage: 1 1/2 Hearts Per Second\n\nCooldown: None\n\nSpecials: Sets opponents on fire")
        
        if (!player.hasTag("spell17")) {
            form90.button('Learn')
            
        }
        
        if (player.hasTag("spell17")) {
            form90.button('Learned')
        }
    
        
        form90.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell17 1`)
        })
}




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_18") {
        
      spell18(player)
    }
  })

function spell18(player) {
    let form108 = new ActionFormData()
        form108.title("Mythic Shield")
        form108.body("Element: §5Pure§r\n\nRarity: §1Rare§r\n\nType: Self\n\nDamage: None\n\nCooldown: None\n\nSpecials: Pushes back and blocks entitys")
        
        if (!player.hasTag("spell18")) {
            form108.button('Learn')
            
        }
        
        if (player.hasTag("spell18")) {
            form108.button('Learned')
        }
    
        
        form108.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell18 1`)
        })
}






world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_19") {
        
      spell19(player)
    }
  })

function spell19(player) {
    let form109 = new ActionFormData()
        form109.title("Mythic Force Field")
        form109.body("Element: §5Pure§r\n\nRarity: §5Epic§r\n\nType: Area\n\nDamage: None\n\nCooldown: 75 Seconds\n\nSpecials: Protects caster from entitys within a field of pure magic")
        
        if (!player.hasTag("spell19")) {
            form109.button('Learn')
            
        }
        
        if (player.hasTag("spell19")) {
            form109.button('Learned')
        }
    
        
        form109.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell19 1`)
        })
}




world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_20") {
        
      spell20(player)
    }
  })

function spell20(player) {
    let form110 = new ActionFormData()
        form110.title("Poison Dart")
        form110.body("Element: §5Pure§r\n\nRarity: §aUncommon§r\n\nType: Projectile\n\nDamage: 1 Heart\n\nCooldown: None\n\nSpecials: Gives target posion upon hit")
        
        if (!player.hasTag("spell20")) {
            form110.button('Learn')
            
        }
        
        if (player.hasTag("spell20")) {
            form110.button('Learned')
        }
    
        
        form110.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell20 1`)
        })
}





world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_21") {
        
      spell21(player)
    }
  })

function spell21(player) {
    let form111 = new ActionFormData()
        form111.title("Mythic Pulse")
        form111.body("Element: §5Pure§r\n\nRarity: §5Epic§r\n\nType: Projectile and Area\n\nDamage: 4 Hearts\n\nCooldown: None\n\nSpecials: Emits a strong area attack on hit")
        
        if (!player.hasTag("spell21")) {
            form111.button('Learn')
            
        }
        
        if (player.hasTag("spell21")) {
            form111.button('Learned')
        }
    
        
        form111.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell21 1`)
        })
}





world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_22") {
        
      spell22(player)
    }
  })

function spell22(player) {
    let form112 = new ActionFormData()
        form112.title("Frost Ray")
        form112.body("Element: §bCold§r\n\nRarity: §5Epic§r\n\nType: Beam\n\nDamage: 2 1/2 Hearts\n\nCooldown: None\n\nSpecials: Causes slowness")
        
        if (!player.hasTag("spell22")) {
            form112.button('Learn')
            
        }
        
        if (player.hasTag("spell22")) {
            form112.button('Learned')
        }
    
        
        form112.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell22 1`)
        })
}





world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_23") {
        
      spell23(player)
    }
  })

function spell23(player) {
    let form113 = new ActionFormData()
        form113.title("Teleport")
        form113.body("Element: §5Pure§r\n\nRarity: §1Rare§r\n\nType: Projectile\n\nDamage: None\n\nCooldown: 40 Seconds\n\nSpecials: None")
        
        if (!player.hasTag("spell23")) {
            form113.button('Learn')
            
        }
        
        if (player.hasTag("spell23")) {
            form113.button('Learned')
        }
    
        
        form113.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell23 1`)
        })
}





world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_24") {
        
      spell24(player)
    }
  })

function spell24(player) {
    let form114 = new ActionFormData()
        form114.title("Mythic Armor")
        form114.body("Element: §5Pure§r\n\nRarity: §6Legendary§r\n\nType: Self\n\nDamage: None\n\nCooldown: None\n\nSpecials: None")
        
        if (!player.hasTag("spell24")) {
            form114.button('Learn')
            
        }
        
        if (player.hasTag("spell24")) {
            form114.button('Learned')
        }
    
        
        form114.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell24 1`)
        })
}





world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_25") {
        
      spell25(player)
    }
  })

function spell25(player) {
    let form115 = new ActionFormData()
        form115.title("Meteor")
        form115.body("Element: §1Astrology§r\n\nRarity: §5Epic§r\n\nType: Area\n\nDamage: Depends on range\n\nCooldown: 125 Seconds\n\nSpecials: None")
        
        if (!player.hasTag("spell25")) {
            form115.button('Learn')
            
        }
        
        if (player.hasTag("spell25")) {
            form115.button('Learned')
        }
    
        
        form115.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell25 1`)
        })
}






world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_26") {
        
      spell26(player)
    }
  })

function spell26(player) {
    let form116 = new ActionFormData()
        form116.title("Wither Skull")
        form116.body("Element: §5Pure§r\n\nRarity: §1Rare§r\n\nType: Projectile\n\nDamage: Up to 4 Hearts\n\nCooldown: 10 Seconds\n\nSpecials: Small explosion and wither")
        
        if (!player.hasTag("spell26")) {
            form116.button('Learn')
            
        }
        
        if (player.hasTag("spell26")) {
            form116.button('Learned')
        }
    
        
        form116.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell26 1`)
        })
}



world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_27") {
        
      spell27(player)
    }
  })

function spell27(player) {
    let form117 = new ActionFormData()
        form117.title("Tornado")
        form117.body("Element: §9Air§r\n\nRarity: §6Legendary§r\n\nType: Area\n\nDamage: Up to 12 Hearts Per Second\n\nCooldown: 100 Seconds\n\nSpecials: Moves towards the nearest targets and sucks them in and levitates and damages them")
        
        if (!player.hasTag("spell27")) {
            form117.button('Learn')
            
        }
        
        if (player.hasTag("spell27")) {
            form117.button('Learned')
        }
    
        
        form117.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell27 1`)
        })
}





world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_28") {
        
      spell28(player)
    }
  })

function spell28(player) {
    let form118 = new ActionFormData()
        form118.title("Dragon Fireball")
        form118.body("Element: §5Pure§r\n\nRarity: §5Epic§r\n\nType: Projectile and Area\n\nDamage: Around 3 Hearts Per Second\n\nCooldown: 30 Seconds\n\nSpecials: Doesnt do impact damage but does area damage on impact for a good amount of time")
        
        if (!player.hasTag("spell28")) {
            form118.button('Learn')
            
        }
        
        if (player.hasTag("spell28")) {
            form118.button('Learned')
        }
    
        
        form118.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell28 1`)
        })
}






world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_29") {
        
      spell29(player)
    }
  })

function spell29(player) {
    let form119 = new ActionFormData()
        form119.title("Thunderbolt")
        form119.body("Element: §eElectric§r\n\nRarity: §1Rare§r\n\nType: Projectile\n\nDamage: 1 1/2 Hearts\n\nCooldown: None\n\nSpecials: Cause wither")
        
        if (!player.hasTag("spell29")) {
            form119.button('Learn')
            
        }
        
        if (player.hasTag("spell29")) {
            form119.button('Learned')
        }
    
        
        form119.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell29 1`)
        })
}






world.events.beforeItemUse.subscribe(data => {
    let { item, source } = data
    const player = data.source
    
    if (item.id == "wizardry:spell_30") {
        
      spell30(player)
    }
  })

function spell30(player) {
    let form120 = new ActionFormData()
        form120.title("Petrify")
        form120.body("Element: §5Pure§r\n\nRarity: §6Legendary§r\n\nType: Body\n\nDamage: Has a 10% Chance to kill the target\n\nCooldown: 125 Seconds\n\nSpecials: Turns other humans to stone which causes them to not be able to move for a certain amount of time")
        
        if (!player.hasTag("spell30")) {
            form120.button('Learn')
            
        }
        
        if (player.hasTag("spell30")) {
            form120.button('Learned')
        }
    
        
        form120.show(player).then((response) => {
            if(response.selection == 0) player.runCommand(`scoreboard players set @s spell30 1`)
        })
}
