//priority: 0

//hazmat
onEvent('recipes', e => {
    const { divine, bone, wither, prismarine, steampunk, robe, unstable, infused, ignitium, dm, rm, gem } = armorMats

    //divine armor
    armorPieces.vanilla.forEach(piece => {
        const t = CA(`material_armor_${piece}`)
        e.recipes.create.sequenced_assembly([
            IA(`divine_${piece}`),
        ], Item.of(t).ignoreNBT(), [
            e.recipes.createFilling(t, [t, divine.B]),
            e.recipes.createDeploying(t, [t, divine.C]),
            e.recipes.createDeploying(t, [t, divine.D]),
            e.recipes.createFilling(t, [t, divine.E]),
        ]).transitionalItem(t)
            .loops(divine.loops)
            .id(KJ(`divine_${piece}`))
    })



    // bone armor
    armorPieces.vanilla.forEach(piece => {
        const t = IA(`divine_${piece}`)
        e.recipes.create.sequenced_assembly([
            IA(`bone_${piece}`),
        ], Item.of(t).ignoreNBT(), [
            e.recipes.createFilling(t, [t, bone.B]),
            e.recipes.createDeploying(t, [t, bone.C]),
            e.recipes.createDeploying(t, [t, bone.D]),
            e.recipes.createDeploying(t, [t, bone.E]),
            e.recipes.createDeploying(t, [t, bone.F]),
            e.recipes.createFilling(t, [t, bone.G]),
        ]).transitionalItem(t)
            .loops(bone.loops)
            .id(KJ(`bone_${piece}`))
    })



    // wither armor
    armorPieces.vanilla.forEach(piece => {
        const t = IA(`bone_${piece}`)
        e.recipes.create.sequenced_assembly([
            IA(`wither_${piece}`),
        ], Item.of(t).ignoreNBT(), [
            e.recipes.createFilling(t, [t, wither.B]),
            e.recipes.createDeploying(t, [t, wither.C]),
            e.recipes.createDeploying(t, [t, wither.D]),
            e.recipes.createDeploying(t, [t, wither.E]),
            e.recipes.createDeploying(t, [t, wither.F]),
            // e.recipes.createFilling(t, [t, wither.G]),
        ]).transitionalItem(t)
            .loops(wither.loops)
            .id(KJ(`wither_${piece}`))
    })



	//prismarine armor
    armorPieces.vanilla.forEach(piece => {
        e.recipes.create.mechanical_crafting(
            IA(`prismarine_${piece}`),
            armorTemplates.advanced[piece],
            armorObj.advanced(prismarine, piece)
        ).id(KJ(`mechanical_crafting/prismarine_${piece}`))
		e.recipes.extendedcrafting.shaped_table(
			IA(`prismarine_${piece}`),
            armorTemplates.advanced[piece],
            armorObj.advanced(prismarine, piece)
		).id(KJ(`extended_crafting/prismarine_${piece}`))
    })



    //steampunk armor
    armorPieces.vanilla.forEach(piece => {
        e.recipes.create.mechanical_crafting(
            IA(`steampunk_${piece}`),
            armorTemplates.elite[piece],
            armorObj.elite(steampunk, piece)
        ).id(KJ(`mechanical_crafting/steampunk_${piece}`))
        e.recipes.extendedcrafting.shaped_table(
            IA(`steampunk_${piece}`),
            armorTemplates.elite[piece],
            armorObj.elite(steampunk, piece)
        ).id(KJ(`extended_crafting/steampunk_${piece}`))
    })



    //robe armor
    armorPieces.vanilla.forEach(piece => {
        e.recipes.extendedcrafting.shaped_table(
            IA(`robe_${piece}`),
            armorTemplates.ultimate[piece],
            armorObj.ultimate(robe, piece)
        ).id(KJ(`robe_${piece}`))
    })



    //unstable armor
    armorPieces.vanilla.forEach(piece => {
        e.remove({ id: MU(`unstable_${piece}`) })
        e.custom({
            input: [
                { item: unstable.A },
                { item: unstable.base[piece] },
                { item: unstable.A },
                { item: unstable.B },
                { item: unstable.B },
                { item: unstable.C },
                { item: unstable.D },
                { item: unstable.C }
            ],
            inputFluid: `{FluidName:\"${unstable.fluid}\",Amount:${unstable.fluidAmount}}`,
            processingTime: 400,
            output: {
              item: MU(`unstable_${piece}`),
              count: 1
            },
            type: IF("dissolution_chamber")
        }).id(KJ(`unstable_${piece}`))
    })



    //unstable armor
    armorPieces.vanilla.forEach(piece => {
        e.remove({ id: MU(`infused_${piece}`) })
        e.custom({
            input: [
                { item: infused.A },
                { item: infused.base[piece] },
                { item: infused.A },
                { tag: infused.B },
                { tag: infused.B },
                { item: infused.C },
                { item: infused.D },
                { item: infused.C }
            ],
            inputFluid: `{FluidName:\"${infused.fluid}\",Amount:${infused.fluidAmount}}`,
            processingTime: 400,
            output: {
              item: MU(`infused_${piece}`),
              count: 1
            },
            type: IF("dissolution_chamber")
        }).id(KJ(`infused_${piece}`))
    })



    //ignitium armor
    armorPieces.vanilla.forEach(piece => {
        e.remove({ output: CC(`ignitium_${piece}`) })
        e.custom({
            input: [
                { item: ignitium.A },
                { item: ignitium.base[piece] },
                { item: ignitium.A },
                { item: ignitium.B },
                { item: ignitium.B },
                { item: ignitium.C },
                { item: ignitium.D },
                { item: ignitium.C }
            ],
            inputFluid: `{FluidName:\"${ignitium.fluid}\",Amount:${ignitium.fluidAmount}}`,
            processingTime: 400,
            output: {
              item: CC(`ignitium_${piece}`),
              count: 1
            },
            type: IF("dissolution_chamber")
        }).id(KJ(`ignitium_${piece}`))
    })



    //dm armor
    armorPieces.vanilla.forEach(piece => {
        e.remove({ output: PRE(`dm_${piece}`) })
        e.recipes.extendedcrafting.shaped_table(
            PRE(`dm_${piece}`),
            armorTemplates.ultimate[piece],
            armorObj.ultimate(dm, piece)
        ).id(KJ(`dm_${piece}`))
    })



    //rm armor
    armorPieces.vanilla.forEach(piece => {
        e.remove({ output: PRE(`rm_${piece}`) })
        e.custom({
            input: [
                { item: rm.A },
                { item: rm.base[piece] },
                { item: rm.A },
                { item: rm.B },
                { item: rm.B },
                { item: rm.C },
                { item: rm.D },
                { item: rm.C }
            ],
            inputFluid: `{FluidName:\"${rm.fluid}\",Amount:${rm.fluidAmount}}`,
            processingTime: 400,
            output: {
              item: PRE(`rm_${piece}`),
              count: 1
            },
            type: IF("dissolution_chamber")
        }).id(KJ(`rm_${piece}`))
    })



    //gem armor
    armorPieces.vanilla.forEach(piece => {
        e.remove({ output: PRE(`gem_${piece}`) })
        e.custom({
            input: [
                { item: gem.A },
                { item: gem.base[piece] },
                { item: gem.A },
                { item: gem.B },
                { item: gem.B },
                { item: gem.C },
                { item: gem.D },
                { item: gem.C }
            ],
            inputFluid: `{FluidName:\"${gem.fluid}\",Amount:${gem.fluidAmount}}`,
            processingTime: 400,
            output: {
              item: PRE(`gem_${piece}`),
              count: 1
            },
            type: IF("dissolution_chamber")
        }).id(KJ(`gem_${piece}`))
    })



    //meka suit
    armorPieces.meka.forEach((piece, i) => {
		const vanillaEq = armorPieces.vanilla[i]

		//remove
		removeRecipeByOutput(e, [
			M(`mekasuit_${piece}`)
		])

		//extended crafting
		e.recipes.extendedcrafting.shaped_table(
            M(`mekasuit_${piece}`),
            armorTemplates.ultimate[vanillaEq],
            armorObj.ultimate(armorMats.meka, vanillaEq)
        ).id(KJ(`mekasuit_${piece}`))
    })



    //infinity armor
    armorPieces.vanilla.forEach(piece => {
		//remove
		removeRecipeByOutput(e, [
			AV(`infinity_armor_${piece}`)
		])

		//extended crafting
		e.recipes.extendedcrafting.shaped_table(
            AV(`infinity_armor_${piece}`),
            armorTemplates.ultimate[piece],
            armorObj.ultimate(armorMats.infinity, piece)
        ).id(KJ(`${AV()}/extended_crafting/infinity_armor_${piece}`))
    })



    //hazmat armor
    armorPieces.hazmat.forEach((piece, i) => {
		const vanillaEq = armorPieces.vanilla[i]

		//remove
		removeRecipeByOutput(e, [
			M(`hazmat_${piece}`)
		])

		//extended crafting
		e.recipes.extendedcrafting.shaped_table(
            M(`hazmat_${piece}`),
            armorTemplates.ultimate[vanillaEq],
            armorObj.ultimate(armorMats.hazmat, vanillaEq)
        ).id(KJ(`${M()}/extended_crafting/hazmat_${piece}`))
	})



    //space suit
    armorPieces.space.forEach((piece, i) => {
		const vanillaEq = armorPieces.vanilla[i]

		//remove
		removeRecipeByOutput(e, [
			BT(piece)
		])

		//extended crafting
		e.recipes.extendedcrafting.shaped_table(
            BT(piece),
            armorTemplates.ultimate[vanillaEq],
            armorObj.ultimate(armorMats.space, vanillaEq)
        ).id(KJ(`${BT()}/extended_crafting/${piece}`))
    })



    //netherite space suit
    armorPieces.space.forEach((piece, i) => {
		const vanillaEq = armorPieces.vanilla[i]

		//remove
		removeRecipeByOutput(e, [
			BT(`netherite_${piece}`)
		])

		//extended crafting
		e.recipes.extendedcrafting.shaped_table(
            BT(`netherite_${piece}`),
            armorTemplates.ultimate[vanillaEq],
            armorObj.ultimate(armorMats.spaceNetherite, vanillaEq)
        ).id(KJ(`${BT()}/extended_crafting/netherite_${piece}`))
    })
})