diff --git a/modules/utils/api/utils.api b/modules/utils/api/utils.api index cfa6a8ba6..da3d14c74 100644 --- a/modules/utils/api/utils.api +++ b/modules/utils/api/utils.api @@ -99,6 +99,7 @@ public abstract interface class org/polyfrost/oneconfig/api/platform/v1/PlayerPl public abstract fun getPlayerName ()Ljava/lang/String; public abstract fun getServerBrand ()Ljava/lang/String; public abstract fun inMultiplayer ()Z + public abstract fun joinServer (Lorg/polyfrost/oneconfig/api/platform/v1/PlayerPlatform$Server;)V } public class org/polyfrost/oneconfig/api/platform/v1/PlayerPlatform$Server { diff --git a/modules/utils/src/main/java/org/polyfrost/oneconfig/api/platform/v1/PlayerPlatform.java b/modules/utils/src/main/java/org/polyfrost/oneconfig/api/platform/v1/PlayerPlatform.java index 183a37460..a9cf48ca1 100644 --- a/modules/utils/src/main/java/org/polyfrost/oneconfig/api/platform/v1/PlayerPlatform.java +++ b/modules/utils/src/main/java/org/polyfrost/oneconfig/api/platform/v1/PlayerPlatform.java @@ -26,6 +26,7 @@ package org.polyfrost.oneconfig.api.platform.v1; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface PlayerPlatform { @@ -45,6 +46,8 @@ public interface PlayerPlatform { @Nullable Server getCurrentServer(); + void joinServer(@NotNull Server server); + class Server { public final String ip, name; diff --git a/versions/mappings/fabric-1.17.1-1.16.5.txt b/versions/mappings/fabric-1.17.1-1.16.5.txt index 7a2d77f5a..cd3237c95 100644 --- a/versions/mappings/fabric-1.17.1-1.16.5.txt +++ b/versions/mappings/fabric-1.17.1-1.16.5.txt @@ -1,2 +1,2 @@ com.mojang.blaze3d.platform.GlStateManager _glFramebufferTexture2D() framebufferTexture2D() -com.mojang.blaze3d.platform.GlStateManager _texImage2D() texImage2D() +com.mojang.blaze3d.platform.GlStateManager _texImage2D() texImage2D() \ No newline at end of file diff --git a/versions/mappings/forge-1.16.5-1.12.2.txt b/versions/mappings/forge-1.16.5-1.12.2.txt index 39e18b3f8..471096b32 100644 --- a/versions/mappings/forge-1.16.5-1.12.2.txt +++ b/versions/mappings/forge-1.16.5-1.12.2.txt @@ -39,6 +39,9 @@ net.minecraft.profiler.IProfiler net.minecraft.profiler.Profiler net.minecraft.util.text.ITextComponent getUnformattedComponentText() getUnformattedText() +net.minecraft.client.gui.screen.MultiplayerScreen net.minecraft.client.gui.GuiMultiplayer +net.minecraft.client.gui.screen.ConnectingScreen net.minecraft.client.multiplayer.GuiConnecting + net.minecraftforge.client.event.ClientPlayerNetworkEvent getNetworkManager() getManager() net.minecraftforge.client.event.ClientPlayerNetworkEvent net.minecraftforge.fml.common.network.FMLNetworkEvent net.minecraftforge.client.event.ClientPlayerNetworkEvent$LoggedInEvent net.minecraftforge.fml.common.network.FMLNetworkEvent$ClientConnectedToServerEvent diff --git a/versions/mappings/forge-1.17.1-1.16.5.txt b/versions/mappings/forge-1.17.1-1.16.5.txt index b5d3e9793..cf99e5a4b 100644 --- a/versions/mappings/forge-1.17.1-1.16.5.txt +++ b/versions/mappings/forge-1.17.1-1.16.5.txt @@ -38,6 +38,9 @@ net.minecraft.client.Minecraft missTime leftClickCounter net.minecraft.client.sounds.SoundEngine net.minecraft.client.audio.SoundEngine +net.minecraft.client.gui.screens.ConnectScreen net.minecraft.client.gui.screen.ConnectingScreen +net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen net.minecraft.client.gui.screen.MultiplayerScreen + net.minecraft.ChatFormatting net.minecraft.util.text.TextFormatting net.minecraft.ChatFormatting stripFormatting() getTextWithoutFormattingCodes() diff --git a/versions/src/main/java/org/polyfrost/oneconfig/api/platform/v1/internal/PlayerPlatformImpl.java b/versions/src/main/java/org/polyfrost/oneconfig/api/platform/v1/internal/PlayerPlatformImpl.java index d3dbe1f20..20adedb63 100644 --- a/versions/src/main/java/org/polyfrost/oneconfig/api/platform/v1/internal/PlayerPlatformImpl.java +++ b/versions/src/main/java/org/polyfrost/oneconfig/api/platform/v1/internal/PlayerPlatformImpl.java @@ -26,9 +26,21 @@ package org.polyfrost.oneconfig.api.platform.v1.internal; +//#if MC >= 1.17.1 +//#if FORGE +//$$ import net.minecraft.client.multiplayer.resolver.ServerAddress; +//#else +//$$ import net.minecraft.client.network.ServerAddress; +//#endif +//#endif + import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.multiplayer.GuiConnecting; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.util.Session; +import org.jetbrains.annotations.NotNull; +import org.polyfrost.oneconfig.api.platform.v1.Platform; import org.polyfrost.oneconfig.api.platform.v1.PlayerPlatform; public class PlayerPlatformImpl implements PlayerPlatform { @@ -72,4 +84,46 @@ public Server getCurrentServer() { old = d; return cache = new Server(d.serverIP, d.serverName); } + + public void joinServer(@NotNull Server server) { + ServerData data = new ServerData( + server.name, + server.ip, + //#if MC >= 1.20.4 + //#if FORGE + //$$ ServerData.Type.OTHER + //#else + //$$ ServerInfo.ServerType.OTHER + //#endif + //#else + false + //#endif + ); + + //#if MC >= 1.17.1 + //$$ ServerAddress address = ServerAddress + //#if FORGE + //$$ .parseString(server.ip); + //#else + //$$ .parse(server.ip); + //#endif + //#if FORGE + //$$ ConnectScreen.startConnecting( + //$$ new JoinMultiplayerScreen(Platform.screen().current()), + //$$ Minecraft.getInstance(), + //#else + //$$ ConnectScreen.connect( + //$$ new MultiplayerScreen(Platform.screen().current()), + //$$ MinecraftClient.getInstance(), + //#endif + //$$ address, + //$$ data + //#if MC >= 1.20.4 + //$$ , false + //#endif + //$$ ); + //#else + Platform.screen().display(new GuiConnecting(new GuiMultiplayer(Platform.screen().current()), Minecraft.getMinecraft(), data)); + //#endif + } }