// priority 10
const tfcStone = [
  "granite",
  "diorite",
  "gabbro",
  "shale",
  "claystone",
  "limestone",
  "conglomerate",
  "dolomite",
  "chert",
  "chalk",
  "rhyolite",
  "basalt",
  "andesite",
  "dacite",
  "quartzite",
  "slate",
  "phyllite",
  "schist",
  "gneiss",
  "marble"
]
const gemStonesA = [
 "amethyst",
 "diamond",
 "emerald",
 "lapis_lazuli",
 "opal",
 "pyrite",
 "ruby",
 "sapphire",
 "topaz"
]
const tfcSaplings = [
  "acacia",
  "ash",
  "aspen",
  "birch",
  "blackwood",
  "chestnut",
  "douglas_fir",
  "hickory",
  "kapok",
  "mangrove",
  "maple",
  "oak",
  "palm",
  "pine",
  "rosewood",
  "sequoia",
  "spruce",
  "sycamore",
  "white_cedar",
  "willow"
]
let recipeAdd = (/** @type {Internal.RecipesEventJS} */ event) => {
  const tfc = event.recipes.tfc
  const shaped = event.recipes.minecraft.crafting_shaped

  // event.replaceOutput({ type: "tfc:anvil" }, "gtceu:wrought_iron_rod", "minecraft:apple")
  /*
  event.custom({
    type: "tfc:anvil",
    input: { tag: "forge:ingots/wrought_iron" },
    result: {
      item: "gtceu:wrought_iron_rod",
      count: 2
    },
    tier: 3,
    rules: ["bend_last", "draw_second_last", "draw_third_last"]
  })
  */
  event.recipes.tfc.anvil(
    "treetap:tap",
    "#forge:ingots/copper",
    ["bend_last", "bend_second_last", "bend_third_last"])
    .tier(1)
    .applyBonus(false)
    .id("gregitas:anvil/treetap")
  /*
  event.custom({
    type: "tfc:anvil",
    input: { tag: "forge:ingots/copper" },
    result: {
      item: "treetap:tap",
      count: 1
    },
    tier: 1,
    rules: ["bend_last", "bend_second_last", "bend_third_last"]
  })
  */

  shaped("tfc:bloomery", ["BBB", "B B", "BBB"], {
    B: "#forge:double_sheets/any_bronze"
  })

  event.custom({
    type: "tfc:glassworking",
    operations: ["blow", "blow", "roll", "pinch", "saw"],
    batch: {
      item: "tfc:silica_glass_batch"
    },
    result: {
      item: "gtceu:glass_tube"
    }
  })

  //Create Start

  shaped("create:millstone", [" M ", " G ", " Q "], {
    M: "tfc:handstone",
    G: "create:cogwheel",
    Q: "tfc:quern"
  })
  gemStonesA.forEach((gemStone) => {
      event.custom({
          type: "tfc:damage_inputs_shapeless_crafting",
          recipe: {
              type: "minecraft:crafting_shapeless",
              ingredients: [
              {
                  tag: "create:sandpaper"
              },
              {
                  item: `tfc:ore\/${gemStone}`
              },
              {
                  tag: "tfc:chisels"
              },
              {
                  tag: "forge:tools/hammers"
              }
              ],
              result: {
                  item: `tfc:gem\/${gemStone}`
              }
          }
        })
    })

  event.custom({
    type: "create:pressing",
    ingredients: [{ item: "tfc:raw_iron_bloom" }],
    results: [{ item: "tfc:refined_iron_bloom" }]
  })
  event.custom({
    type: "create:pressing",
    ingredients: [{ item: "tfc:refined_iron_bloom" }],
    results: [{ item: "tfc:metal/ingot/wrought_iron" }]
  })
  event.custom({
    type: "create:deploying",
    ingredients: [
      {
        item: "create:shaft"
      },
      { tag: "forge:treated_wood" }
    ],
    results: [{ item: "create:cogwheel" }]
  })
  event.custom({
    type: "create:deploying",
    ingredients: [
      {
        item: "create:cogwheel"
      },
      { tag: "forge:treated_wood" }
    ],
    results: [{ item: "create:large_cogwheel" }]
  })
  //Create End

  //GTCEU Start
  shaped("gtceu:primitive_blast_furnace", ["HRS", "PBR", "DRS"], {
    H: "#forge:tools/hammers",
    R: "#forge:rods/steel",
    S: "#forge:screws/steel",
    P: "#forge:sheets/steel",
    B: "gtceu:firebricks",
    D: "#forge:tools/screwdrivers"
  })
  shaped("2x gtceu:coke_oven_bricks", ["BMB","MBM","BMB"], {
    M: "tfc:mortar",
    B: "gtceu:coke_oven_brick"
  })
  event.custom({
    type: "tfc:damage_inputs_shapeless_crafting",
    recipe: {
        type: "minecraft:crafting_shapeless",
        ingredients: [
        {
            tag: "tfc:lumber"
        },
        {
            tag: "tfc:lumber"
        },
        {
            tag: "tfc:lumber"
        },
        {
            tag: "tfc:lumber"
        },
        {
            tag: "forge:tools/saws"
        }
        ],
        result: {
            item: "gtceu:empty_wooden_form"
        }
    }
  })
    event.custom({
      type: "tfc:damage_inputs_shapeless_crafting",
      recipe: {
          type: "minecraft:crafting_shapeless",
          ingredients: [
          {
              item: "gtceu:empty_wooden_form"
          },
          {
              tag: "forge:tools/knives"
          }
          ],
          result: {
              item: "gtceu:brick_wooden_form"
          }
      }
    })
  tfcSaplings.forEach((sapling) => {
    //Greenhouse
    event.recipes.gtceu
      .greenhouse(`gregitas:${sapling}`)
      .circuit(1)
      .notConsumable(`tfc:wood/sapling/${sapling}`)
      .inputFluids(Fluid.of("minecraft:water", 1000))
      .itemOutputs(`64x tfc:wood/log/${sapling}`, `4x tfc:wood/sapling/${sapling}`)
      .duration(640)
      .EUt(MV)

    event.recipes.gtceu
      .greenhouse(`gregitas:${sapling}_boosted`)
      .circuit(2)
      .notConsumable(`tfc:wood/sapling/${sapling}`)
      .itemInputs("4x gtceu:fertilizer")
      .inputFluids(Fluid.of("minecraft:water", 1000))
      .itemOutputs(`64x tfc:wood/log/${sapling}`, `64x tfc:wood/log/${sapling}`, `8x tfc:wood/sapling/${sapling}`)
      .duration(640)
      .EUt(MV)

    //Cutter
    event.recipes.gtceu
      .cutter(`gregitas:${sapling}_lumber_water`)
      .itemInputs(`tfc:wood/log/${sapling}`)
      .inputFluids(Fluid.of("minecraft:water", 4))
      .itemOutputs(`12x tfc:wood/lumber/${sapling}`)
      .duration(120)
      .EUt(LV)

    event.recipes.gtceu
      .cutter(`gregitas:${sapling}_lumber_distilled_water`)
      .itemInputs(`tfc:wood/log/${sapling}`)
      .inputFluids(Fluid.of("gtceu:distilled_water", 3))
      .itemOutputs(`12x tfc:wood/lumber/${sapling}`)
      .duration(80)
      .EUt(LV)

    event.recipes.gtceu
      .cutter(`gregitas:${sapling}_lumber_lubricant`)
      .itemInputs(`tfc:wood/log/${sapling}`)
      .inputFluids(Fluid.of("gtceu:lubricant", 1))
      .itemOutputs(`12x tfc:wood/lumber/${sapling}`)
      .duration(40)
      .EUt(LV)
  })

  shaped('gtceu:treated_wood_planks', ['LL', 'LL'], {L: 'gregitas:creosote_treated_lumber'}).id('gregitas:shaped/treated_wood_planks')
  shaped('gtceu:rubber_planks', ['LL', 'LL'], {L: 'gregitas:rubber_lumber'}).id('gregitas:shaped/rubber_planks')

  event.custom({
    type: "tfc:barrel_sealed",
    input_item: {
      ingredient: {
        tag: 'tfc:lumber'
      }
    },
    input_fluid: {
      ingredient: 'gtceu:creosote',
      amount: 25
    },
    output_item: {
      item: 'gregitas:creosote_treated_lumber'
    },
    duration: 6000
  }).id('gregitas:barrel/creosote_treated_lumber')
  
  //GTCEU End

  //Rock and Stone!
  tfcStone.forEach((stone) => {
    event.recipes.gtceu
      .rock_breaker(`loose_${stone}`)
      .notConsumable(`tfc:rock/raw/${stone}`)
      .itemOutputs(`tfc:rock/raw/${stone}`)
      .duration(16)
      .EUt(LV)
      ["addData(java.lang.String,java.lang.String)"]("fluidA", "minecraft:lava")
      ["addData(java.lang.String,java.lang.String)"]("fluidB", "minecraft:water")
      .addCondition(RockBreakerCondition.INSTANCE)
  })
  //Railcraft Start
  shaped("railcraft:solid_fueled_firebox", ["BBB", "BCB", "BFB"], {
    B: "minecraft:brick",
    C: "minecraft:fire_charge",
    F: "tfc:crucible"
  })

  shaped("framedblocks:framed_chest", ["FRF", "RCR", "FRF"], {
    F: "framedblocks:framed_cube",
    R: "#forge:rods/cast_iron",
    C: "#forge:chests/wooden"
  })

  shaped("framedblocks:framed_secret_storage", ["RFR", "FCF", "RFR"], {
    F: "framedblocks:framed_cube",
    R: "#forge:rods/cast_iron",
    C: "framedblocks:framed_chest"
  })
  //Railcraft End


  //Framed Compacting Drawers Start
  shaped("framedcompactdrawers:framed_full_one", ["SPS", " C ", "SPS"], {
    S: "#forge:screws/brass",
    C: "#forge:chests/wooden",
    P: "#forge:plates/brass"
  })

  shaped("2x framedcompactdrawers:framed_full_two", ["SPS", "C C", "SPS"], {
    S: "#forge:screws/brass",
    C: "#forge:chests/wooden",
    P: "#forge:plates/brass"
  })

  shaped("4x framedcompactdrawers:framed_full_four", ["CSC", "SPS", "CSC"], {
    S: "#forge:screws/brass",
    C: "#forge:chests/wooden",
    P: "gtceu:brass_double_plate"
  })

  shaped("framedcompactdrawers:framed_compact_drawer", ["PSP", "QDQ", "SRS"], {
    P: "#forge:plates/brass",
    S: "#forge:screws/brass",
    Q: "minecraft:piston",
    D: "#forge:chests/wooden",
    R: "minecraft:repeater"
  })

  shaped("framedcompactdrawers:framed_drawer_controller", ["PSP", "TDQ", "SRS"], {
    P: "#forge:plates/brass",
    S: "#forge:screws/brass",
    Q: "minecraft:piston",
    D: "framedcompactdrawers:framed_compact_drawer",
    R: "minecraft:repeater",
    T: "#forge:rods/brass"
  })
  //Framed Compacting Drawers End

  //Ender Tanks & Chests
  shaped('enderchests:ender_chest', ['eOs', 'cCc', 'OfO'], {
    e: 'gtceu:mv_emitter', 
    O: 'gtceu:obsidian_plate', 
    s: 'gtceu:mv_sensor', 
    c: 'gtceu:mv_conveyor_module', 
    C: 'gtceu:lv_super_chest', 
    f: 'gtceu:lv_field_generator'
  })

  shaped('endertanks:ender_tank', ['eOs', 'pTp', 'OfO'], {
    e: 'gtceu:mv_emitter', 
    O: 'gtceu:obsidian_plate', 
    s: 'gtceu:mv_sensor', 
    p: 'gtceu:mv_electric_pump', 
    T: 'gtceu:lv_super_tank', 
    f: 'gtceu:lv_field_generator'
  })
}
