Fix crash with TC NEI & other handlers with null or short/empty getRecipeName()

This commit is contained in:
Jason Mitchell committed 2021-05-16 10:27:37 -07:00
1 parent 344b22a322
commit 5fdb5824df
2 files changed
+10 -2

No files matched your search

+1 -1
View File
@@ -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
+9 -1
View File
@@ -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;