function spellBookRecipe(grid, result) {
	let item = grid.find('#irons_spellbooks:spellbooks')
	let itemCopy = item.copy()

    let nbt1 = item.nbt
	var spells
	if (result.nbt == null) {
        result.nbt = {}
	}
	if (nbt1 != null) {
        if (nbt1.ISB_spellbook != null) {
			spells = nbt1.ISB_spellbook.spells
		}
	}

	let nbt2 = result.nbt
	if (nbt2 == null) {
        nbt2 = {}
    }
	if (spells != null) {
		nbt2.ISB_spellbook = {}
		nbt2.ISB_spellbook.spells = spells
	}

	let outputItem = result.withNBT(nbt2)
		
	return outputItem
}

onEvent('recipes', event => {
	event.remove({output: 'irons_spellbooks:copper_spell_book'})
	event.shaped('irons_spellbooks:copper_spell_book', [
		'CPP',
		'RPP',
		'CPP'
	  ], {
		C: 'minecraft:copper_ingot',
		P: 'minecraft:paper',
        R: 'malum:corrupted_resonance'
	  })
	  
	event.remove({output: 'irons_spellbooks:iron_spell_book'})
	event.shaped('irons_spellbooks:iron_spell_book', [
		'IFF',
		'IBG',
		'IFF'
	  ], {
		I: 'malum:iron_impetus',
		G: 'minecraft:iron_ingot',
		F: 'malum:spirit_fabric',
		B: 'irons_spellbooks:copper_spell_book'
	  })
	  
	event.remove({output: 'irons_spellbooks:gold_spell_book'})
	event.shaped('irons_spellbooks:gold_spell_book', [
		'IEH',
		'IBG',
		'IEH'
	  ], {
		I: 'malum:gold_impetus',
		G: 'minecraft:gold_ingot',
		B: 'irons_spellbooks:iron_spell_book',
		E: 'irons_spellbooks:arcane_essence',
		H: 'irons_spellbooks:hogskin'
	  })
	  
	event.remove({output: 'irons_spellbooks:diamond_spell_book'})
	event.shaped('irons_spellbooks:diamond_spell_book', [
		'HII',
		'CBC',
		'HII'
	  ], {
		I: 'malum:vivid_nitrate',
		B: 'irons_spellbooks:gold_spell_book',
		C: 'irons_spellbooks:magic_cloth',
		H: 'irons_spellbooks:hogskin'
	  })
	
})