diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiIngredientFast.java b/src/main/java/mezz/jei/gui/ingredients/GuiIngredientFast.java index 95430e7e4..8262b2a60 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiIngredientFast.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiIngredientFast.java @@ -30,8 +30,12 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.crash.ICrashReportDetail; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.ReportedException; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.ForgeHooksClient; @@ -87,13 +91,12 @@ public void renderItemAndEffectIntoGUI() { return; } - ItemStack itemStack = (ItemStack) ingredient; + final ItemStack itemStack = (ItemStack) ingredient; try { renderItemAndEffectIntoGUI(itemStack); } catch (RuntimeException e) { - logRenderError(this, e); - clear(); + throw createRenderIngredientException(e, itemStack); } } @@ -169,8 +172,7 @@ public void renderSlow() { try { renderSlow(ingredient, area, padding); } catch (RuntimeException e) { - logRenderError(this, e); - clear(); + throw createRenderIngredientException(e, ingredient); } } } @@ -194,8 +196,7 @@ public void renderOverlay(Minecraft minecraft) { try { renderOverlay(minecraft, itemStack); } catch (RuntimeException e) { - logRenderError(this, e); - clear(); + throw createRenderIngredientException(e, itemStack); } } @@ -357,19 +358,22 @@ private static List getTooltip(Minecraft minecraft, V ingredient, II return list; } - private static void logRenderError(GuiIngredientFast guiItemStack, Exception e) { - Object ingredient = guiItemStack.getIngredient(); - logRenderError(ingredient, e); - } - - private static void logRenderError(@Nullable V ingredient, Exception e) { - if (ingredient == null) { - Log.error("Rendering ingredient crashed.", e); - } else { - IIngredientRegistry ingredientRegistry = Internal.getIngredientRegistry(); - IIngredientHelper ingredientHelper = ingredientRegistry.getIngredientHelper(ingredient); - String info = ingredientHelper.getErrorInfo(ingredient); - Log.error("Rendering ingredient crashed: {}", info, e); - } + private static ReportedException createRenderIngredientException(Throwable throwable, final T ingredient) { + final IIngredientHelper ingredientHelper = Internal.getIngredientRegistry().getIngredientHelper(ingredient); + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering ingredient"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Ingredient being rendered"); + crashreportcategory.setDetail("Ingredient Mod", new ICrashReportDetail() { + @Override + public String call() throws Exception { + return Internal.getModIdUtil().getModNameForIngredient(ingredient, ingredientHelper); + } + }); + crashreportcategory.setDetail("Ingredient Info", new ICrashReportDetail() { + @Override + public String call() throws Exception { + return ingredientHelper.getErrorInfo(ingredient); + } + }); + throw new ReportedException(crashreport); } }