Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Join Multiplayer World


 Share

Recommended Posts

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? 

Link to comment
Share on other sites

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 by CodingPupper3033
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.