From c14a1cc216730037319f2a18370fd29b1993fe71 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 30 May 2023 12:37:39 +0800 Subject: Fix #1318 --- .../gui/widget/favorites/history/DisplayEntry.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'runtime/src/main/java') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java index 72fd04e6f..03db37b7e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java @@ -44,10 +44,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; @@ -99,7 +96,7 @@ public class DisplayEntry extends WidgetWithBounds { CategoryRegistry.CategoryConfiguration configuration = CategoryRegistry.getInstance().get((CategoryIdentifier) display.getCategoryIdentifier()); DisplayCategory category = configuration.getCategory(); Rectangle displayBounds = new Rectangle(0, 0, category.getDisplayWidth(display), category.getDisplayHeight()); - List widgets = configuration.getView(display).setupDisplay(display, displayBounds); + List widgets = setupDisplay(configuration, displayBounds); float scale = 1.0F; if (parentBounds.width * scale < displayBounds.width) { scale = Math.min(scale, parentBounds.width * scale / (float) displayBounds.width); @@ -124,6 +121,19 @@ public class DisplayEntry extends WidgetWithBounds { return widgets; } + private List setupDisplay(CategoryRegistry.CategoryConfiguration configuration, Rectangle displayBounds) { + try { + return configuration.getView(display).setupDisplay(display, displayBounds); + } catch (Throwable throwable) { + throwable.printStackTrace(); + List w = new ArrayList<>(); + w.add(Widgets.createRecipeBase(displayBounds).color(0xFFBB0000)); + w.add(Widgets.createLabel(new Point(displayBounds.getCenterX(), displayBounds.getCenterY() - 8), new TextComponent("Failed to initiate setupDisplay"))); + w.add(Widgets.createLabel(new Point(displayBounds.getCenterX(), displayBounds.getCenterY() + 1), new TextComponent("Check console for error"))); + return w; + } + } + @Override public Rectangle getBounds() { return bounds.value().getBounds(); -- cgit