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.