events.listen("recipes", function (e) {
  function cookSeed(level, catalyseur, name) {
    e.remove({ id: "mysticalagriculture:seed/infusion/" + name });
    craft = "mysticalagriculture:" + name + "_seeds";

    if (level == 1) {
      (seedDeBase = "kubejs:inferium_seed"), (prix = "minecraft:redstone");
    } else if (level == 2) {
      (seedDeBase = "kubejs:prudentium_seed"), (prix = "minecraft:diamond");
    } else if (level == 3) {
      (seedDeBase = "kubejs:tertium_seed"), (prix = "minecraft:diamond_block");
    } else if (level == 4) {
      (seedDeBase = "kubejs:imperium_seed"), (prix = "minecraft:emerald");
    } else if (level == 5) {
      (seedDeBase = "kubejs:supremium_seed"),
        (prix = "minecraft:emerald_block");
    }
    //creation recette
    e.custom({
      type: "thermal:smelter",
      ingredients: [
        { value: [{ item: seedDeBase }], count: 1 },
        { value: [{ item: catalyseur }], count: 4 },
        { value: [{ item: prix }], count: 4 },
      ],
      result: [{ item: craft }],
      energy: 64000,
    });
  }

  //craft graine tier elementaire
  cookSeed(1, "mysticalagriculture:air_agglomeratio", "air");
  cookSeed(1, "mysticalagriculture:fire_agglomeratio", "fire");
  cookSeed(1, "mysticalagriculture:earth_agglomeratio", "earth");
  cookSeed(1, "mysticalagriculture:water_agglomeratio", "water");
  //craft graine tier 1
  cookSeed(1, "minecraft:cobblestone", "stone");
  cookSeed(1, "minecraft:dirt", "dirt");
  cookSeed(1, "minecraft:oak_log", "wood");
  cookSeed(1, "minecraft:ice", "ice");

  //craft graine tier 2
  cookSeed(2, "mysticalagriculture:nature_agglomeratio", "nature");
  cookSeed(2, "minecraft:bone_meal", "dye");
  cookSeed(2, "minecraft:netherrack", "nether");
  cookSeed(2, "minecraft:coal", "coal");
  cookSeed(2, "minecraft:dead_tube_coral_block", "coral");
  cookSeed(2, "minecraft:honey_bottle", "honey");
  cookSeed(2, "industrialforegoing:dryrubber", "rubber");
  cookSeed(2, "appliedenergistics2:silicon", "silicon");
  cookSeed(2, "thermal:sulfur_dust", "sulfur");
  cookSeed(2, "alltheores:aluminum_ingot", "aluminum");
  cookSeed(2, "alltheores:copper_ingot", "copper");
  cookSeed(2, "thermal:niter_dust", "saltpeter");
  cookSeed(2, "thermal:apatite", "apatite");
  cookSeed(2, "botania:fertilizer", "mystical_flower");
  cookSeed(2, "astralsorcery:marble_runed", "marble");
  cookSeed(2, "create:polished_limestone", "limestone");
  cookSeed(2, "minecraft:basalt", "basalt");

  //craft graine tier 3
  cookSeed(3, "appliedenergistics2:certus_quartz_crystal", "certus_quartz");
  cookSeed(3, "appliedenergistics2:sky_stone_block", "sky_stone");
  cookSeed(3, "create:brass_block", "brass");
  cookSeed(3, "alltheores:silver_block", "silver");
  cookSeed(3, "alltheores:lead_block", "lead");
  cookSeed(3, "alltheores:zinc_block", "zinc");
  cookSeed(3, "tconstruct:slimesteel_block", "slimesteel");
  cookSeed(3, "quark:biotite", "ender_biotite");
  cookSeed(3, "tconstruct:pig_iron_block", "pig_iron");
  cookSeed(3, "thermal:bronze_block", "bronze");
  cookSeed(3, "botania:manasteel_block", "manasteel");
  cookSeed(3, "minecraft:iron_block", "iron");
  cookSeed(3, "minecraft:glowstone", "glowstone");
  cookSeed(3, "minecraft:redstone_block", "redstone");
  cookSeed(3, "minecraft:obsidian", "obsidian");
  cookSeed(3, "tconstruct:tinkers_bronze_block", "tinkers_bronze");
  cookSeed(3, "minecraft:prismarine", "prismarine");
  cookSeed(3, "minecraft:quartz_block", "nether_quartz");
  cookSeed(3, "astralsorcery:aquamarine", "aquamarine");
  cookSeed(3, "bigreactors:graphite_block", "graphite");
  cookSeed(3, "twilightforest:steeleaf_block", "steeleaf");
  cookSeed(3, "twilightforest:ironwood_block", "ironwood");
  cookSeed(3, "alltheores:tin_block", "tin");

  //craft graine tier 4
  cookSeed(4, "minecraft:lapis_block", "lapis_lazuli");
  cookSeed(4, "minecraft:end_stone", "end");
  cookSeed(4, "mekanism:block_steel", "steel");
  cookSeed(4, "alltheores:nickel_block", "nickel");
  cookSeed(4, "thermal:constantan_block", "constantan");
  cookSeed(4, "thermal:electrum_block", "electrum");
  cookSeed(4, "thermal:invar_block", "invar");
  cookSeed(4, "alltheores:uranium_block", "uranium");
  cookSeed(4, "thermal:ruby_block", "ruby");
  cookSeed(4, "thermal:sapphire_block", "sapphire");
  cookSeed(4, "thermal:signalum_block", "signalum");
  cookSeed(4, "thermal:lumium_block", "lumium");
  cookSeed(4, "astralsorcery:starmetal", "starmetal");
  cookSeed(4, "mekanism:block_refined_obsidian", "refined_obsidian");
  cookSeed(4, "mekanism:block_refined_glowstone", "refined_glowstone");
  cookSeed(4, "powah:blazing_crystal_block", "blazing_crystal");
  cookSeed(4, "kubejs:hop_block", "hop_graphite");
  cookSeed(4, "tconstruct:cobalt_block", "cobalt");
  cookSeed(4, "tconstruct:rose_gold_block", "rose_gold");
  cookSeed(4, "botania:elementium_block", "elementium");
  cookSeed(4, "alltheores:osmium_block", "osmium");
  cookSeed(4, "mekanism:fluorite_gem", "fluorite");
  cookSeed(4, "powah:energized_steel_block", "energized_steel");
  cookSeed(4, "appliedenergistics2:fluix_block", "fluix");
  cookSeed(4, "minecraft:gold_block", "gold");
  cookSeed(4, "pneumaticcraft:compressed_iron_block", "compressed_iron");
  cookSeed(4, "twilightforest:fiery_block", "fiery_ingot");
  cookSeed(4, "twilightforest:knightmetal_block", "knightmetal");

  //craft graine tier 5
  cookSeed(5, "astralsorcery:marble_engraved", "rock_crystal");
  cookSeed(5, "minecraft:diamond_block", "diamond");
  cookSeed(5, "minecraft:emerald", "emerald");
  cookSeed(5, "minecraft:netherite_block", "netherite");
  cookSeed(5, "alltheores:platinum_block", "platinum");
  cookSeed(5, "thermal:enderium_block", "enderium");
  cookSeed(5, "tconstruct:manyullyn_block", "manyullyn");
  cookSeed(5, "tconstruct:queens_slime_block", "queens_slime");
  cookSeed(5, "tconstruct:hepatizon_block", "hepatizon");
  cookSeed(5, "botania:terrasteel_block", "terrasteel");
  cookSeed(5, "draconicevolution:draconium_block", "draconium");
  cookSeed(5, "powah:niotic_crystal_block", "niotic_crystal");
  cookSeed(5, "powah:spirited_crystal_block", "spirited_crystal");
  cookSeed(5, "powah:uraninite_block", "uraninite");
  cookSeed(5, "bigreactors:yellorium_block", "yellorium");
  cookSeed(5, "bigreactors:cyanite_block", "cyanite");

  //tier 6
  function grainetier6(graine, itemA) {
    e.custom({
      type: "mysticalagriculture:infusion",

      input: {
        item: "kubejs:insanium_seed",
      },
      ingredients: [
        {
          item: itemA,
        },
        {
          item: "mysticalagradditions:insanium_essence",
        },
        {
          item: itemA,
        },
        {
          item: "mysticalagradditions:insanium_essence",
        },
        {
          item: itemA,
        },
        {
          item: "mysticalagradditions:insanium_essence",
        },
        {
          item: itemA,
        },
        {
          item: "mysticalagradditions:insanium_essence",
        },
      ],
      result: {
        item: graine,
      },
    });
  }

  grainetier6(
    "mysticalagriculture:nether_star_seeds",
    "mysticalagradditions:nether_star_crux"
  );
  grainetier6(
    "mysticalagriculture:dragon_egg_seeds",
    "mysticalagradditions:dragon_egg_crux"
  );
  grainetier6(
    "mysticalagriculture:awakened_draconium_seeds",
    "mysticalagradditions:awakened_draconium_crux"
  );
  grainetier6(
    "mysticalagriculture:nitro_crystal_seeds",
    "mysticalagradditions:nitro_crystal_crux"
  );
  grainetier6("mysticalagriculture:alfstein_seeds", "kubejs:alfsteel_crux");
  grainetier6("mysticalagriculture:tanium_seeds", "kubejs:tanium_crux");

  //thermal isolator
  e.custom({
    type: "thermal:insolator",
    ingredient: {
      item: "mysticalagriculture:awakened_draconium_seeds",
    },
    result: [
      {
        item: "mysticalagriculture:awakened_draconium_essence",
        chance: 1.0,
      },
      {
        item: "mysticalagriculture:awakened_draconium_seeds",
        chance: 1.0,
      },
    ],
  });
  e.custom({
    type: "thermal:insolator",
    ingredient: {
      item: "mysticalagriculture:nitro_crystal_seeds",
    },
    result: [
      {
        item: "mysticalagriculture:nitro_crystal_essence",
        chance: 1.0,
      },
      {
        item: "mysticalagriculture:nitro_crystal_seeds",
        chance: 1.0,
      },
    ],
  });

  //oeuf pglin barbare
  e.custom({
    type: "mysticalagriculture:infusion",

    input: {
      item: "minecraft:egg",
    },
    ingredients: [
      {
        item: "mysticalagriculture:supremium_block",
      },
      {
        item: "mysticalagriculture:piglin_brute_essence",
      },
      {
        item: "mysticalagriculture:supremium_block",
      },
      {
        item: "mysticalagriculture:piglin_brute_essence",
      },
      {
        item: "mysticalagriculture:supremium_block",
      },
      {
        item: "mysticalagriculture:piglin_brute_essence",
      },
      {
        item: "mysticalagriculture:supremium_block",
      },
      {
        item: "mysticalagriculture:piglin_brute_essence",
      },
    ],
    result: {
      item: "minecraft:piglin_brute_spawn_egg",
    },
  });
  //craft egg cave pider
  e.custom({
    type: "mysticalagriculture:infusion",

    input: {
      item: "minecraft:egg",
    },
    ingredients: [
      {
        item: "mysticalagriculture:tertium_block",
      },
      {
        item: "kubejs:glande_veni",
      },
      {
        item: "mysticalagriculture:tertium_block",
      },
      {
        item: "mysticalagriculture:spider_essence",
      },
      {
        item: "mysticalagriculture:tertium_block",
      },
      {
        item: "mysticalagriculture:spider_essence",
      },
      {
        item: "mysticalagriculture:tertium_block",
      },
      {
        item: "mysticalagriculture:spider_essence",
      },
    ],
    result: {
      item: "minecraft:cave_spider_spawn_egg",
    },
  });
});
