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.

[1.8.9+][SOLVED] Detect connection to integrated server ASAP (before anything).

Featured Replies

Posted

I am coding client mod which should only work (about 90% of it) only if server has proper mod.

Please remind me - how do I check that?

 

Would be awesome if I could have this boolean before EVERYTHING else (joining world (client), etc.)

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Okay after a break...

 

So - while @NetworkCheckHandler is a nice tool to check if server, I am connecting to, has my mod (so I can disable (make if bool) all client-sided events if the server is not using mod) ...it is still not enough.

 

I still need to figure out how to detect when you try to join Integrated server.

 

Part on my CLIENT-ONLY mod:

/**
 * Set to true if mod should be operational.
 * False cases:
 * - Client connected to integrated server.
 * - Client connected to server which doesn't have this mod.
 */
private static boolean OPERATIONAL;

 

So yeah - @NetworkCheckHandler covers second "false case", but idk how to get 1st one before ANYTHING happens.

 

Is there something NICE that is called before PlayerLoggedInEvent that would allow me to get "real" return from Minecraft.getMinecraft().isIntegratedServerRunning()?

(by "real" I mean that apparently Integrated server is not really flushing. Meaning: If you would call it inside @NetworkCheckHandler it might or might not be true. Same goes for #getIntegratedServer() - it might or not return null or some instance (old one?).

 

Awaiting :D

1.7.10 is no longer supported by forge, you are on your own.

FMLNetworkEvent.ClientConnectedToServerEvent

is fired (on the Netty thread) when the client connects to a server.

 

The

FMLNetworkEvent.ClientConnectedToServerEvent#isLocal

field will be

true

when the connection is local, i.e. the server is an integrated server and this client is the host.

 

Minecraft#getCurrentServerData

will return the current

ServerData

.

ServerData#func_181041_d

(

isOnLAN

in recent mappings) will return

true

when the connection is to a LAN server (i.e. an integrated server hosted by a different client).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

Yay, that should do it.

 

I was literally looking for ClientConnectedToServerEvent, just didn't think of actually using search (it's inner class so after i couldn't find it I was like "maybe they removed it?").

That LAN thing will be also useful :D

 

CLOSED

1.7.10 is no longer supported by forge, you are on your own.

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.