// priority: 0

onEvent('recipes', event => {
    removeRecipeByID(event, [
        EC("ultimate_singularity")
    ])

    //singularities
    const singularities = [
        { id: "antimatter_relay_mk3", core: PRE("relay_mk3") },
        { id: "pity_machine_frame", core: IF("machine_frame_pity") },
        { id: "electrum", core: F("#ingots/electrum") },
        { id: "lapis_lazuli", core: F("#gems/lapis") },
        { id: "white_matter", core: PREXP("white_matter") },
        { id: "blue_matter", core: PREXP("blue_matter") },
        { id: "klein_star_omega", core: PRE("klein_star_omega") },
        { id: "uranium", core: F("#ingots/uranium") },
        { id: "yellow_matter", core: PREXP("yellow_matter") },
        { id: "redstone", core: MC("redstone") },
        { id: "violet_matter", core: PREXP("violet_matter") },
        { id: "diamond", core: MC("diamond") },
        { id: "iron", core: F("#ingots/iron") },
        { id: "energy_condenser_mk2", core: PRE("condenser_mk2") },
        { id: "steel_casing", core: M("steel_casing") },
        { id: "nickel", core: F("#ingots/nickel") },
        { id: "cyan_matter", core: PREXP("cyan_matter") },
        { id: "steel", core: F("#ingots/steel") },
        { id: "red_matter", core: PRE("red_matter") },
        { id: "emerald", core: MC("emerald") },
        { id: "purple_matter", core: PREXP("purple_matter") },
        { id: "aluminum", core: F("#ingots/aluminum") },
        { id: "silver", core: F("#ingots/silver") },
        { id: "experience_pearl_x4", core: MU("experience_pearl_4x") },
        { id: "pink_matter", core: PREXP("pink_matter") },
        { id: "copper", core: F("#ingots/copper") },
        { id: "antimatter", core: M("pellet_antimatter") },
        { id: "bronze", core: F("#ingots/bronze") },
        { id: "invar", core: F("#ingots/invar") },
        { id: "dark_matter", core: PRE("dark_matter") },
        { id: "lime_matter", core: PREXP("lime_matter") },
        { id: "coal", core: MC("coal") },
        { id: "iron_opinium_core", core: MU("iron_opinium_core") },
        { id: "magenta_matter", core: PREXP("magenta_matter") },
        { id: "orange_matter", core: PREXP("orange_matter") },
        { id: "platinum", core: F("#ingots/platinum") },
        { id: "magnum_star_omega", core: PREXP("magnum_star_omega") },
        { id: "machine_frame", core: RTB("machine_frame") },
        { id: "glowstone", core: MC("glowstone_dust") },
        { id: "redstone_ingot", core: F("#ingots/red_alloy") },
        { id: "queens_slime_ingot", core: F("#ingots/queens_slime") },
        { id: "singularity", core: AE2("quantum_entangled_singularity") },
        { id: "fading_matter", core: PREXP("fading_matter") },
        { id: "green_matter", core: PREXP("green_matter") },
        { id: "tin", core: F("#ingots/tin") },
        { id: "16m_cell_component", core: AE2E("16m_cell_component") },
        { id: "lead", core: F("#ingots/lead") },
        { id: "colossal_star_omega", core: PREXP("colossal_star_omega") },
        { id: "energy_collector_mk1", core: PRE("collector_mk1") },
        { id: "energy_collector_mk2", core: PRE("collector_mk2") },
        { id: "energy_collector_mk3", core: PRE("collector_mk3") },
        { id: "antimatter_relay_mk1", core: PRE("relay_mk1") },
        { id: "antimatter_relay_mk2", core: PRE("relay_mk2") },
        { id: "antimatter_relay_mk3", core: PRE("relay_mk3") },
        { id: "crystaltine_ingot", core: EC("crystaltine_ingot") },
        { id: "crystal_matrix_ingot", core: AV("crystal_matrix_ingot") },
        { id: "neutronium_ingot", core: AV("neutronium_ingot") },
        { id: "computation_matrix", core: KJ("computation_matrix") },
        { id: "refined_radiance", core: CR("refined_radiance") },
        { id: "shadow_steel", core: CR("shadow_steel") },
        { id: "the_final_opinium_core", core: MU("the_final_opinium_core") },
    ]
    let singIdList = []

    singularities.forEach(singularity => {
        const { id, core } = singularity
        const singularityId = Item.of(EC('singularity'), { Id:EC(id) })

        event.recipes.extendedcrafting.shaped_table(singularityId, [
            'B   B   B',
            ' B  B  B ',
            '  B B B  ',
            '   BBB   ',
            'BBBBABBBB',
            '   BBB   ',
            '  B B B  ',
            ' B  B  B ',
            'B   B   B',
        ], {
        A: core,
        B: AE2("singularity"),
        }).id(KJ(`${EC()}/singularity/${id}`))

        singIdList.push(singularityId)
    })

    event.recipes.extendedcrafting.shapeless_table(EC("ultimate_singularity"), singIdList)

    //ender star
    event.shaped(EC("ender_star"), [
        'AAA',
        'ABA',
        'AAA'
    ], {
        A: MC('dragon_breath'),
        B: MC("nether_star")
    })

    //the ultimate ingot
    event.recipes.extendedcrafting.shapeless_table(EC("the_ultimate_ingot"), [
        F("#ingots/copper"), F("#ingots/zinc"), F("#ingots/iron"), F("#ingots/gold"), F("#ingots/silicon_bronze"),
        F("#ingots/cobalt"), F("#ingots/brass"), F("#ingots/netherite"), F("#ingots/platinum"), CM("star_infused_netherite_ingot"),
        F("#ingots/slimesteel"), F("#ingots/rose_gold"), F("#ingots/pig_iron"), F("#ingots/queens_slime"), F("#ingots/manyullyn"),
        F("#ingots/hepatizon"), F("#ingots/aluminum"), F("#ingots/silver"), F("#ingots/nickel"), F("#ingots/bronze"), F("#ingots/cast_iron"),
        F("#ingots/constantan"), F("#ingots/electrum"), F("#ingots/invar"), MAT("fairy_ingot"), BC("aurinium_ingot"),
        TA("tantalum_ingot"), TA("cobalt_tantalum_ingot"), TA("galaxy_alloy_ingot"), EC("crystaltine_ingot"), AV("crystal_matrix_ingot"),
        F("#ingots/red_alloy"), Item.of(MU("unstable_ingot")).ignoreNBT(), IF("pink_slime_ingot"), CC("ignitium_ingot"), F("#ingots/uranium"),
        F("#ingots/osmium"), F("#ingots/tin"), F("#ingots/lead"), F("#ingots/enderium"), F("#ingots/steel"),
        F("#ingots/refined_obsidian"), F("#ingots/refined_glowstone"), F("#ingots/desh"), F("#ingots/silicon"), AV("neutronium_ingot"),
    ]).id(KJ(`${EC()}/the_ultimate_ingot`))
})