Skip to content

Commit

Permalink
Better Recipe Recycling Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Feb 20, 2024
1 parent 3069fe0 commit 90d20df
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/nomiceu/nomilabs/groovy/ReplaceRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void removeRecyclingRecipe(RecipeMap<?> map, GTRecipeCategory cat
}

public static void replaceRecipeShaped(ResourceLocation name, ItemStack output, List<List<IIngredient>> inputs) {
validate(name, output, true);
validate(name, output, true, false);
crafting.remove(name);
crafting.addShaped(LabsNames.makeGroovyName(name.getPath()), output, inputs);
registerRecycling(output, inputs);
Expand All @@ -89,7 +89,7 @@ public static void replaceRecipeShaped(ItemStack oldOutput, ItemStack newOutput,
}

public static void replaceRecipeOutput(ResourceLocation name, ItemStack newOutput) {
IShapedRecipe originalRecipe = validate(name, newOutput, true);
IShapedRecipe originalRecipe = validate(name, newOutput, true, true);
var originalCount = originalRecipe.getRecipeOutput().getCount();
var newCount = newOutput.getCount();

Expand All @@ -110,7 +110,7 @@ public static void replaceRecipeOutput(ItemStack oldOutput, ItemStack newOutput)
}

public static void replaceRecipeInput(ResourceLocation name, List<List<IIngredient>> newInputs) {
IRecipe originalRecipe = validate(name, ItemStack.EMPTY, false);
IRecipe originalRecipe = validate(name, ItemStack.EMPTY, false, false);
var originalOutput = originalRecipe.getRecipeOutput();
crafting.remove(name);
crafting.addShaped(LabsNames.makeGroovyName(name.getPath()), originalOutput, newInputs);
Expand All @@ -135,7 +135,7 @@ public static void changeStackRecycling(ItemStack output, List<IIngredient> ingr
registerRecycling(output, Collections.singletonList(ingredients));
}

private static IShapedRecipe validate(ResourceLocation name, ItemStack output, boolean validateOutput) {
private static IShapedRecipe validate(ResourceLocation name, ItemStack output, boolean validateOutput, boolean requireOutputOriginalInfo) {
IRecipe originalRecipe = ForgeRegistries.RECIPES.getValue(name);
if (originalRecipe == null)
throw new IllegalArgumentException("Could not find recipe with name " + name + "!");
Expand All @@ -148,7 +148,7 @@ private static IShapedRecipe validate(ResourceLocation name, ItemStack output, b

ItemStack originalOutput = checkAndGetOutput(output, validateOutput, originalRecipe);

if (OreDictUnifier.getMaterialInfo(originalOutput) == null)
if (requireOutputOriginalInfo && OreDictUnifier.getMaterialInfo(originalOutput) == null)
throw new IllegalArgumentException("Could not find existing Material Info for item " + originalOutput);

ReloadableRegistryManager.removeRegistryEntry(ForgeRegistries.RECIPES, name);
Expand Down

0 comments on commit 90d20df

Please sign in to comment.