// priority: 0

// Visit the wiki for more info - https://kubejs.com/

console.info("Hello, World! (Loaded server scripts)");

var items = ["iron", "gold", "copper", "zinc", "lead", "nickel"];
var itemsv = ["iron", "gold"];
var itemsc = ["copper", "zinc"];
var itemsm = ["lead", "nickel"];

//

ServerEvents.recipes((event) => {
  console.log("Hello! The recipe event has fired!");

  for (const element of itemsv) {
    event
      .blasting(
        "10x minecraft:" + element + "_nugget",
        "kubejs:" + element + "_dust"
      )
      .xp(0.35);
    event
      .blasting(
        "10x minecraft:" + element + "_nugget",
        "kubejs:" + element + "_float"
      )
      .xp(0.35);
    event.stonecutting(
      "2x minecraft:" + element + "_ingot",
      "kubejs:" + element + "_chunk"
    );
  }
  for (const element of itemsc) {
    event
      .blasting(
        "10x create:" + element + "_nugget",
        "kubejs:" + element + "_dust"
      )
      .xp(0.35);
    event
      .blasting(
        "10x create:" + element + "_nugget",
        "kubejs:" + element + "_float"
      )
      .xp(0.35);
  }
  event.stonecutting("2x minecraft:copper_ingot", "kubejs:copper_chunk");
  event.stonecutting("2x create:zinc_ingot", "kubejs:zinc_chunk");

  for (const element of itemsm) {
    event
      .blasting(
        "immersiveengineering:ingot_" + element,
        "kubejs:" + element + "_dust"
      )
      .xp(0.35);
    event
      .blasting(
        "immersiveengineering:ingot_" + element,
        "kubejs:" + element + "_float"
      )
      .xp(0.35);
    event.stonecutting(
      "2x immersiveengineering:ingot_" + element,
      "kubejs:" + element + "_chunk"
    );
  }

  for (const element of itemsv) {
    event.custom({
      type: "farmersdelight:cutting",
      ingredients: [
        {
          item: "minecraft:raw_" + element,
        },
      ],
      tool: {
        type: "farmersdelight:tool_action",
        action: "pickaxe_dig",
      },
      result: [
        {
          item: "create:crushed_raw_" + element,
          count: 1,
        },
      ],
    });
  }
  event.custom({
    type: "farmersdelight:cutting",
    ingredients: [
      {
        item: "minecraft:raw_copper",
      },
    ],
    tool: {
      type: "farmersdelight:tool_action",
      action: "pickaxe_dig",
    },
    result: [
      {
        item: "create:crushed_raw_copper",
        count: 1,
      },
    ],
  });
  event.custom({
    type: "farmersdelight:cutting",
    ingredients: [
      {
        item: "create:raw_zinc",
      },
    ],
    tool: {
      type: "farmersdelight:tool_action",
      action: "pickaxe_dig",
    },
    result: [
      {
        item: "create:crushed_raw_zinc",
        count: 1,
      },
    ],
  });

  for (const element of items) {
    event.custom({
      type: "farmersdelight:cooking",
      recipe_book_tab: "meals",
      ingredients: [
        {
          item: "kubejs:" + element + "_dust",
        },
        {
          item: "minecraft:kelp",
        },
      ],
      result: {
        item: "kubejs:" + element + "_float",
        count: 2,
      },
      container: {
        item: "minecraft:bowl",
      },
      experience: 1.0,
      cookingtime: 100,
    });
    event.recipes.create.milling(
      [
        "kubejs:" + element + "_dust",
        Item.of("kubejs:" + element + "_dust").withChance(0.5),
      ],
      "create:crushed_raw_" + element
    );
    event.campfireCooking(
      "kubejs:" + element + "_chunk",
      "kubejs:" + element + "_float",
      0.35,
      200
    );
    event.recipes.create.mixing(
      ["2x kubejs:" + element + "_float"],
      ["kubejs:" + element + "_dust", Fluid.water(100)]
    );

    event.recipes.create.compacting(
      ["kubejs:" + element + "_chunk", Fluid.water(100)],
      "kubejs:" + element + "_float"
    );
  }
});
