From 70583743ce67d6e591d122773dfdc019eb950a7a Mon Sep 17 00:00:00 2001 From: Kam Date: Fri, 6 Feb 2026 03:36:32 -0500 Subject: [PATCH] Fix Ability and Custom Button --- .../client/gui/global/GuiNPCManageAnimations.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java index ac4675243..3ac3923b4 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -65,16 +65,17 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol public void initGui() { super.initGui(); + // Toggle button - added FIRST to maintain stable buttonList index + // (prevents double-toggle when initGui() is called from actionPerformed) + String toggleLabel = showingBuiltIn ? "gui.builtin" : "gui.custom"; + this.addButton(new GuiNpcButton(10, guiLeft + 368, guiTop + 56, 45, 20, toggleLabel)); + // Add/Remove buttons - only show for custom animations if (!showingBuiltIn) { this.addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); this.addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); } - // Toggle button for Custom/Built-in - under Remove button - String toggleLabel = showingBuiltIn ? "gui.builtin" : "gui.custom"; - this.addButton(new GuiNpcButton(10, guiLeft + 368, guiTop + 56, 45, 20, toggleLabel)); - if (scrollAnimations == null) { scrollAnimations = new GuiCustomScroll(this, 0, 0); scrollAnimations.setSize(143, 185); @@ -200,11 +201,15 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol // Toggle button if (button.id == 10) { showingBuiltIn = !showingBuiltIn; - // Clear selection when switching views + // Clear selection and search when switching views selected = null; + search = ""; animation = new Animation(); currentIsBuiltIn = false; + playingAnimation = false; scrollAnimations.clear(); + // Re-request data to ensure both lists are populated + PacketClient.sendClient(new AnimationsGetPacket()); initGui(); return; }