events.listen('recipes', function (e) {
    //Functions    
    function remove(item) {
      e.remove({output: item})
    }    
    function removeId(item) {
      e.remove({id: item})
    }
    var shaped = e.shaped
    var shapeless = e.shapeless
    function modifyShaped(result, count, p1, p2, p3, ingridients){
        remove(result)
        shaped(item.of(result, count), [
            p1,
            p2,
            p3
        ], ingridients
        )
    }
    function modifyShapeless(result, count, ingridients){
        remove(result)
        shapeless(item.of(result, count), ingridients)
    }
    function modifySmelt(result, ingridients){
        remove(result)
        e.smelting(result, ingridients)
    }

    //Modified recipes
    modifyShaped('mekanismgenerators:solar_panel', 1,
    'PPP',
    'RIR',
    'OOO',
    {
      P: 'powah:solar_panel_starter',
      R: '#forge:dusts/redstone',
      I: 'mekanism:alloy_infused',
      O: '#forge:ingots/osmium'
    })
    modifyShaped('engineerstools:crushing_hammer', 1,
    'RI ',
    'BS ',
    '  S',
    {
        R: '#forge:string',
        I: '#forge:ingots/iron',
        B: '#forge:storage_blocks/iron',
        S: '#forge:rods/wooden'
    })
    modifyShaped('forbidden_arcanus:candle_lamp', 1,
      'NDN',
      'GAG',
      'NDN', 
    {
          N: 'forbidden_arcanus:arcane_gold_nugget',
          A: 'forbidden_arcanus:candle',
          D: 'forbidden_arcanus:darkstone',
          G: 'forbidden_arcanus:arcane_gold_ingot'
    })
    modifyShaped('mekanism:module_solar_recharging_unit', 1,
      'ISI',
      'IAI',
      'PPP',
    {
        I: '#forge:alloys/elite',
        A: 'mekanism:module_base',
        S: 'powah:solar_panel_blazing',
        P: 'mekanism:pellet_polonium'
    })
    modifyShaped('immersiveengineering:cloche', 1,
      'GEG',
      'G G',
      'TRT',
    {
        G: '#forge:glass',
        E: 'immersiveengineering:electron_tube',
        T: '#forge:treated_wood',
        R: 'mekanism:resistive_heater'
    })
    removeId('bagofyurting:bag_of_yurting')
    shaped('bagofyurting:bag_of_yurting', 1,
      'WSW',
      'WEW',
      'WWW',
    {
        W: '#minecraft:wool',
        E: '#forge:ender_pearls',
        S: 'minecraft:string'
    })
    modifyShapeless('appliedenergistics2:cable_anchor', 3, [['#forge:ingots/gold','#forge:ingots/iron','#forge:ingots/copper','#forge:ingots/tin'],'#appliedenergistics2:knife'])
    modifyShapeless('appliedenergistics2:fluix_covered_cable', 1, ['#minecraft:wool','appliedenergistics2:fluix_glass_cable'])
    modifyShapeless('appliedenergistics2:crafting_card', 1, ['#forge:workbench','appliedenergistics2:basic_card'])
    modifyShapeless('appliedenergistics2:fuzzy_card', 1, ['#minecraft:wool','appliedenergistics2:advanced_card'])
    modifyShaped('appliedenergistics2:quartz_glass', 4,
      'GDG',
      'DGD',
      'GDG',
    {
        G: '#appliedenergistics2:dusts/quartz',
        D: '#forge:glass'
    })
    modifyShaped('appliedenergistics2:quartz_fiber', 3,
      'DDD',
      'GGG',
      'DDD',
    {
      G: '#appliedenergistics2:dusts/quartz',
      D: '#forge:glass'
    })
    modifyShaped('appliedenergistics2:chest', 1,
      'GTG',
      'C C',
      'IFI',
    {
        G: '#forge:glass',
        T: 'appliedenergistics2:terminal',
        C: 'appliedenergistics2:fluix_glass_cable',
        I: '#forge:ingots/iron',
        F: '#appliedenergistics2:crystals/fluix'
    })
    modifyShaped('appliedenergistics2:condenser', 1,
      'IGI',
      'GDG',
      'IGI',
    {
        G: '#forge:glass',
        I: '#forge:ingots/iron',
        D: '#appliedenergistics2:dusts/fluix',
    })
    modifyShaped('appliedenergistics2:spatial_io_port', 1,
      'GGG',
      'CPC',
      'IEI',
    {
        G: '#forge:glass',
        C: 'appliedenergistics2:fluix_glass_cable',
        P: 'appliedenergistics2:io_port',
        I: '#forge:ingots/iron',
        E: 'appliedenergistics2:engineering_processor'
    })
    modifyShaped('appliedenergistics2:io_port', 1,
      'GGG',
      'DCD',
      'IPI',
    {
        G: '#forge:glass',
        C: 'appliedenergistics2:fluix_glass_cable',
        P: 'appliedenergistics2:logic_processor',
        I: '#forge:ingots/iron',
        D: 'appliedenergistics2:drive'
    })
    modifyShaped('appliedenergistics2:interface', 1,
      'IGI',
      'A F',
      'IGI',
    {
        G: '#forge:glass',
        A: 'appliedenergistics2:annihilation_core',
        F: 'appliedenergistics2:formation_core',
        I: '#forge:ingots/iron'
    })
    shapeless('appliedenergistics2:interface', 1, ['appliedenergistics2:cable_interface'])
    modifyShaped('appliedenergistics2:molecular_assembler', 1,
      'IGI',
      'ACF',
      'IGI',
    {
        G: 'appliedenergistics2:quartz_glass',
        A: 'appliedenergistics2:annihilation_core',
        F: 'appliedenergistics2:formation_core',
        I: '#forge:ingots/iron',
        C: '#forge:workbench'
    })
    modifyShaped('appliedenergistics2:cell_workbench', 1,
      'WEW',
      'ICI',
      'III',
    {
        W: '#minecraft:wool',
        E: 'appliedenergistics2:calculation_processor',
        I: '#forge:ingots/iron',
        C: '#forge:chests/wooden'
    })
    modifyShaped('minecraft:daylight_detector', 1,
      'GGG',
      'QQQ',
      'SSS',
    {
        G: '#forge:glass',
        Q: '#forge:gems/quartz',
        S: '#minecraft:wooden_slabs'
    })
    modifySmelt('refinedstorage:silicon', '#appliedenergistics2:crystals/quartz')
    remove('silents_mechanisms:zombie_leather')
    e.recipes.silents_mechanisms.drying({
      process_time: 600,
      ingredient: {
          item: 'minecraft:rotten_flesh'
      },
      result: {
          item: 'forbidden_arcanus:rotten_leather'
      }
    })
    removeId('appliedenergistics2:inscriber/silicon_print')
    e.recipes.appliedenergistics2.inscriber({
        mode: 'inscribe',
        result: {
          item: 'appliedenergistics2:printed_silicon'
        },
        ingredients: {
          top: {
            item: 'appliedenergistics2:silicon_press'
          },
          middle: {
            tag: 'forge:silicon'
          }
        }
    })

    //Dye stuff
    function dyeStuff(color){
        remove('minecraft:'+color+'_bed')
        e.replaceInput('minecraft:'+color+'_dye', '#forge:dyes/'+color)
      shaped(item.of('minecraft:'+color+'_bed'), [
        '   ',
        'WWW',
        'PPP'
      ], {
        P: '#minecraft:planks',
        W: 'minecraft:'+color+'_wool'
      })
      shapeless(item.of('minecraft:'+color+'_bed'), ['#minecraft:beds', '#forge:dyes/'+color])
        remove('minecraft:'+color+'_wool')
      shaped(item.of('minecraft:'+color+'_wool', 8), [
        'WWW',
        'WCW',
        'WWW'
      ], {
        C: '#forge:dyes/'+color,
        W: '#minecraft:wool'
      })
      shaped(item.of('minecraft:'+color+'_wool', 2), [
        ' C ',
        ' C ',
        ' C ',
      ], {
        C: 'minecraft:'+color+'_carpet'
      })
        remove('minecraft:'+color+'_carpet')
      shapeless(item.of('minecraft:'+color+'_carpet'), ['#minecraft:carpets', '#forge:dyes/'+color])
      shaped(item.of('minecraft:'+color+'_carpet', 8), [
        'WWW',
        'WCW',
        'WWW'
      ], {
        C: '#forge:dyes/'+color,
        W: '#minecraft:carpets'
      })
      shaped(item.of('minecraft:'+color+'_carpet', 3), [
        '   ',
        'WW ',
        '   ',
      ], {
        W: 'minecraft:'+color+'_wool'
      })
      remove('comforts:sleeping_bag_'+color)
      shaped(item.of('comforts:sleeping_bag_'+color), [
        'WWW',
        'SSS',
        'WWW',
      ], {
        W: 'absentbydesign:slab_wool_'+color,
        S: '#forge:string'
      })
      shaped(item.of('minecraft:'+color+'_stained_glass', 3), [
        'GGG',
        'G G',
        'GGG',
      ], {
        G: 'minecraft:'+color+'_stained_glass_pane'
      })
    }
    dyeStuff('black')
    dyeStuff('blue')
    dyeStuff('brown')
    dyeStuff('cyan')
    dyeStuff('gray')
    dyeStuff('green')
    dyeStuff('light_blue')
    dyeStuff('light_gray')
    dyeStuff('lime')
    dyeStuff('magenta')
    dyeStuff('orange')
    dyeStuff('pink')
    dyeStuff('purple')
    dyeStuff('red')
    dyeStuff('white')
    dyeStuff('yellow')
    shaped(item.of('minecraft:white_wool'), [
        'SS ',
        'SS ',
        '   '
    ], {
      S: '#forge:string'
    })
    shaped(item.of('minecraft:glass', 3), [
      'GGG',
      'G G',
      'GGG',
    ], {
      G: 'minecraft:glass_pane'
    })
    e.replaceInput('minecraft:glass_pane', '#forge:glass_panes')
})