-
Bug
-
Resolution: Fixed
-
1.21, 1.21.1
-
None
-
Plausible
-
Networking
-
Normal
-
Platform
Hello,
We found that the registry system in the game allows for duplicate entries to be added, this appears to be a small oversight as there is code that appears to prevent this but fails to do so due to a missing “throw”. This issue mostly affects mods, but can be reproduced by a vanilla client connecting to a server that sends duplicate entries in a registry upon login. While I could not find any visible indicators of this causing a problem in vanilla, I strongly believe its against the design of the registry system and could lead to subtle issues that I haven’t thought of.
Looking at the code in MappedRegistry.register there are checks for duplicate keys or duplicate values, when either is present an IllegalStateException is created and passed to Util.pauseInIde. However this exception is never thrown, silently allowing duplicate entries as pauseInIde effectively does nothing in the normal game. The fix appears to be trivial as follows:
Util.pauseInIde(new IllegalStateException("Adding duplicate key '" + resourceKey + "' to registry”));
becomes
throw Util.pauseInIde(new IllegalStateException("Adding duplicate key '" + resourceKey + "' to registry”));
Please let me know if any more information is required, or if this behaviour is intended.
Regards,
modmuss