events.listen('recipes', event => {

    var mekcrush = event.recipes.mekanism.crushing
    var removeOut = function (item) {
      event.remove({output: item})
    }
    var removeIn = function (item) {
      event.remove({input: item})
    }
    var removeId = function (id) {
      event.remove({id: id})
    }
    var mekenrichItem = function (item, iCount, result, rCount) {
        event.recipes.mekanism.enriching({
            input: {
                amount: iCount,
                ingredient: {
                  item: item
                }
            },
            output: {
                item: result,
                count: rCount
            }
        })
    }
    var mekenrichTag = function (tag, iCount, result, rCount) {
        event.recipes.mekanism.enriching({
            input: {
                amount: iCount,
                ingredient: {
                    tag: tag
                }
            },
            output: {
                item: result,
                count: rCount
            }
        })
    }
    var silentsCrushTag = function (tag, result, rCount, duration) {
      event.recipes.silents_mechanisms.crushing({
        process_time: duration,
        ingredient: {
          tag: tag
        },
        results: [
          {
            item: result,
            count: rCount
          }
        ]
      })
    }
    var silentsCrushItem = function (item, result, rCount, duration) {
      event.recipes.silents_mechanisms.crushing({
        process_time: duration,
        ingredient: {
          item: item
        },
        results: [
          {
            item: result,
            count: rCount
          }
        ]
      })
    }
    var energize = function(ingredient, result, rCount, power) {
      event.recipes.powah.energizing({
        ingredients: ingredient,
        energy: power,
        result: {
          item: result,
          count: rCount
        }
      })
    }
    var pressure = function(inputs, result, rCount, pressure) {
      event.recipes.pneumaticcraft.pressure_chamber(
        {
          inputs: inputs,
          pressure: pressure,
          results: [
            {
              item: result,
              count: rCount
            }
          ]
        }
      )
    }
  
    //Make bio fuel use tags instead of invidual items
    removeOut('mekanism:bio_fuel')
    mekcrush(item.of('mekanism:bio_fuel', 2), '#misctags:biofuel2')
    mekcrush(item.of('mekanism:bio_fuel', 4), '#misctags:biofuel4')
    mekcrush(item.of('mekanism:bio_fuel', 5), '#misctags:biofuel5')
    mekcrush(item.of('mekanism:bio_fuel', 7), '#misctags:biofuel7')
    mekcrush(item.of('mekanism:bio_fuel', 8), '#misctags:biofuel8')
  
    //Recipes for AE2 dusts
    mekcrush(item.of('appliedenergistics2:certus_quartz_dust'), '#forge:gems/certus_quartz')
    mekcrush(item.of('appliedenergistics2:ender_dust'), '#forge:ender_pearls')
    mekcrush(item.of('appliedenergistics2:fluix_dust'), '#appliedenergistics2:crystals/fluix')
    silentsCrushTag('forge:ender_pearls', 'appliedenergistics2:ender_dust', 1, 180)
    silentsCrushTag('forge:gems/certus_quartz', 'appliedenergistics2:certus_quartz_dust', 1, 180)
    silentsCrushItem('appliedenergistics2:fluix_crystal', 'appliedenergistics2:fluix_dust', 1, 180)
    
    //Powah recipes
    energize([{tag: 'forge:ingots/allthemodium'},{tag: 'forge:ingots/unobtainium'}], 'allthemodium:unobtainium_allthemodium_alloy_ingot', 1, 50000)
    energize([{tag: 'forge:ingots/vibranium'},{tag: 'forge:ingots/allthemodium'}], 'allthemodium:vibranium_allthemodium_alloy_ingot', 1, 50000)
    energize([{tag: 'forge:ingots/vibranium'},{tag: 'forge:ingots/unobtainium'}], 'allthemodium:vibranium_unobtainium_alloy_ingot', 1, 50000)
    energize([{tag: 'forge:storage_blocks/iron'},{tag: 'forge:storage_blocks/gold'}], 'powah:energized_steel_block', 2, 90000)
    energize([{item: 'botania:blaze_block'}], 'powah:blazing_crystal_block', 1, 810000)
    energize([{tag: 'forge:storage_blocks/diamond'}], 'powah:niotic_crystal_block', 1, 2700000)
    energize([{tag: 'forge:storage_blocks/emerald'}], 'powah:spirited_crystal_block', 1, 9000000)

    //Misc recipes
    event.recipes.appliedenergistics2.inscriber({
        mode: 'inscribe',
        result: {
          item: 'appliedenergistics2:printed_silicon'
        },
        ingredients: {
          top: {
            item: 'appliedenergistics2:silicon_press'
          },
          middle: {
            tag: 'forge:silicon'
          }
        }
    })
    event.recipes.industrialforegoing.dissolution_chamber({
      input: [
        {
          tag: 'minecraft:planks'
        }
      ],
      inputFluid: '{FluidName:\'immersiveengineering:creosote\',Amount:125}',
      processingTime: 1,
      output: {
        item: 'immersiveengineering:treated_wood_horizontal',
        count: 1
      }
    })

    mekcrush(item.of('minecraft:blaze_powder', 4), '#forge:rods/blaze')
    mekcrush(item.of('minecraft:quartz',4), '#forge:storage_blocks/quartz')
    mekenrichItem('minecraft:blaze_powder', 4, 'minecraft:blaze_rod', 1)


    //Recipe removals
    removeOut('appliedenergistics2:silicon')
    removeOut('mekanism:upgrade_anchor')
    removeOut('chunk:loader')
    removeOut('mekanismgenerators:solar_panel')
    
    //Recipe Changes
    removeOut('forbidden_arcanus:candle_lamp')
    event.shaped(item.of('forbidden_arcanus:candle_lamp'), [
      'NDN',
      'GAG',
      'NDN'
      ], {
          'N': 'forbidden_arcanus:arcane_gold_nugget',
          'A': 'forbidden_arcanus:candle',
          'D': 'forbidden_arcanus:darkstone',
          'G': 'forbidden_arcanus:arcane_gold_ingot'
    })
    removeOut('mekanism:module_solar_recharging_unit')
    event.shaped(item.of('mekanism:module_solar_recharging_unit'), [
      'I#I',
      'IAI',
      'PPP'
      ], {
        'I': '#forge:alloys/elite',
        'A': 'mekanism:module_base',
        '#': 'powah:solar_panel_blazing',
        'P': 'mekanism:pellet_polonium'
    })
    removeId('bagofyurting:bag_of_yurting')
    event.shaped(item.of('bagofyurting:bag_of_yurting'), [
      'wsw',
      'wEw',
      'www'
      ], {
        'w': '#minecraft:wool',
        'E': '#forge:ender_pearls',
        's': 'minecraft:string'
    })
    removeOut('refinedstorage:silicon')
    event.smelting(item.of('refinedstorage:silicon'), ['#forge:gems/quartz', '#forge:gems/certus_quartz'])
    removeOut('silents_mechanisms:zombie_leather')
    event.recipes.silents_mechanisms.drying({
      process_time: 600,
      ingredient: {
          item: 'minecraft:rotten_flesh'
      },
      result: {
          item: 'forbidden_arcanus:rotten_leather'
      }
    })

    //Creative recipes
    energize([{item: 'appliedenergistics2:dense_energy_cell'}], 'appliedenergistics2:creative_energy_cell', 1, 420000000)
    energize([{item: 'refinedstorage:controller'}], 'refinedstorage:creative_controller', 1, 420000000)
    energize([{item: 'refinedstorageaddons:wireless_crafting_grid'}], 'refinedstorageaddons:creative_wireless_crafting_grid', 1, 420000000)
    energize([{item: 'refinedstorage:wireless_crafting_monitor'}], 'refinedstorage:creative_wireless_crafting_monitor', 1, 420000000)
    energize([{item: 'refinedstorage:wireless_fluid_grid'}], 'refinedstorage:creative_wireless_fluid_grid', 1, 420000000)
    energize([{item: 'refinedstorage:wireless_grid'}], 'refinedstorage:creative_wireless_grid', 1, 420000000)
    event.shapeless(item.of('botania:mana_tablet', {mana:500000,creative:1}), ['botania:creative_pool'])
    event.shapeless('botania:creative_pool', [item.of('botania:mana_tablet', {mana:500000,creative:1})])
    pressure([
      {
        type: 'pneumaticcraft:stacked_item',
        item: 'mysticalagradditions:insanium_block',
        count: 2
      },
      {
        type: 'pneumaticcraft:stacked_item',
        tag: 'forge:pellets/antimatter',
        count: 4
      },
      {
        type: 'pneumaticcraft:stacked_item',
        item: 'botania:gaia_ingot',
        count: 2
      },
      {
        type: 'pneumaticcraft:stacked_item',
        tag: 'forge:storage_blocks/allthemodium',
        count: 1
      },
      {
        type: 'pneumaticcraft:stacked_item',
        tag: 'forge:storage_blocks/vibranium',
        count: 1
      },
      {
        type: 'pneumaticcraft:stacked_item',
        tag: 'forge:storage_blocks/unobtainium',
        count: 1
      }
    ], 'mysticalagradditions:creative_essence', 1, 4.9)
    event.shaped(item.of('botania:creative_pool'), [
      'CCC',
      'CPC',
      'CCC'
      ], {
          'C': 'mysticalagradditions:creative_essence' ,
          'P': 'botania:fabulous_pool'
          
    })
    event.shaped(item.of('pneumaticcraft:creative_compressor'), [
      'CLC',
      'FCA',
      'CEC'
      ], {
          'C': 'mysticalagradditions:creative_essence',
          'L': 'pneumaticcraft:advanced_liquid_compressor',
          'A': 'pneumaticcraft:advanced_air_compressor',
          'E': 'pneumaticcraft:electrostatic_compressor',
          'F': 'pneumaticcraft:flux_compressor'
    })
    event.shaped(item.of('rats:rat_upgrade_creative'), [
      'HUH',
      'CCC',
      'HUH'
      ], {
          'C': 'mysticalagradditions:creative_essence',
          'H': 'rats:creative_cheese',
          'U': 'rats:rat_upgrade_nonbeliever'
    })

    //SGear salvaging
    var salvage = function (item, results) {
      event.recipes.silentgear.salvaging(
        {
          ingredient: {
            item: item
          },
          results: results
        }
      )
    }
    salvage('minecraft:netherite_sword', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:stick',
          'count': 1
      },
      {
          'item': 'minecraft:diamond',
          'count': 2
      }
    ])
    salvage('minecraft:netherite_shovel', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:stick',
          'count': 2
      },
      {
          'item': 'minecraft:diamond',
          'count': 1
      }
    ])
    salvage('minecraft:netherite_pickaxe', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:stick',
          'count': 2
      },
      {
          'item': 'minecraft:diamond',
          'count': 3
      }
    ])
    salvage('minecraft:netherite_hoe', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:stick',
          'count': 2
      },
      {
          'item': 'minecraft:diamond',
          'count': 2
      }
    ])
    salvage('minecraft:netherite_axe', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:stick',
          'count': 2
      },
      {
          'item': 'minecraft:diamond',
          'count': 3
      }
    ])
    salvage('minecraft:netherite_boots', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:diamond',
          'count': 4
      }
    ])
    salvage('minecraft:netherite_leggings', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:diamond',
          'count': 7
      }
    ])
    salvage('minecraft:netherite_chestplate', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:diamond',
          'count': 8
      }
    ])
    salvage('minecraft:netherite_helmet', [
      {
        'item': 'minecraft:netherite_ingot',
        'count': 1
      },
      {
          'item': 'minecraft:diamond',
          'count': 5
      }
    ])
    salvage('minecraft:anvil', [
      {
        'item': 'minecraft:iron_ingot',
        'count': 31
      }
    ])
    salvage('minecraft:diamond_horse_armor', [
      {
          'item': 'minecraft:diamond',
          'count': 7
      }
    ])
    salvage('minecraft:golden_horse_armor', [
      {
        'item': 'minecraft:gold_ingot',
        'count': 7
      }
    ])
    salvage('minecraft:iron_horse_armor', [
      {
        'item': 'minecraft:iron_ingot',
        'count': 7
      }
    ])
    salvage('minecraft:leather_horse_armor', [
      {
        'item': 'minecraft:leather',
        'count': 7
      }
    ])
    salvage('minecraft:minecart', [
      {
        'item': 'minecraft:iron_ingot',
        'count': 5
      }
    ])
})