diff --git a/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java b/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java index 5eebdcffe..9f05b7ca7 100644 --- a/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java +++ b/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java @@ -5,6 +5,7 @@ import com.lambda.client.util.Wrapper; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiIngameMenu; +import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -15,11 +16,26 @@ public class MixinGuiIngameMenu extends GuiScreen { @Inject(method = "actionPerformed", at = @At("HEAD"), cancellable = true) public void actionPerformed(GuiButton button, CallbackInfo callbackInfo) { - if (button.id == 1) { - if (AntiDisconnect.INSTANCE.isEnabled()) { - Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiAntiDisconnect()); - callbackInfo.cancel(); - } + switch (button.id) { + case 1: + if (AntiDisconnect.INSTANCE.isEnabled()) { + Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiAntiDisconnect()); + callbackInfo.cancel(); + } + break; + case Integer.MIN_VALUE: + Wrapper.getMinecraft().displayGuiScreen(new GuiMultiplayer(this)); + break; + default: + break; + } + } + + @Inject(method = "initGui", at = @At("RETURN")) + public void initGui(CallbackInfo ci) { + if (!mc.isSingleplayer()) { + GuiButton openToLanButton = buttonList.remove(4); + buttonList.add(new GuiButton(Integer.MIN_VALUE, openToLanButton.x, openToLanButton.y, openToLanButton.width, openToLanButton.height, "Server List")); } } } diff --git a/src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java b/src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java new file mode 100644 index 000000000..6c259edbf --- /dev/null +++ b/src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java @@ -0,0 +1,22 @@ +package com.lambda.mixin.gui; + +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.ServerData; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiMultiplayer.class) +public class MixinGuiMultiplayer extends GuiScreen { + + @Inject(method = "connectToServer", at = @At("HEAD")) + public void connectToServer(ServerData serverData, CallbackInfo ci) { + if (mc.getCurrentServerData() != null && mc.world != null) { + mc.world.sendQuittingDisconnectingPacket(); + mc.loadWorld(null); + } + } + +} diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index 2ea5d021b..a67d4dceb 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -47,6 +47,7 @@ "gui.MixinGuiIngameMenu", "gui.MixinGuiInventory", "gui.MixinGuiMainMenu", + "gui.MixinGuiMultiplayer", "gui.MixinGuiNewChat", "gui.MixinGuiPlayerTabOverlay", "gui.MixinGuiScreen",