ServerEvents.recipes(event => {
  let metalMinecraftItem = [
    "helmet",
    "chestplate",
    "leggings",
    "boots",
    "sword",
    "axe",
    "pickaxe",
    "shovel",
    "hoe",
  ];

  let metalJaamsItem = [
    "battle_axe",
    "broadsword",
    "buster_sword",
    "butterfly_sword",
    "claw",
    "cleaver",
    "dagger",
    "dagger_reverse",
    "greathammer",
    "greatsword",
    "hammer",
    "hook_sword",
    "kama",
    "katana",
    "katar",
    "knuckle",
    "longsword",
    "machete",
    "ring",
    "saw_cleaver",
    "saw_cleaver_unfolded",
    "scythe",
    "sickle",
    "spear",
    "twinblade",
    "zweihander"
  ];

  let metalShieldItem = [
    "shield"
  ];

  let metalBowItem = [
    "bow"
  ];

  let metalArrowItem = [
    "arrow"
  ];


  event.shapeless(
    Item.of(`kubejs:iron_upgrade_tablet`, 1),
    [
      `sortilege:limitite`,
      'minecraft:iron_ingot',
      'minecraft:iron_ingot',
      'minecraft:iron_ingot',
    ]
  );
  
  event.shapeless(
    Item.of(`kubejs:diamond_upgrade_tablet`, 1),
    [
      `sortilege:limitite`,
      'minecraft:diamond',
      'minecraft:diamond',
      'minecraft:diamond',
    ]
  );
  
  event.shapeless(
    Item.of(`kubejs:netherite_upgrade_tablet`, 1),
    [
      `sortilege:limitite`,
      'minecraft:netherite_scrap',
      'minecraft:netherite_scrap',
      'minecraft:netherite_scrap',
    ]
  );


// Wooden -> Iron recipes

metalMinecraftItem.forEach(type => {
  event.shapeless(
    Item.of(`minecraft:iron_${type}`, 1),
    [
      `minecraft:wooden_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`minecraft:wooden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalMinecraftItem.forEach(type => {
  event.shapeless(
    Item.of(`minecraft:iron_${type}`, 1),
    [
      `minecraft:leather_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`minecraft:leather_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalJaamsItem.forEach(type => {
  event.shapeless(
    Item.of(`jaams_weaponry:iron_${type}`, 1),
    [
      `jaams_weaponry:wooden_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`jaams_weaponry:wooden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalShieldItem.forEach(type => {
  event.shapeless(
    Item.of(`shieldexp:iron_${type}`, 1),
    [
      `shieldexp:wooden_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`shieldexp:wooden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalBowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:iron_${type}`, 1),
    [
      `archeryexp:wooden_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`archeryexp:wooden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})



// Stone -> Iron recipes

metalMinecraftItem.forEach(type => {
  event.shapeless(
    Item.of(`minecraft:iron_${type}`, 1),
    [
      `minecraft:stone_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`minecraft:stone_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalJaamsItem.forEach(type => {
  event.shapeless(
    Item.of(`jaams_weaponry:iron_${type}`, 1),
    [
      `jaams_weaponry:stone_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`jaams_weaponry:stone_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalShieldItem.forEach(type => {
  event.shapeless(
    Item.of(`shieldexp:iron_${type}`, 1),
    [
      `shieldexp:stone_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`shieldexp:stone_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalBowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:iron_${type}`, 1),
    [
      `archeryexp:stone_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`archeryexp:stone_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalArrowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:iron_${type}`, 1),
    [
      `archeryexp:stone_${type}`,
      'kubejs:iron_upgrade_tablet',
    ]
  )
})




// Golden -> Diamond recipes

metalMinecraftItem.forEach(type => {
  event.shapeless(
    Item.of(`minecraft:diamond_${type}`, 1),
    [
      `minecraft:golden_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`minecraft:golden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalJaamsItem.forEach(type => {
  event.shapeless(
    Item.of(`jaams_weaponry:diamond_${type}`, 1),
    [
      `jaams_weaponry:golden_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`jaams_weaponry:golden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalShieldItem.forEach(type => {
  event.shapeless(
    Item.of(`shieldexp:diamond_${type}`, 1),
    [
      `shieldexp:golden_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`shieldexp:golden_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})




// Iron -> Diamond recipes

metalMinecraftItem.forEach(type => {
  event.shapeless(
    Item.of(`minecraft:diamond_${type}`, 1),
    [
      `minecraft:iron_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`minecraft:iron_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalJaamsItem.forEach(type => {
  event.shapeless(
    Item.of(`jaams_weaponry:diamond_${type}`, 1),
    [
      `jaams_weaponry:iron_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`jaams_weaponry:iron_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalShieldItem.forEach(type => {
  event.shapeless(
    Item.of(`shieldexp:diamond_${type}`, 1),
    [
      `shieldexp:iron_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`shieldexp:iron_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalBowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:diamond_${type}`, 1),
    [
      `archeryexp:iron_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`archeryexp:iron_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalArrowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:diamond_${type}`, 1),
    [
      `archeryexp:iron_${type}`,
      'kubejs:diamond_upgrade_tablet',
    ]
  )
})




// Diamond -> Netherite recipes

metalMinecraftItem.forEach(type => {
  event.shapeless(
    Item.of(`minecraft:netherite_${type}`, 1),
    [
      `minecraft:diamond_${type}`,
      'kubejs:netherite_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`minecraft:diamond_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalJaamsItem.forEach(type => {
  event.shapeless(
    Item.of(`jaams_weaponry:netherite_${type}`, 1),
    [
      `jaams_weaponry:diamond_${type}`,
      'kubejs:netherite_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`jaams_weaponry:diamond_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalShieldItem.forEach(type => {
  event.shapeless(
    Item.of(`shieldexp:netherite_${type}`, 1),
    [
      `shieldexp:diamond_${type}`,
      'kubejs:netherite_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`shieldexp:diamond_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalBowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:netherite_${type}`, 1),
    [
      `archeryexp:diamond_${type}`,
      'kubejs:netherite_upgrade_tablet',
    ]
  ).modifyResult((grid, result) => {
    let input = grid.find(Item.of(`archeryexp:diamond_${type}`))
    if (input) {
      result.nbt = input.nbt
      result.damageValue = input.damageValue
    }
    return result
  });
})

metalArrowItem.forEach(type => {
  event.shapeless(
    Item.of(`archeryexp:netherite_${type}`, 1),
    [
      `archeryexp:diamond_${type}`,
      'kubejs:netherite_upgrade_tablet',
    ]
  )
})

});