[Fix] Prevent alt list index out-of-bounds in GUI

This commit is contained in:
xiaozhou233 committed 2026-01-25 13:58:10 +08:00
1 parent b72c1bc13c
commit c9c2c92698
1 file changed
+7 -4
@@ -50,6 +50,8 @@ public class GUIAltManager extends GuiScreen {
@Override
protected void actionPerformed(GuiButton button) throws IOException {
List<Alt> alts = OrangeX.getInstance().getAltManager().getAlts();
switch (button.id) {
case 1:
mc.displayGuiScreen(new GUIAddCracked());
@@ -64,15 +66,15 @@ public class GUIAltManager extends GuiScreen {
break;
case 4:
if (selectedIndex >= 0) {
Alt alt = OrangeX.getInstance().getAltManager().getAlts().get(selectedIndex);
if (selectedIndex >= 0 && selectedIndex < alts.size()) {
Alt alt = alts.get(selectedIndex);
OrangeX.getInstance().getAltManager().login(alt);
}
break;
case 5:
if (selectedIndex >= 0) {
Alt alt = OrangeX.getInstance().getAltManager().getAlts().get(selectedIndex);
if (selectedIndex >= 0 && selectedIndex < alts.size()) {
Alt alt = alts.get(selectedIndex);
OrangeX.getInstance().getAltManager().removeAlt(alt);
selectedIndex = -1;
lastClickIndex = -1;
@@ -81,6 +83,7 @@ public class GUIAltManager extends GuiScreen {
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();