// const $ISpellContainer = Java.loadClass("io.redspace.ironsspellbooks.api.spells.ISpellContainer")
// /** @type {Array<Internal.ItemStack>} */
// let scrollIngredientArr = []
// 
// SpellRegistry.REGISTRY.get().forEach(spell => {
//     for (let level = spell.minLevel; level <= spell.maxLevel; level++) {
//         let scrollStack = Item.of('irons_spellbooks:scroll')
//         $ISpellContainer.createScrollContainer(spell, level, scrollStack)
//         scrollIngredientArr.push(scrollStack)
//     }
// })
// 
// ServerEvents.recipes(event => {
//   
//     for (let scroll of scrollIngredientArr) {
//         let spellData = scroll.nbt["irons_spellbooks:spell_container"]["data"][0]
//         let r = event.shapeless(
//             Item.of('irons_spellbooks:scroll', 2),
//             [
//                 'sortilege:limitite',
//                 scroll.weakNBT()
//             ]
//         )
//         r.id(`kubejs:nbt_dupe/${spellData["id"].split(":")[1]}_${spellData["level"]}`)
//         r.modifyResult((grid, result) => {
//             return result.withNBT(grid.find(scroll).nbt)
//         })
//     }
// })

ServerEvents.recipes(event => {
    event.shapeless(
        'irons_spellbooks:scroll',
        ['sortilege:limitite', 'irons_spellbooks:scroll']
    ).id('kubejs:nbt_dupe_test')
        .modifyResult((grid, result) => {
            let input = grid.find('irons_spellbooks:scroll')
            let finalNbt = input.nbt ? input.nbt : new CompoundTag()
            return result.withNBT(finalNbt)
        })
        .keepIngredient('irons_spellbooks:scroll')
})