events.listen("recipes", function (e) {
  function Protection(catalyseur, precedent, nouveau, type) {
    e.remove({ id: nouveau + type });

    e.custom({
      type: "minecraft:smithing",
      base: { item: precedent + type },
      addition: { tag: catalyseur },
      result: { item: nouveau + type },
    });
  }
  var outil = ["leggings", "helmet", "boots", "chestplate"];

  outil.forEach((S) => {
    Protection(
      "forge:ingots/iron",
      "minecraft:chainmail_",
      "minecraft:iron_",
      S
    );
    Protection("forge:ingots/gold", "minecraft:iron_", "minecraft:golden_", S);
    Protection(
      "forge:gems/diamond",
      "minecraft:golden_",
      "minecraft:diamond_",
      S
    );
  });
});
