diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java b/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java index 5ed3221..8908c76 100644 --- a/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java +++ b/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java @@ -1,8 +1,15 @@ package net.silentclient.client.gui; +import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; -import net.silentclient.client.gui.minecraft.GuiMainMenu; +import net.minecraft.client.gui.GuiScreenServerList; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.resources.I18n; +import net.silentclient.client.mixin.accessors.GuiMultiplayerAccessor; +import net.silentclient.client.mixin.wrappers.ServerDataWrapper; + +import java.io.IOException; public class GuiMultiplayerInGame extends GuiMultiplayer { @@ -10,18 +17,33 @@ public class GuiMultiplayerInGame extends GuiMultiplayer { super(parentScreen); } + @Override + protected void actionPerformed(GuiButton button) throws IOException { + if(button.id == 1) { + disconnect(); + } + + if(button.id == 4) { + ((GuiMultiplayerAccessor) this).silent$setDirectConnect(true); + ((GuiMultiplayerAccessor) this).silent$setSelectedServer(new ServerDataWrapper(new ServerData(I18n.format("selectServer.defaultName"), "", false))); + this.mc.displayGuiScreen(new GuiScreenServerList(this, ((GuiMultiplayerAccessor) this).silent$getSelectedServer().getServerData())); + } + + super.actionPerformed(button); + } + @Override public void connectToSelected() { - this.performDisconnection(); + disconnect(); super.connectToSelected(); } - public void performDisconnection() { - if (this.mc.theWorld != null) { + private void disconnect() { + if(this.mc.theWorld != null) { this.mc.theWorld.sendQuittingDisconnectingPacket(); this.mc.loadWorld(null); this.mc.displayGuiScreen(null); -// ((GuiMultiplayerAccessor) this).setParentScreen(new GuiMultiplayer(new GuiMainMenu())); + ((GuiMultiplayerAccessor) this).silent$setParentScreen(null); } } diff --git a/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java b/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java index f7534ad..5d1577c 100644 --- a/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java +++ b/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java @@ -1,11 +1,12 @@ package net.silentclient.client.mixin.accessors; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; +import net.minecraft.client.multiplayer.ServerData; +import net.silentclient.client.mixin.wrappers.GuiScreenWrapper; +import net.silentclient.client.mixin.wrappers.ServerDataWrapper; -@Mixin(GuiMultiplayer.class) public interface GuiMultiplayerAccessor { - @Accessor void setParentScreen(GuiScreen a); + void silent$setParentScreen(GuiScreenWrapper a); + void silent$setDirectConnect(boolean a); + void silent$setSelectedServer(ServerDataWrapper a); + ServerDataWrapper silent$getSelectedServer(); } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java new file mode 100644 index 0000000..dec501a --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java @@ -0,0 +1,47 @@ +package net.silentclient.client.mixin.mixins; + +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.ServerData; +import net.silentclient.client.mixin.accessors.GuiMultiplayerAccessor; +import net.silentclient.client.mixin.wrappers.GuiScreenWrapper; +import net.silentclient.client.mixin.wrappers.ServerDataWrapper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(GuiMultiplayer.class) +public abstract class GuiMultiplayerMixin implements GuiMultiplayerAccessor { + @Shadow private GuiScreen parentScreen; + + @Shadow private boolean directConnect; + + @Shadow private ServerData selectedServer; + + @Override + public void silent$setParentScreen(GuiScreenWrapper a) { + if(a == null) { + this.parentScreen = null; + return; + } + this.parentScreen = a.getScreen(); + } + + @Override + public void silent$setDirectConnect(boolean a) { + this.directConnect = a; + } + + @Override + public ServerDataWrapper silent$getSelectedServer() { + return new ServerDataWrapper(selectedServer); + } + + @Override + public void silent$setSelectedServer(ServerDataWrapper a) { + if(a == null) { + this.selectedServer = null; + return; + } + this.selectedServer = a.getServerData(); + } +} diff --git a/src/main/java/net/silentclient/client/mixin/wrappers/GuiScreenWrapper.java b/src/main/java/net/silentclient/client/mixin/wrappers/GuiScreenWrapper.java new file mode 100644 index 0000000..c84f07b --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/wrappers/GuiScreenWrapper.java @@ -0,0 +1,16 @@ +package net.silentclient.client.mixin.wrappers; + +import net.minecraft.client.gui.GuiScreen; + +public class GuiScreenWrapper { + private final GuiScreen screen; + + + public GuiScreenWrapper(GuiScreen screen) { + this.screen = screen; + } + + public GuiScreen getScreen() { + return screen; + } +} diff --git a/src/main/java/net/silentclient/client/mixin/wrappers/ServerDataWrapper.java b/src/main/java/net/silentclient/client/mixin/wrappers/ServerDataWrapper.java new file mode 100644 index 0000000..465940b --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/wrappers/ServerDataWrapper.java @@ -0,0 +1,16 @@ +package net.silentclient.client.mixin.wrappers; + +import net.minecraft.client.multiplayer.ServerData; + +public class ServerDataWrapper { + private final ServerData serverData; + + + public ServerDataWrapper(ServerData serverData) { + this.serverData = serverData; + } + + public ServerData getServerData() { + return serverData; + } +} diff --git a/src/main/resources/mixins.SilentClient.json b/src/main/resources/mixins.SilentClient.json index 60bb000..b644648 100644 --- a/src/main/resources/mixins.SilentClient.json +++ b/src/main/resources/mixins.SilentClient.json @@ -23,6 +23,7 @@ "mixins.RenderPlayerMixin", "mixins.GuiInGameMixin", "mixins.LayerCapeMixin", - "mixins.GuiAchievementMixin" + "mixins.GuiAchievementMixin", + "mixins.GuiMultiplayerMixin" ] } \ No newline at end of file