function replaceItemInAllRecipes(event, oldItem, newItem) {
  Platform.getMods().forEach((modId, modInfo) => {
    event.forEachRecipe({ mod: modId }, (recipe) => {
      const recipeJsonString = recipe.json.toString();
      if (!recipeJsonString.includes(`"${oldItem}"`)) return;

      const newRecipeJson = JSON.parse(recipeJsonString.replace(`"${oldItem}"`, `"${newItem}"`));

      event.remove({ id: `${recipe.id}` });
      event.custom(newRecipeJson).id(`${recipe.id}`);
      console.log(`${recipe.id} from ${modInfo.name} has been edited.`);
    });
  });
}

ServerEvents.recipes((event) => {
  event.replaceInput({ input: 'farmersdelight:wheat_dough' }, 'farmersdelight:wheat_dough', 'create:dough');
  event.replaceOutput({ output: 'farmersdelight:wheat_dough' }, 'farmersdelight:wheat_dough', 'create:dough');
  replaceItemInAllRecipes(event, 'irons_spellbooks:hogskin', 'mynethersdelight:hoglin_hide');
  replaceItemInAllRecipes(event, 'irons_spellbooks:blood_vial', 'hexerei:blood_bottle');
});
