// This File has been authored by AllTheMods Staff, or a Community contributor for use in AllTheMods.
// As all AllTheMods packs are licensed under All Rights Reserved, this file is not allowed to be used in any public packs not released by the AllTheMods Team, without explicit permission.

ServerEvents.tags("item", (allthemods) => {
  let tags = [
    "rftoolsutility:living/highyield",
    "extended_industrialization:farmer_plantable",
    "c:salad_ingredients",
    "c:crops/asparagus",
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:salad_ingredients/asparagus",
    "c:vegetables/asparagus",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:asparagus")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:egg",
    "c:crops",
    "rftoolsutility:living/highyield",
    "c:vegetables",
    "c:fruits",
    "c:vegetables/avocado",
    "extended_industrialization:farmer_plantable",
    "diet:fruits",
    "c:egg/avocado",
    "c:fruits/avocado",
    "c:crops/avocado"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:avocado")
  })

  tags = [
    "c:vinegar_ingredients/barley",
    "rftoolsutility:living/living",
    "c:flour_plants",
    "c:flour_plants/barley",
    "c:grain/barley",
    "c:crops/barley",
    "rftoolsutility:living/highyield",
    "c:grain",
    "c:vinegar_ingredients",
    "c:carbs/barley",
    "c:carbs",
    "extended_industrialization:farmer_plantable",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:barley")
  })

  tags = [
    "c:berries",
    "c:berries/blackberry",
    "c:fruits/blackberries",
    "c:paper_plants",
    "rftoolsutility:living/living",
    "c:crops",
    "rftoolsutility:living/highyield",
    "c:crops/blackberry",
    "c:fruits",
    "extended_industrialization:farmer_plantable",
    "c:paper_plants/blackberry",
    "c:fruits/blackberry"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:blackberry")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:berries",
    "c:fruits/blueberries",
    "extended_industrialization:farmer_plantable",
    "c:fruits",
    "c:fruits/blueberry",
    "rftoolsutility:living/highyield",
    "c:crops",
    "c:crops/blueberry",
    "c:berries/blueberry"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:blueberry")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:salad_ingredients/broccoli",
    "extended_industrialization:farmer_plantable",
    "c:salad_ingredients",
    "c:crops/broccoli",
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:vegetables/broccoli",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:broccoli")
  })

  tags = [
    "c:vegetables/cabbage",
    "rftoolsutility:living/living",
    "c:salad_ingredients/cabbage",
    "c:leafyvegetables/cabbage",
    "extended_industrialization:farmer_plantable",
    "c:leafyvegetables",
    "c:crops/cabbage",
    "c:salad_ingredients",
    "rftoolsutility:living/highyield",
    "c:crops",
    "c:vegetables"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:cabbage")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:vegetables/cauliflower",
    "extended_industrialization:farmer_plantable",
    "c:salad_ingredients",
    "c:salad_ingredients/cauliflower",
    "c:crops/cauliflower",
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:cauliflower")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:vegetables",
    "extended_industrialization:farmer_plantable",
    "c:vegetables/celery",
    "c:crops",
    "rftoolsutility:living/highyield",
    "c:crops/celery"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:celery")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:fruits",
    "extended_industrialization:farmer_plantable",
    "c:vinegar_ingredients",
    "rftoolsutility:living/living",
    "c:vinegar_ingredients/cherry",
    "c:fruits/cherry",
    "c:crops",
    "c:crops/cherry"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:cherries")
  })

  tags = [
    "c:protein/corn",
    "c:carbs/corn",
    "rftoolsutility:living/living",
    "c:crops/corn",
    "c:flour_plants",
    "c:flour_plants/corn",
    "c:protein",
    "rftoolsutility:living/highyield",
    "c:grain/corn",
    "c:grain",
    "c:carbs",
    "extended_industrialization:farmer_plantable",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:corn")
  })

  tags = [
    "c:crops/eggplant",
    "rftoolsutility:living/living",
    "c:vegetables/eggplant",
    "c:vegetables",
    "extended_industrialization:farmer_plantable",
    "c:crops",
    "rftoolsutility:living/highyield"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:eggplant")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:vegetables",
    "c:rootvegetables/garlic",
    "extended_industrialization:farmer_plantable",
    "rftoolsutility:living/highyield",
    "c:crops/garlic",
    "c:crops",
    "supplementaries:cookies",
    "c:rootvegetables",
    "c:vegetables/garlic"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:garlic_bulb")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:crops",
    "rftoolsutility:living/highyield",
    "c:crops/ginger",
    "extended_industrialization:farmer_plantable"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:ginger_root")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:fruits",
    "c:fruits/grapes",
    "c:vinegar_ingredients/grape",
    "c:vinegar_ingredients",
    "extended_industrialization:farmer_plantable",
    "c:crops/grape",
    "rftoolsutility:living/highyield",
    "c:fruits/grape",
    "c:vinegar_ingredients/grapes",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:grapes")
  })

  // Can argue that green beans != beans, but good enough
  tags = [
    "rftoolsutility:living/living",
    "c:grain/bean",
    "extended_industrialization:farmer_plantable",
    "c:grain",
    "rftoolsutility:living/highyield",
    "c:flour_plants/bean",
    "supplementaries:cookies",
    "c:crops/bean",
    "c:crops",
    "c:flour_plants"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:green_bean")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:peppers",
    "c:peppers/bellpepper",
    "extended_industrialization:farmer_plantable",
    "c:crops/bellpepper",
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:vegetables/bellpepper",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:green_pepper")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:crops",
    "rftoolsutility:living/highyield",
    "c:citrusfruits",
    "c:fruits",
    "c:citrusfruits/lemon",
    "c:vinegar_ingredients/lemon",
    "extended_industrialization:farmer_plantable",
    "c:fruits/lemon",
    "diet:fruits",
    "c:vinegar_ingredients",
    "c:crops/lemon"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:lemon")
  })

  tags = [
    "c:vegetables",
    "c:leafyvegetables/lettuce",
    "rftoolsutility:living/living",
    "c:crops/lettuce",
    "extended_industrialization:farmer_plantable",
    "c:vegetables/lettuce",
    "c:leafyvegetables",
    "c:salad_ingredients",
    "rftoolsutility:living/highyield",
    "c:salad_ingredients/lettuce",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:lettuce")
  })

  tags = [
    "c:crops/lime",
    "c:crops",
    "rftoolsutility:living/living",
    "c:vinegar_ingredients/lime",
    "rftoolsutility:living/highyield",
    "c:fruits",
    "c:citrusfruits",
    "c:fruits/lime",
    "extended_industrialization:farmer_plantable",
    "c:citrusfruits/lime",
    "diet:fruits",
    "c:vinegar_ingredients",
    "minecolonies:compostables"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:lime")
  })

  tags = [
    "c:vinegar_ingredients/oats",
    "rftoolsutility:living/highyield",
    "c:crops/oat",
    "extended_industrialization:farmer_plantable",
    "c:crops",
    "c:carbs",
    "c:flour_plants/oats",
    "c:vinegar_ingredients",
    "c:grain/oat",
    "c:flour_plants/oat",
    "c:carbs/oat",
    "c:grain",
    "rftoolsutility:living/living",
    "c:seeds/oat",
    "c:grain/oats",
    "c:crops/oats",
    "c:flour_plants",
    "c:vinegar_ingredients/oat",
    "c:carbs/oats"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:oats")
  })

  tags = [
    "c:rootvegetables/onion",
    "rftoolsutility:living/living",
    "c:rootvegetables",
    "extended_industrialization:farmer_plantable",
    "c:vegetables/onion",
    "c:onions",
    "rftoolsutility:living/highyield",
    "c:crops/onion",
    "c:onions/onion",
    "c:crops",
    "c:vegetables"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:onion")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:vinegar_ingredients/orange",
    "extended_industrialization:farmer_plantable",
    "diet:fruits",
    "c:fruits",
    "c:fruits/orange",
    "rftoolsutility:living/highyield",
    "c:vinegar_ingredients",
    "c:crops",
    "c:crops/orange"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:orange")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:fruits/peach",
    "extended_industrialization:farmer_plantable",
    "c:fruits",
    "diet:fruits",
    "c:vinegar_ingredients/peach",
    "rftoolsutility:living/highyield",
    "c:vinegar_ingredients",
    "c:crops/peach",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:peach")
  })

  tags = [
    "c:fruits/pear",
    "rftoolsutility:living/living",
    "extended_industrialization:farmer_plantable",
    "c:fruits",
    "diet:fruits",
    "rftoolsutility:living/highyield",
    "c:crops/pear",
    "c:vinegar_ingredients",
    "c:vinegar_ingredients/pear",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:pear")
  })

  tags = [
    "extended_industrialization:farmer_plantable",
    "c:crops",
    "c:vegetables/pea",
    "rftoolsutility:living/highyield",
    "c:salad_ingredients/peas",
    "c:crops/pea",
    "c:salad_ingredients/pea",
    "c:salad_ingredients",
    "c:flour_plants/peas",
    "c:seeds/pea",
    "c:flour_plants/pea",
    "c:vegetables/peas",
    "c:flour_plants",
    "c:crops/peas",
    "rftoolsutility:living/living",
    "c:vegetables"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:peas")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:fruits",
    "c:paper_plants/pineapple",
    "extended_industrialization:farmer_plantable",
    "c:crops/pineapple",
    "rftoolsutility:living/living",
    "c:fruits/pineapple",
    "c:paper_plants",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:pineapple")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:fruits/plum",
    "extended_industrialization:farmer_plantable",
    "c:fruits",
    "diet:fruits",
    "rftoolsutility:living/highyield",
    "c:vinegar_ingredients",
    "c:crops/plum",
    "c:crops",
    "c:vinegar_ingredients/plum"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:plum")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "extended_industrialization:farmer_plantable",
    "c:rootvegetables/radish",
    "c:vegetables",
    "c:crops/radish",
    "rftoolsutility:living/living",
    "c:vegetables/radish",
    "c:crops",
    "c:rootvegetables"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:radish")
  })

  tags = [
    "c:crops",
    "c:vinegar_ingredients",
    "c:fruits",
    "c:berries/raspberry",
    "rftoolsutility:living/highyield",
    "c:vinegar_ingredients/raspberry",
    "extended_industrialization:farmer_plantable",
    "c:crops/raspberry",
    "c:berries",
    "c:paper_plants/raspberry",
    "c:paper_plants",
    "c:fruits/raspberries",
    "c:vinegar_ingredients/raspberries",
    "rftoolsutility:living/living",
    "c:fruits/raspberry"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:raspberry")
  })

  tags = [
    "c:flour_plants",
    "c:paper_plants",
    "c:protein",
    "c:crops/rice",
    "c:paper_plants/rice",
    "c:protein/rice",
    "c:vinegar_ingredients/rice",
    "c:carbs/rice",
    "c:vinegar_ingredients",
    "c:crops",
    "c:flour_plants/rice",
    "rftoolsutility:living/highyield",
    "extended_industrialization:farmer_plantable",
    "rftoolsutility:living/living",
    "c:carbs",
    "c:grain",
    "c:grain/rice"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:rice")
  })

  tags = [
    "c:crops/rye",
    "c:vinegar_ingredients/rye",
    "rftoolsutility:living/living",
    "c:flour_plants",
    "c:grain/rye",
    "c:carbs/rye",
    "rftoolsutility:living/highyield",
    "c:grain",
    "c:vinegar_ingredients",
    "c:flour_plants/rye",
    "c:carbs",
    "extended_industrialization:farmer_plantable",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:rye")
  })

  // Good enough match
  tags = [
    "c:vegetables/wintersquash",
    "c:crops/wintersquash",
    "rftoolsutility:living/living",
    "c:vegetables",
    "extended_industrialization:farmer_plantable",
    "c:crops",
    "rftoolsutility:living/highyield"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:wintersquash")
  })

  tags = [
    "rftoolsutility:living/living",
    "c:berries",
    "extended_industrialization:farmer_plantable",
    "c:fruits/strawberry",
    "c:fruits",
    "c:fruits/strawberries",
    "c:crops/strawberry",
    "rftoolsutility:living/highyield",
    "c:berries/strawberry",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:strawberry")
  })

  tags = [
    "c:seeds/sweet_potato",
    "rftoolsutility:living/highyield",
    "c:rootvegetables/sweetpotato",
    "c:vegetables",
    "c:crops/sweetpotato",
    "c:vegetables/sweet_potato",
    "extended_industrialization:farmer_plantable",
    "c:carbs",
    "c:crops",
    "c:vegetables/sweetpotato",
    "c:protein/sweetpotato",
    "c:crops/sweet_potato",
    "c:rootvegetables/sweet_potato",
    "c:rootvegetables",
    "rftoolsutility:living/living",
    "c:carbs/sweet_potato",
    "c:protein",
    "c:protein/sweet_potato",
    "c:carbs/sweetpotato"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:sweet_potato")
  })

  tags = [
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:vegetables/tomato",
    "c:vinegar_ingredients/tomato",
    "extended_industrialization:farmer_plantable",
    "c:salad_ingredients",
    "c:vinegar_ingredients",
    "c:salad_ingredients/tomato",
    "rftoolsutility:living/highyield",
    "c:crops/tomato",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:tomato")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:rootvegetables/turnip",
    "c:crops/turnip",
    "extended_industrialization:farmer_plantable",
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:vegetables/turnip",
    "c:crops",
    "c:rootvegetables"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:turnip")
  })

  tags = [
    "rftoolsutility:living/highyield",
    "c:crops/zucchini",
    "c:vegetables/zucchini",
    "c:salad_ingredients",
    "extended_industrialization:farmer_plantable",
    "c:vegetables",
    "rftoolsutility:living/living",
    "c:salad_ingredients/zucchini",
    "c:crops"
  ]
  tags.forEach((tag) => {
    allthemods.add(tag, "herbsandharvest:zucchini")
  })

  // Not present in other mods
  const spices = [
    "herbsandharvest:turmeric_root",
    "herbsandharvest:fresh_basil",
    "herbsandharvest:fresh_bay_leaf",
    "herbsandharvest:fresh_bay_leaf",
    "herbsandharvest:fresh_chive",
    "herbsandharvest:fresh_cilantro",
    "herbsandharvest:fresh_dill",
    "herbsandharvest:fresh_lemongrass",
    "herbsandharvest:fresh_mint"
  ]
  spices.forEach((spice) => {
    allthemods.add("c:spices", spice)
  })

  // Small tweaks
  allthemods.add("c:onions/onion", "farmersdelight:onion")
  allthemods.add("c:onions", "farmersdelight:onion")
})

ServerEvents.recipes((allthemods) => {
  if (Platform.isLoaded("merrymaking")) {
    allthemods.remove([
      {
        id: "merrymaking:poultry_dinner"
      },
      {
        id: "merrymaking:latke"
      },
      {
        id: "merrymaking:sweet_potato_pie"
      },
      {
        id: "merrymaking:icing"
      },
      {
        id: "merrymaking:ground_ginger"
      },
      {
        id: "merrymaking:cookie_dough"
      },
      {
        id: "merrymaking:gingerbread_dough"
      },
      {
        id: "merrymaking:harvest_tray"
      }
    ])

    allthemods
      .shaped("merrymaking:stuffed_poultry_dinner", ["ABC", "DEF"], {
        A: "merrymaking:quartz_platter",
        B: "#c:vegetables/sweet_potato",
        C: "#c:grain/corn",
        D: "minecraft:carrot",
        E: "minecraft:potato",
        F: "minecraft:beetroot"
      })
      .id("allthemods:merrymaking/poultry_dinner")

    allthemods
      .shapeless("merrymaking:latke", ["minecraft:potato", "#c:onions/onion", "minecraft:egg", "minecraft:wheat"])
      .id("allthemods:merrymaking/latke")

    allthemods
      .shapeless("merrymaking:sweet_potato_pie", [
        "#c:milk",
        "minecraft:wheat",
        "minecraft:sugar",
        "minecraft:egg",
        "#c:vegetables/sweet_potato"
      ])
      .id("allthemods:merrymaking/sweet_potato_pie")

    allthemods
      .shapeless("8x merrymaking:icing", ["minecraft:sugar", "#c:milk", "minecraft:bowl"])
      .id("allthemods:merrymaking/icing")

    allthemods.shapeless("8x merrymaking:ground_ginger", ["#c:crops/ginger"]).id("allthemods:merrymaking/ground_ginger")

    allthemods
      .shapeless("merrymaking:cookie_dough", ["#c:milk", "minecraft:wheat", "minecraft:sugar", "minecraft:egg"])
      .id("allthemods:merrymaking/cookie_dough")

    allthemods
      .shapeless("merrymaking:gingerbread_dough", [
        "merrymaking:ground_ginger",
        "#c:milk",
        "minecraft:wheat",
        "minecraft:sugar",
        "minecraft:egg"
      ])
      .id("allthemods:merrymaking/gingerbread_dough")

    allthemods
      .shapeless("merrymaking:harvest_tray", [
        "merrymaking:empty_tray",
        "#c:vegetables/sweet_potato",
        "#c:grain/corn",
        "minecraft:carrot",
        "minecraft:apple",
        "minecraft:potato",
        "minecraft:sweet_berries",
        "minecraft:beetroot",
        "minecraft:wheat"
      ])
      .id("allthemods:merrymaking/harvest_tray")
  }

  if (Platform.isLoaded("herbsandharvest")) {
    // Saplings
    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:avocado_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:cherry_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:lemon_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:lime_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:orange_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:peach_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:pear_fruit_sapling"
      }
    })

    allthemods.custom({
      type: "farmingforblockheads:market",
      category: "farmingforblockheads:saplings",
      preset: "herbsandharvest:saplings",
      result: {
        count: 1,
        item: "herbsandharvest:plum_fruit_sapling"
      }
    })
  }
})

// This File has been authored by AllTheMods Staff, or a Community contributor for use in AllTheMods.
// As all AllTheMods packs are licensed under All Rights Reserved, this file is not allowed to be used in any public packs not released by the AllTheMods Team, without explicit permission.
