ServerEvents.recipes((event) => {
  const recipes = [
    {
      output: "botanypots:terracotta_hopper_botany_pot",
      input: ["botanypots:terracotta_botany_pot", "minecraft:hopper"],
    },
    {
      output: "botanypotstiers:elite_terracotta_hopper_botany_pot",
      input: [
        "botanypotstiers:elite_terracotta_botany_pot",
        "minecraft:hopper",
      ],
    },
    {
      output: "botanypotstiers:ultra_terracotta_hopper_botany_pot",
      input: [
        "botanypotstiers:ultra_terracotta_botany_pot",
        "minecraft:hopper",
      ],
    },
    {
      output: "botanypotstiers:creative_terracotta_hopper_botany_pot",
      input: [
        "botanypotstiers:creative_terracotta_botany_pot",
        "minecraft:hopper",
      ],
    },
  ];

  recipes.forEach((recipe) => {
    const parts = recipe.output.split(":");
    const itemName = parts[1];
    const id = `infinitynexus:${itemName}`;

    // Processar cada ingrediente individualmente
    const ingredients = recipe.input.map((input) => {
      const inputParts = input.split("x ");
      const quantity =
        inputParts.length > 1 ? parseInt(inputParts[0].trim(), 10) : 1;
      const item =
        inputParts.length > 1 ? inputParts[1].trim() : inputParts[0].trim();
      return Array(quantity).fill({ item: item });
    });

    // Adicionar a receita personalizada
    event
      .custom({
        type: "minecraft:crafting_shapeless",
        result: {
          item: recipe.output,
        },
        ingredients: ingredients,
      })
      .id(id);
  });
});
