Almost fixed GuiMultiplayerInGame

This commit is contained in:
kirillsaint 2023-06-29 16:05:39 +06:00
parent 0b95f422f8
commit 23966b5ba7
7 changed files with 239 additions and 12 deletions

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -1,8 +1,15 @@
package net.silentclient.client.gui; package net.silentclient.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen; 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 { public class GuiMultiplayerInGame extends GuiMultiplayer {
@ -10,18 +17,33 @@ public class GuiMultiplayerInGame extends GuiMultiplayer {
super(parentScreen); 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 @Override
public void connectToSelected() { public void connectToSelected() {
this.performDisconnection(); disconnect();
super.connectToSelected(); super.connectToSelected();
} }
public void performDisconnection() { private void disconnect() {
if (this.mc.theWorld != null) { if(this.mc.theWorld != null) {
this.mc.theWorld.sendQuittingDisconnectingPacket(); this.mc.theWorld.sendQuittingDisconnectingPacket();
this.mc.loadWorld(null); this.mc.loadWorld(null);
this.mc.displayGuiScreen(null); this.mc.displayGuiScreen(null);
// ((GuiMultiplayerAccessor) this).setParentScreen(new GuiMultiplayer(new GuiMainMenu())); ((GuiMultiplayerAccessor) this).silent$setParentScreen(null);
} }
} }

View File

@ -1,11 +1,12 @@
package net.silentclient.client.mixin.accessors; package net.silentclient.client.mixin.accessors;
import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.gui.GuiScreen; import net.silentclient.client.mixin.wrappers.GuiScreenWrapper;
import org.spongepowered.asm.mixin.Mixin; import net.silentclient.client.mixin.wrappers.ServerDataWrapper;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(GuiMultiplayer.class)
public interface GuiMultiplayerAccessor { 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();
} }

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -23,6 +23,7 @@
"mixins.RenderPlayerMixin", "mixins.RenderPlayerMixin",
"mixins.GuiInGameMixin", "mixins.GuiInGameMixin",
"mixins.LayerCapeMixin", "mixins.LayerCapeMixin",
"mixins.GuiAchievementMixin" "mixins.GuiAchievementMixin",
"mixins.GuiMultiplayerMixin"
] ]
} }