Skip to content

Commit

Permalink
Avoid spamming logs if a recipe is throwing exceptions during aspect …
Browse files Browse the repository at this point in the history
…discovery (#38)
  • Loading branch information
TheCodex6824 committed Aug 19, 2024
1 parent ab099b9 commit 370735d
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package thecodex6824.thaumcraftfix.core.transformer;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;

import javax.annotation.Nullable;
Expand All @@ -37,6 +39,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.IShapedRecipe;
import net.minecraftforge.oredict.OreDictionary;
import thaumcraft.api.ThaumcraftApiHelper;
Expand Down Expand Up @@ -78,6 +81,8 @@ public static InventoryCrafting makeVanillaRecipeWrapper(InventoryCrafting input
return new InventoryCraftingWrapper(input);
}

private static final Set<ResourceLocation> BROKEN_RECIPES = new HashSet<ResourceLocation>();

@Nullable
public static InventoryCrafting createFilledInventoryForRecipe(IRecipe recipe) {
if (recipe.isDynamic() || !recipe.canFit(3, 3)) {
Expand Down Expand Up @@ -131,7 +136,10 @@ public static InventoryCrafting createFilledInventoryForRecipe(IRecipe recipe) {
matches = recipe.matches(ret, null);
}
catch (Exception ex) {
ThaumcraftFix.instance.getLogger().error("Failed calling IRecipe#matches", ex);
if (BROKEN_RECIPES.add(recipe.getRegistryName())) {
ThaumcraftFix.instance.getLogger().error("Failed calling IRecipe#matches", ex);
ThaumcraftFix.instance.getLogger().error("Note: future errors with this recipe will not be logged");
}
}

return matches ? ret : null;
Expand Down

0 comments on commit 370735d

Please sign in to comment.