Jump to content

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


Ernio

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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