ServerEvents.recipes(event => {
    // Most of the mod is gated behind basic energetic and build grist
    event.replaceInput({output: 'create_new_age:reinforced_motor'},
        'minecraft:diamond',
        '#kubejs:grist/build/basic'
    );

    event.replaceInput({mod: 'create_new_age'},
        'minecraft:redstone_block',
        '#kubejs:grist/energetic/basic'
    );


    event.replaceInput({mod: 'create_new_age'},
        'minecraft:netherite_scrap',
        '#kubejs:grist/energetic/improved'
    );

    event.replaceInput({mod: 'create_new_age'},
        '#forge:nuggets/copper',
        '#kubejs:grist/energetic/basic'
    );

    // Reactor requires energetic
    event.replaceInput({output: 'create_new_age:reactor_casing'},
        'minecraft:bricks',
        '#kubejs:grist/energetic/improved'
    );

    // Power generation requires basic energetic and build
    event.replaceInput({output: 'create_new_age:carbon_brushes'},
        'minecraft:coal',
        '#kubejs:grist/build/basic'
    );

    event.replaceInput({output: 'create_new_age:generator_coil'},
        'minecraft:copper_ingot',
        '#kubejs:grist/energetic/basic'
    );

    // Rewrite the motors to use grist
    event.remove({output: 'create_new_age:basic_motor'});
    event.shaped('create_new_age:basic_motor', [
        'ABA',
        'CDE',
        'AFA'
    ], {
        'A': '#forge:nuggets/iron',
        'B': '#kubejs:grist/energetic/basic',
        'C': 'create_new_age:magnetite_block',
        'D': 'create:andesite_casing',
        'E': 'create:shaft',
        'F': '#kubejs:grist/build/basic'
    });

    event.remove({output: 'create_new_age:advanced_motor'});
    event.shaped('create_new_age:advanced_motor', [
        'ABA',
        'CDE',
        'AFA'
    ], {
        'A': '#forge:plates/invar',
        'B': '#kubejs:grist/energetic/basic',
        'C': global.ingotItem('tin'),
        'D': 'create:andesite_casing',
        'E': 'create:shaft',
        'F': '#kubejs:grist/build/basic'
    });


    // Powah compat with the energizing recipes

    /*event.recipes.powah.energizing(
        ['#forge:plates/iron'],
        'create_new_age:overcharged_iron_sheet',
        1000
    );

    event.recipes.powah.energizing(
        ['#forge:ingots/iron'],
        'create_new_age:overcharged_iron',
        2000
    );

    event.recipes.powah.energizing(
        ['#forge:ingots/gold'],
        'create_new_age:overcharged_gold',
        2000
    );

    event.recipes.powah.energizing(
        ['#forge:plates/gold'],
        'create_new_age:overcharged_gold_sheet',
        2000
    );*/

    // Remove the whole energizing mechanic in favor of the metals system
    event.remove({type: 'create_new_age:energising'});
    event.remove({output: 'create_new_age:overcharged_iron_sheet'});
    event.remove({output: 'create_new_age:overcharged_gold_sheet'});
    event.remove({output: 'create_new_age:energiser_t1'});
    event.remove({output: 'create_new_age:energiser_t2'});
    event.remove({output: 'create_new_age:energiser_t3'});
    event.replaceInput({},
        'create_new_age:overcharged_iron',
        global.ingotItem('tin')
    );

    event.replaceInput({},
        'create_new_age:overcharged_iron_sheet',
        global.plateItem('tin')
    );
    
    event.replaceInput({},
        'create_new_age:overcharged_gold',
        global.ingotItem('constantan')
    );

    event.replaceInput({},
        'create_new_age:overcharged_gold_sheet',
        global.plateItem('constantan')
    );

    event.replaceInput({},
        'create_new_age:overcharged_diamond',
        global.gearItem('platinum')
    );
});