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

[SOLVED] Best way to pass custom data from server to clients upon connect?


Zarkov
 Share

Recommended Posts

Hi,

 

I'm writing a simple mod which dynamically adds new dimensions that are convenient for automated mining.

 

Everything is basically working as I want, with (surprise) one exception. The problem only occurs when running the mod in a dedicated server setting. If a player logs out while in a mining world, and then tries to reconnect, the client doesn't know about the dimension id and provider type id which causes an exception.

 

I'm handling this in other scenarios by sending custom packets to the client, but I haven't figured out how to provide the information before the client tries to load the dimension when connecting. I would just like to send a list of dimension ids so that the client can call DimensionManager.registerDimension etc. on it's side. I've tried quite a few things, but they either don't work at all or seem unreliable.

 

Any suggestions or help greatly appreciated!

 

Update: I found a solution to this problem, though it's probably not the "best". I'll put it here in case it can help anyone else:

 

I implemented ConnectionHandler and in connectionReceived I use the SaveHandler for dimension 0 to load the player data of the connecting client (by username). This so that I could get the correct dimension id.

 

If the dimension id belongs to a dimension generated by my mod, I send a basic Packet250CustomPayload packet with the dimension id to the client. The client can then call DimensionManager.registerDimension and registerProviderType before the world is loaded, and the exception is avoided.

 

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.

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.