maruohon / justenoughdimensions

A simple Minecraft mod to register custom dimensions to the game
GNU General Public License v3.0
12 stars 7 forks source link

Dimension Name is not working #25

Closed davqvist closed 6 years ago

davqvist commented 6 years ago

Here my custom dimensions: https://pastebin.com/0kdAVq0Z

Using /forge tps shows for dimensions 1100 and 1101 the dimension nme "JED Surface 0" instead of their respective names. Not tested for the others, but they are probably not working either. I also tested with DimensionType.getById( id ).getName() with my mod and it throws an exception, meaning the name is not set. It worked in JED 1.5.0, pretty confident on that.

MC 1.12.2 Forge 2654 JED 1.6.0-dev.20180411.215951

maruohon commented 6 years ago

This is due to the recent-ish change (in the 1.6.0 dev builds at the end of last December I believe) that JED re-uses DimensionType entries, unless you force it to register an exact match. The related config options are listed here: https://pastebin.com/raw/28jeWZyv

So if you want the dimension to actually have the exact names you used, then add the "require_exact_match": true option inside the dimensiontype object.

The change was done to avoid registering new entries with just a different name and type ID, as those are rarely that important to anything, and the registration will start causing issues after the values have been queried enough and the JIT compiler optimizes away the values() method of the enum. This for example led to a crash with Optifine, as it uses the DimensionType value in a switch statement. To be more precise, the crash happens if JED (or any other mod) registers new entries after that JIT optimization has happened, so after something has queried the values() method enough times. Which in practice means that after the game has been running for an X amount of time, registering new entries becomes a problem, at least in some cases/with some mods.

In vanilla terms, the type ID is only used for nether and end portals more or less, so you may be able to use a vanilla portal from a custom dimension, if you use one of the vanilla ids 0, 1 or -1, but I haven't actually tested that. Obviously you can't go back unless the actual dimension ID is also that. And the name is used just in debug messages and some dimension teleportation related things...

davqvist commented 6 years ago

Thanks for your elaborate explanation, but I have trouble understanding that all. To be precise: What are the downside if I use "require_exact_match": true in my configuration?

maruohon commented 6 years ago

In most cases probably nothing. Basically that option alone will cause JED to register the entries when it loads the config, which should be early enough to not cause issues, at least in single player. I'm not entirely sure whether or not that would lead to the Optifine crash on a server though... although... I think I'm syncing the dimensions on initial join to the server? In which case it shouldn't cause issues unless the player joins another server with a different dimension configuration, without restarting the game.

So basically I'm pretty sure in most cases you are fine enabling that. The older way JED worked was that it always registered new entries when (re-)loading the configuration, even if there would have already been identical entries registered. Now it uses existing entries whenever possible, according to the three options that control it (ie. whether it finds a suitable existing entry). So the force_register (oh god why is there a typo in the pastebin on that one?! >_>) option is what would get you into trouble at least with Optifine, if you were to save & exit and then reload a world in single player, or I think also if re-joining a server, maybe(?).

davqvist commented 6 years ago

Thanks, I will try with require_exact_match

davqvist commented 6 years ago

Works, thanks