Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?ย 

  • 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 by CodingPupper3033

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

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.