
ServerEvents.recipes(event => {

// BITUMEN PARTIAL FIX, ANOTHER ONE IN STARTUP   ///
    event.replaceInput(   
	 { input: 'thermal:bitumen' }, // Arg 1: the filter
	    'thermal:bitumen',            // Arg 2: the item to replace
	    '#forge:bitumen'         // Arg 3: the item to replace it with
    )
    event.recipes.thermal.stirling_fuel('#forge:bitumen').energy(16000)



// OIL REFINING REBALANCE   ////////////////////////////////////
 event.recipes.thermal.refinery(        //fractionating still, crude oil refining into heavy oil and light oil(sulfurized diesel), change of ratios
    [
    Fluid.of('thermal:heavy_oil', 50),                      // outputs
    Fluid.of('immersivepetroleum:diesel_sulfur', 50), 
    Item.of('immersivepetroleum:bitumen').withChance(0.1)
    ],
    Fluid.of('immersivepetroleum:crudeoil', 100)            // input    
    )
    .energy(6000)

event.remove({ id: 'thermal:machines/refinery/refinery_crude_oil' })


 event.recipes.thermal.refinery(        //fractionating still, heavy oil into refined fuel(diesel), change of ratio
    [
    Fluid.of('immersivepetroleum:diesel', 50),
    Item.of('thermal:tar').withChance(0.1)
    ],
    Fluid.of('thermal:heavy_oil', 100)
    )
    .energy(6000)

event.remove({ id: 'thermal:machines/refinery/refinery_heavy_oil' })


 event.recipes.thermal.refinery(        //fractionating still, light oil(sulfurized diesel) into refined fuel(diesel), change of ratio
    [
    Fluid.of('immersivepetroleum:diesel', 75), 
    Item.of('thermal:sulfur_dust').withChance(0.2)
    ],
    Fluid.of('immersivepetroleum:diesel_sulfur', 100)
    )
    .energy(6000)

event.remove({ id: 'thermal:machines/refinery/refinery_light_oil' })           
    
})

// FLUID UNIFICATION /////////////////////////////////////////// 
const FluidsForUnification = [
    {
        toreplace: 'createaddition:bioethanol',
        replacewith: 'immersiveengineering:biodiesel'
    },
    {
        toreplace: 'createaddition:seed_oil',
        replacewith: 'immersiveengineering:plantoil'
    },
    {
        toreplace: 'thermal:tree_oil',
        replacewith: 'immersiveengineering:plantoil'
    },
    {
        toreplace: 'thermal:light_oil',
        replacewith: 'immersivepetroleum:diesel_sulfur'
    },
    {
        toreplace: 'thermal:creosote',
        replacewith: 'immersiveengineering:creosote'
    },
    {
        toreplace: 'thermal:crude_oil',
        replacewith: 'immersivepetroleum:crudeoil'
    },
    {
        toreplace: 'thermal:refined_fuel',
        replacewith: 'immersivepetroleum:diesel'
    },
]

FluidsForUnification.forEach(fluid => {
    global.FluidReplaceOutput(
        fluid.toreplace,
        fluid.replacewith
    )
    global.FluidReplaceInput(
        fluid.toreplace,
        fluid.replacewith
    )
})


// REMOVING WATER TAGS FROM OILS  ///////
ServerEvents.tags('fluid', event => {             

    const badwatertags = [
        'createaddition:bioethanol', 
        'createaddition:flowing_bioethanol', 
        'createaddition:seed_oil',
        'createaddition:flowing_seed_oil'
    ]
    
    badwatertags.forEach(badwatertag => {
        event.removeAllTagsFrom(badwatertag)
    })
})

