From 5fdb5824df8632a41a3ccc126662cc769bb7339f Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sun, 16 May 2021 10:27:37 -0700 Subject: [PATCH] Fix crash with TC NEI & other handlers with null or short/empty `getRecipeName()` --- build.properties | 2 +- src/codechicken/nei/recipe/GuiRecipeTab.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index 2f134c94..d2412b4b 100644 --- a/build.properties +++ b/build.properties @@ -2,4 +2,4 @@ mc_version=1.7.10 forge_version=10.13.4.1614-1.7.10 ccl_version=1.1.3.138 ccc_version=1.0.7.+ -mod_version=2.1.2-GTNH +mod_version=2.1.3-GTNH diff --git a/src/codechicken/nei/recipe/GuiRecipeTab.java b/src/codechicken/nei/recipe/GuiRecipeTab.java index e1fe4861..e548b3af 100644 --- a/src/codechicken/nei/recipe/GuiRecipeTab.java +++ b/src/codechicken/nei/recipe/GuiRecipeTab.java @@ -105,7 +105,15 @@ public abstract class GuiRecipeTab extends Widget { GuiContainerManager.drawItems.zLevel -= 100; } else { // Text fallback - String text = handler.getRecipeName().substring(0, 2); + String text = handler.getRecipeName(); + if (text != null && text.length() > 0) { + if (text.length() > 2) { + text = text.substring(0, 2); + } + } else { + text = "??"; + } + int textCenterX = x + (int) (getWidth() / 2f); int textCenterY = y + (int) (getHeight() / 2f) - 3; int color = selected ? 0xffffa0 : 0xe0e0e0;