Posted January 18, 20223 yr Hello! I am trying to give my mod the ability to join Minecraft Servers. I have the IP of the server I would like to join stored in a variable. It appears I can get the Minecraft Session Service by using the command 'Minecraft.getInstance().getMinecraftSessionService()' Using that, I can do session.joinServer(). It takes 3 Arguments, profile, authentication token, serverId. I believe I can get the profile using " Minecraft.getInstance().player ", auth token from " Minecraft.getInstance().getUser().getAccessToken() ", but I have no clue what a serverID is, I tried the server ip, but it doesn't seem to work. Resources I have tried using: OAuth mod Login Anyone have any clue how the MinecraftSessionService works? How do you actually join a server from code?
January 18, 20223 yr Author 2 hours ago, diesieben07 said: ConnectScreen.startConnecting isd what you need. Thanks for the response, I guess I should have mentioned this in my post, is this available for 1.18.1? I am trying to find it in my IDE, and I am unable to Edit: I typed it in wrong, thanks! What do I use for the first parameter, the screen parameter? Do I just make a new one, use null? Edited January 18, 20223 yr by CodingPupper3033
January 18, 20223 yr 1 hour ago, CodingPupper3033 said: Thanks for the response, I guess I should have mentioned this in my post, is this available for 1.18.1? yeah it should it's ConnectScreen#connect 1 hour ago, CodingPupper3033 said: What do I use for the first parameter, the screen parameter? Do I just make a new one, use null? which parameter in which method
January 19, 20223 yr Author 3 hours ago, diesieben07 said: The screen you want Minecraft to return to if connection fails or is aborted, usually you should use the currently open screen. Would you mind providing me with an example of using the function. I have attached what I tried below, and it just will not show anything on the screen, and will not join the server at all. Just immetitely calls WorldEvent.Unload. // Try Logging in LoginMod.LOGGER.info("LoginMod is trying to login to " + domain + ":" + port + "!"); ConnectScreen.startConnecting(Minecraft.getInstance().screen, Minecraft.getInstance(), new ServerAddress(domain, port), null); I believe it does try to connect, I just can't see anything, and I can tell it doesn't actually login. Any clue as to why not? Am I misunderstanding the function? Also, thanks so much for your help, I have been getting a lot farther than I would have otherwise. Much appreciated!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.