// CUNICULUM <-> Apotheosis bridge.
// Keeps mob-dropped CUNICULUM gear salvageable without making normal vanilla gear exploitable.

var CUNIMOB_APOTH_SALVAGE_RARITIES = [
  { key: 'common', apoth: 'apotheosis:common', material: 'apotheosis:common_material' },
  { key: 'uncommon', apoth: 'apotheosis:uncommon', material: 'apotheosis:uncommon_material' },
  { key: 'rare', apoth: 'apotheosis:rare', material: 'apotheosis:rare_material' },
  { key: 'epic', apoth: 'apotheosis:epic', material: 'apotheosis:epic_material' },
  { key: 'mythic', apoth: 'apotheosis:mythic', material: 'apotheosis:mythic_material' }
];

ServerEvents.recipes(event => {
  for (var i = 0; i < CUNIMOB_APOTH_SALVAGE_RARITIES.length; i++) {
    var rarity = CUNIMOB_APOTH_SALVAGE_RARITIES[i];
    event.custom({
      type: 'apotheosis:salvaging',
      input: {
        type: 'neoforge:components',
        items: '#cuniculum:apotheosis_salvageable',
        components: {
          'apotheosis:rarity': rarity.apoth
        },
        strict: false
      },
      outputs: [
        {
          min_count: 1,
          max_count: 4,
          stack: {
            id: rarity.material,
            count: 1
          }
        }
      ]
    }).id('cuniculum:apotheosis_salvage/' + rarity.key);
  }
});
