From b60199e1877a5fe85ccb25618a9d39d61b2389cb Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 6 Jan 2025 01:34:25 +0100 Subject: [PATCH] Fix keyboard navigation crash (#814) - Fix crash when using keyboard navigation at the end of the list --- .../terraformersmc/modmenu/gui/widget/ModListWidget.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/terraformersmc/modmenu/gui/widget/ModListWidget.java b/src/main/java/com/terraformersmc/modmenu/gui/widget/ModListWidget.java index 2464f87e..f5e43133 100644 --- a/src/main/java/com/terraformersmc/modmenu/gui/widget/ModListWidget.java +++ b/src/main/java/com/terraformersmc/modmenu/gui/widget/ModListWidget.java @@ -18,6 +18,7 @@ import net.minecraft.client.render.*; import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; +import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.lwjgl.glfw.GLFW; @@ -78,9 +79,13 @@ public void select(ModListEntry entry) { } @Override - public void setSelected(ModListEntry entry) { + public void setSelected(@Nullable ModListEntry entry) { super.setSelected(entry); - selectedModId = entry.getMod().getId(); + if (entry == null) { + selectedModId = null; + } else { + selectedModId = entry.getMod().getId(); + } parent.updateSelectedEntry(getSelectedOrNull()); }