/**
 * Recipes for Optical Circuits.
 */

ServerEvents.tags("item", event => {
    event.add("forge:lenses/yellow", "gtceu:lithium_niobate_lens")
})

ServerEvents.recipes(event => {
    event.recipes.gtceu.mixer("dielectric_mirror_solution")
        .duration(900)
        .EUt(GTValues.VA[GTValues.LuV])
        .inputFluids("gtceu:polyethylene 1584")
        .itemInputs("7x gtceu:silicon_dioxide_dust", "1x gtceu:enderium_dust", "4x gtceu:tantalum_pentoxide_dust", "5x gtceu:rutile_dust", "3x gtceu:germanium_dust")
        .outputFluids("gtceu:dielectric_mirror_solution 4464")

    event.recipes.gtceu.alloy_blast_smelter("lithium_niobate")
        .blastFurnaceTemp(1510)
        .circuit(3)
        .duration(200)
        .EUt(GTValues.VA[GTValues.IV])
        .inputFluids("gtceu:oxygen 3000")
        .itemInputs("1x gtceu:lithium_dust", "1x gtceu:niobium_dust")
        .outputFluids("gtceu:lithium_niobate 720")
    event.recipes.gtceu.alloy_blast_smelter("lithium_niobate_gas")
        .blastFurnaceTemp(1510)
        .circuit(13)
        .duration(134)
        .EUt(GTValues.VA[GTValues.IV])
        .inputFluids("gtceu:oxygen 3000", "gtceu:nitrogen 5000")
        .itemInputs("1x gtceu:lithium_dust", "1x gtceu:niobium_dust")
        .outputFluids("gtceu:lithium_niobate 720")

    event.recipes.gtceu.chemical_bath("carbon_mesh_reinforced_circuit_board")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(800)
        .EUt(GTValues.VA[GTValues.EV])
        .inputFluids("gtceu:polyether_ether_ketone 144")
        .itemInputs("2x gtceu:carbon_fiber_mesh")
        .itemOutputs("1x kubejs:carbon_mesh_reinforced_circuit_board")

    event.recipes.gtceu.chemical_reactor("carbon_mesh_reinforced_printed_circuit_board_persulfate")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(1500)
        .EUt(GTValues.VA[GTValues.HV])
        .inputFluids("gtceu:sodium_persulfate 5000")
        .itemInputs("1x kubejs:carbon_mesh_reinforced_circuit_board", "10x gtceu:osmium_foil")
        .itemOutputs("1x kubejs:carbon_mesh_reinforced_printed_circuit_board")

    event.recipes.gtceu.chemical_reactor("carbon_mesh_reinforced_printed_circuit_board_iron3")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(1500)
        .EUt(GTValues.VA[GTValues.HV])
        .inputFluids("gtceu:iron_iii_chloride 2500")
        .itemInputs("1x kubejs:carbon_mesh_reinforced_circuit_board", "10x gtceu:osmium_foil")
        .itemOutputs("1x kubejs:carbon_mesh_reinforced_printed_circuit_board")

    event.recipes.gtceu.autoclave("sapphire_seed_crystal")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(1000)
        .EUt(GTValues.VA[GTValues.UHV])
        .inputFluids("gtceu:omnium 288")
        .itemInputs("2x gtceu:flawless_sapphire_gem", "1x kubejs:heart_of_a_universe")
        .itemOutputs("1x kubejs:sapphire_seed_crystal")

    event.recipes.gtceu.electric_blast_furnace("sapphire_boule")
        .blastFurnaceTemp(10900)
        .duration(22000)
        .EUt(GTValues.VA[GTValues.LuV])
        .inputFluids("gtceu:krypton 8000")
        .itemInputs("12x gtceu:sapphire_block", "16x gtceu:omnium_nugget", "1x kubejs:sapphire_seed_crystal")
        .itemOutputs("1x kubejs:sapphire_boule")

    event.recipes.gtceu.cutter("cut_sapphire_boule_water")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(6000)
        .EUt(GTValues.VA[GTValues.IV])
        .itemInputs("1x kubejs:sapphire_boule")
        .inputFluids(Fluid.of("minecraft:water", 1000))
        .itemOutputs("32x kubejs:sapphire_wafer")
        .chancedOutput("1x kubejs:sapphire_seed_crystal", 5000, 0)

    event.recipes.gtceu.cutter("cut_sapphire_boule_distilled_water")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(4000)
        .EUt(GTValues.VA[GTValues.IV])
        .itemInputs("1x kubejs:sapphire_boule")
        .inputFluids(Fluid.of("gtceu:distilled_water", 750))
        .itemOutputs("32x kubejs:sapphire_wafer")
        .chancedOutput("1x kubejs:sapphire_seed_crystal", 5000, 0)

    event.recipes.gtceu.cutter("cut_sapphire_boule")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(3000)
        .EUt(GTValues.VA[GTValues.IV])
        .itemInputs("1x kubejs:sapphire_boule")
        .inputFluids(Fluid.of("gtceu:lubricant", 250))
        .itemOutputs("32x kubejs:sapphire_wafer")
        .chancedOutput("1x kubejs:sapphire_seed_crystal", 5000, 0)

    event.recipes.gtceu.forge_hammer("sapphire_wafer_smashing")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(20)
        .EUt(GTValues.VA[GTValues.MV])
        .itemInputs("1x kubejs:sapphire_wafer")
        .chancedOutput("1x kubejs:sapphire_seed_crystal", 500, 0)

    // More realistic photolithography (not)
    event.recipes.gtceu.chemical_reactor("sapphire_wafer_coating")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(700)
        .EUt(GTValues.VA[GTValues.IV])
        .inputFluids("gtceu:lithium_niobate 144")
        .itemInputs("1x kubejs:sapphire_wafer", "1x gtceu:indium_phosphide_dust")
        .itemOutputs("1x kubejs:coated_sapphire_wafer")

    event.recipes.gtceu.laser_engraver("sapphire_wafer_engraving")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(500)
        .EUt(GTValues.VA[GTValues.ZPM])
        .itemInputs("1x kubejs:coated_sapphire_wafer")
        .notConsumable("1x #forge:lenses/yellow")
        .itemOutputs("1x kubejs:engraved_sapphire_wafer")

    event.recipes.gtceu.chemical_bath("sapphire_wafer_developing")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(1800)
        .EUt(GTValues.VA[GTValues.HV])
        .inputFluids("gtceu:distilled_water 200")
        .itemInputs("1x kubejs:engraved_sapphire_wafer")
        .chancedItemOutputLogic(ChanceLogic.XOR)
        .chancedOutput("1x kubejs:completed_optical_wafer", 5000, 0)
        .chancedOutput("1x kubejs:incomplete_sapphire_wafer", 5000, 0)

    event.recipes.gtceu.chemical_reactor("sapphire_wafer_recoating")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(350)
        .EUt(GTValues.VA[GTValues.EV])
        .inputFluids("gtceu:lithium_niobate 72")
        .itemInputs("1x kubejs:incomplete_sapphire_wafer", "1x gtceu:small_indium_phosphide_dust")
        .itemOutputs("1x kubejs:coated_sapphire_wafer")

    event.recipes.gtceu.cutter("cut_sapphire_wafer_water")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(1800)
        .EUt(GTValues.VA[GTValues.IV])
        .itemInputs("1x kubejs:completed_optical_wafer")
        .inputFluids(Fluid.of("minecraft:water", 1000))
        .itemOutputs("8x kubejs:optical_chip")

    event.recipes.gtceu.cutter("cut_sapphire_wafer_distilled_water")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(1200)
        .EUt(GTValues.VA[GTValues.IV])
        .itemInputs("1x kubejs:completed_optical_wafer")
        .inputFluids(Fluid.of("gtceu:distilled_water", 750))
        .itemOutputs("8x kubejs:optical_chip")

    event.recipes.gtceu.cutter("cut_sapphire_wafer")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(900)
        .EUt(GTValues.VA[GTValues.IV])
        .itemInputs("1x kubejs:completed_optical_wafer")
        .inputFluids(Fluid.of("gtceu:lubricant", 250))
        .itemOutputs("8x kubejs:optical_chip")

    // Intermediate Components
    event.recipes.gtceu.assembler("electro_optic_modulator_pe")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(600)
        .EUt(GTValues.VA[GTValues.LuV])
        .inputFluids("gtceu:glass 144")
        .itemInputs("1x #forge:lenses/lithium_niobate", "1x #forge:lenses/nether_star", "2x gtceu:indium_tin_barium_titanium_cuprate_foil", "gtceu:small_yttrium_barium_cuprate_spring", "1x gtceu:polyethylene_small_fluid_pipe")
        .itemOutputs("6x kubejs:electro_optic_modulator")

    event.recipes.gtceu.assembler("electro_optic_modulator_pvc")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(600)
        .EUt(GTValues.VA[GTValues.LuV])
        .inputFluids("gtceu:glass 144")
        .itemInputs("1x #forge:lenses/lithium_niobate", "1x #forge:lenses/nether_star", "2x gtceu:indium_tin_barium_titanium_cuprate_foil", "gtceu:small_yttrium_barium_cuprate_spring", "1x gtceu:polyvinyl_chloride_small_item_pipe")
        .itemOutputs("6x kubejs:electro_optic_modulator")

    event.recipes.gtceu.assembler("electro_optic_modulator_ptfe")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(600)
        .EUt(GTValues.VA[GTValues.LuV])
        .inputFluids("gtceu:glass 144")
        .itemInputs("1x #forge:lenses/lithium_niobate", "1x #forge:lenses/nether_star", "2x gtceu:indium_tin_barium_titanium_cuprate_foil", "gtceu:small_yttrium_barium_cuprate_spring", "1x gtceu:polytetrafluoroethylene_small_fluid_pipe")
        .itemOutputs("6x kubejs:electro_optic_modulator")

    event.recipes.gtceu.circuit_assembler("optical_processing_unit")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(800)
        .EUt(GTValues.VA[GTValues.UV])
        .inputFluids("gtceu:dielectric_mirror_solution 1152")
        .itemInputs("8x kubejs:carbon_mesh_reinforced_printed_circuit_board", "gtceu:luv_emitter", "16x gtceu:normal_optical_pipe", "12x gtceu:lumium_foil", "32x gtceu:duranium_bolt")
        .itemOutputs("8x kubejs:optical_processing_unit")

    // Non-PrismaC PSoC Steps

    event.recipes.gtceu.cutter("prism_pane_water")
        .duration(180)
        .EUt(GTValues.VA[GTValues.EV])
        .itemInputs("3x monilabs:prism_glass")
        .inputFluids(Fluid.of("minecraft:water", 1000))
        .itemOutputs("8x kubejs:prism_pane")

    event.recipes.gtceu.cutter("prism_pane_distilled_water")
        .duration(120)
        .EUt(GTValues.VA[GTValues.EV])
        .itemInputs("3x monilabs:prism_glass")
        .inputFluids(Fluid.of("gtceu:distilled_water", 750))
        .itemOutputs("8x kubejs:prism_pane")

    event.recipes.gtceu.cutter("prism_pane_lubricant")
        .duration(90)
        .EUt(GTValues.VA[GTValues.EV])
        .itemInputs("3x monilabs:prism_glass")
        .inputFluids(Fluid.of("gtceu:lubricant", 250))
        .itemOutputs("8x kubejs:prism_pane")

    event.recipes.gtceu.large_chemical_reactor("psoc_base")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(200)
        .EUt(GTValues.VA[GTValues.ZPM])
        .inputFluids("gtceu:dielectric_mirror_solution 144")
        .itemInputs("gtceu:activated_netherite_plate", "gtceu:highly_advanced_soc")
        .notConsumable("gtceu:zpm_emitter")
        .itemOutputs("4x kubejs:photonic_soc_base")

    event.recipes.gtceu.forming_press("psoc_inert")
        .cleanroom(CleanroomType.CLEANROOM)
        .duration(400)
        .EUt(GTValues.VA[GTValues.LuV])
        .itemInputs("kubejs:photonic_soc_base", "gtceu:lithium_niobate_lens", "2x kubejs:prism_pane")
        .itemOutputs("kubejs:photonic_soc_inert")
})
