From dac379a8aa98d645d8a3eaadfb67b8cdaae86f4f Mon Sep 17 00:00:00 2001 From: McHorse Date: Fri, 30 Jul 2021 14:36:58 +0100 Subject: [PATCH] Fix this Metamorph crash when navigating with arrow keys into empty Chameleon section --- gradle.properties | 2 +- src/main/java/mchorse/metamorph/client/gui/GuiMorphs.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index ec543b67..0b06a536 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,5 @@ version=1.2.9 mclib=2.3.1 mc_version=1.12.2 -forge_version=14.23.2.2611 +forge_version=14.23.5.2799 snapshot=snapshot_20171003 \ No newline at end of file diff --git a/src/main/java/mchorse/metamorph/client/gui/GuiMorphs.java b/src/main/java/mchorse/metamorph/client/gui/GuiMorphs.java index 51aab4e1..9a78f07e 100644 --- a/src/main/java/mchorse/metamorph/client/gui/GuiMorphs.java +++ b/src/main/java/mchorse/metamorph/client/gui/GuiMorphs.java @@ -14,6 +14,8 @@ public class GuiMorphs extends GuiScrollElement { + private static final MorphCategory EMPTY_CATEGORY = new MorphCategory(null, null); + /** * Cached previous filter. Used for avoiding double recalculations */ @@ -105,7 +107,7 @@ else if (y > 0 && this.isLastCategory(this.selected)) } section = this.sections.get(sectionIndex); - category = section.section.categories.get(section.section.categories.size() - 1); + category = section.section.categories.isEmpty() ? EMPTY_CATEGORY : section.section.categories.get(section.section.categories.size() - 1); } else if (index >= section.section.categories.size()) { @@ -117,7 +119,7 @@ else if (index >= section.section.categories.size()) } section = this.sections.get(sectionIndex); - category = section.section.categories.get(0); + category = section.section.categories.isEmpty() ? EMPTY_CATEGORY : section.section.categories.get(0); } else {