Skip to content

Commit 530d0ba

Browse files
committed
Add "Server List" button in the Minecraft ESC GUI
This patch adds a new "Server List" button replacing the disabled "Open To Lan" button in the multiplayer pause menu :)
1 parent 414581b commit 530d0ba

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java

+21-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import com.lambda.client.gui.mc.LambdaGuiAntiDisconnect;
44
import com.lambda.client.module.modules.misc.AntiDisconnect;
55
import com.lambda.client.util.Wrapper;
6-
import net.minecraft.client.gui.GuiButton;
7-
import net.minecraft.client.gui.GuiIngameMenu;
8-
import net.minecraft.client.gui.GuiScreen;
6+
import net.minecraft.client.gui.*;
97
import org.spongepowered.asm.mixin.Mixin;
108
import org.spongepowered.asm.mixin.injection.At;
119
import org.spongepowered.asm.mixin.injection.Inject;
@@ -15,11 +13,26 @@
1513
public class MixinGuiIngameMenu extends GuiScreen {
1614
@Inject(method = "actionPerformed", at = @At("HEAD"), cancellable = true)
1715
public void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
18-
if (button.id == 1) {
19-
if (AntiDisconnect.INSTANCE.isEnabled()) {
20-
Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiAntiDisconnect());
21-
callbackInfo.cancel();
22-
}
16+
switch (button.id) {
17+
case 1:
18+
if (AntiDisconnect.INSTANCE.isEnabled()) {
19+
Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiAntiDisconnect());
20+
callbackInfo.cancel();
21+
}
22+
break;
23+
case Integer.MIN_VALUE:
24+
Wrapper.getMinecraft().displayGuiScreen(new GuiMultiplayer(this));
25+
break;
26+
default:
27+
break;
28+
}
29+
}
30+
31+
@Inject(method = "initGui", at = @At("RETURN"))
32+
public void initGui(CallbackInfo ci) {
33+
if (!mc.isSingleplayer()) {
34+
GuiButton openToLanButton = buttonList.remove(4);
35+
buttonList.add(new GuiButton(Integer.MIN_VALUE, openToLanButton.x, openToLanButton.y, openToLanButton.width, openToLanButton.height, "Server List"));
2336
}
2437
}
2538
}

0 commit comments

Comments
 (0)