/**
 * 需要能烧成铁粒的泰拉饰品 方便空岛前期出铁
 */
const CONFLUENCE_TO_IRON_NUGGET = [
  "confluence:tally_counter",
  "confluence:dps_meter",
];

// Yakurum BLOCKS that craft FROM a yakurum resource -- re-enabled (storage/deco blocks; the resources
// drop from the Water Lucky Block). Everything else yakurum stays lucky-block-only, and the reverse
// block->resource "uncraft" recipes stay disabled too (matched by recipe OUTPUT below).
const YAKURUM_CRAFTABLE_BLOCKS = [
  "aquamarine_block", "bitominous_coal_block", "bitominous_lantern", "bitominous_torch",
  "coral_crystal_block", "crystal_gem_block", "fish_tank_block", "frostarce_pearl_block",
  "guardian_block", "pearl_block", "prismarine_gem_block", "sea_shell_block",
  "triton_scale_block", "tropical_slime_block", "water_diamond_block",
];

// For each block above, keep BOTH its craft (resource->block, matched by OUTPUT) AND its block->resource
// "uncraft" (recipe id "<block>_to_item"; the 5 deco blocks have no such recipe -> harmless no-op).
const YAKURUM_KEEP = [];
YAKURUM_CRAFTABLE_BLOCKS.forEach(function (b) {
  YAKURUM_KEEP.push({ output: "yakurum:" + b });
  YAKURUM_KEEP.push({ id: "yakurum:" + b + "_to_item" });
});

/**
 * 配方配置
 */
ServerEvents.recipes((event) => {
  // 配方阶段还未实现，先屏蔽合成，由任务获取
  event.remove([
    "lucky:lucky_block",
    "mutantsbuff:aadd",
    "mutantsbuff:creeper_shard_plus_hammer",
    "mutantsbuff:creeper_shard_plus_ham_2"
  ]);
  // All content-mod recipes must come from lucky blocks only. Blanket per-mod removal,
  // update-proof: every current AND future recipe of each mod is dropped. This replaces the
  // disable_mod_recipes OpenLoader datapack, which listed each recipe and drifted on mod updates
  // (it had missed Yakurum + Majrusz recipes).
  ["confluence", "fuze_relics", "majruszsdifficulty", "mutantmonsters"].forEach((mod) => {
    event.remove({ mod: mod });
  });
  // yakurum: same blanket removal, but KEEP both the craft AND the block->resource uncraft of each
  // yakurum-resource block (YAKURUM_KEEP, built above). Everything else yakurum stays lucky-block-only.
  event.remove({ mod: "yakurum", not: { or: YAKURUM_KEEP } });
  // "lucky" is special: drop every lucky-block CRAFT (base lucky:lucky_block, lucky:addons and all
  // addon block recipes -- update-proof) but KEEP the two recipes the old disable_mod_recipes datapack
  // left craftable:
  //   - lucky:luck  = the luck INFUSION (LuckModifierCraftingRecipe / crafting_luck), a core feature
  //   - lucky:lucky_world_invasion_lucky_block = the pack's signature LWI lucky block (craftable)
  // 1.2.12 put "lucky" in the blanket above and removed BOTH; the first hotfix kept only lucky:luck
  // and still wrongly dropped the LWI block craft.
  event.remove({ mod: "lucky", not: { or: [{ id: "lucky:luck" }, { id: "lucky:lucky_world_invasion_lucky_block" }] } });
  // 熔炉
  CONFLUENCE_TO_IRON_NUGGET.forEach((item) => {
    event.smelting("minecraft:iron_nugget", item, 0.1, 100);
  });
  // 锻造台
  event.smithing(
    "mutantsbuff:charged_hammer",
    "mutantmonsters:hulk_hammer",
    "mutantmonsters:creeper_shard"
  );
  event.smithing(
    "mutantsbuff:upgraded_hulk_hammer",
    "mutantmonsters:hulk_hammer",
    "mutantsbuff:flame_orb"
  );
});
