I have defined several keys for use by a mod, by defining each as a KeyBinding, and registering each by ClientRegistry.registerKeyBinding().
This has been working OK up to 1.11.2, but has hit a problem when I updated to 1.12.
Minecraft crashes when entering Options => Controls, and I can see why:
I have provided a custom category for all of the bound keys, so that they will all appear grouped under a heading for my mod in the Options => Controls screen. What has happened in 1.12 is that several changes have been made to the net.minecraft.client.settings.KeyBinding.class.
There is a private static final Map attribute called field_193627_d and this is filled with a set of key category descriptions, each mapped to an integer.
E.g. field_193627_d.put("key.categories.inventory", Integer.valueOf(3));
Of course, my custom key category doesn't appear here, and there doesn't seem to be a way I can add it.
This wouldn't be a problem, except there is now a compareTo() method on KeyBinding, which is called (indirectly) from net.minecraft.client.gui.GuiKeyBindingList - and this fails with a NullPointerException because my custom category is unrecognised.
I have worked around this, by assigning my key bindings to one of the existing categories, but this isn't ideal, as I would like to be able to group my mod's keys together like I did previously, and of course anybody else who writes a mod that binds keys will probably have to put theirs into the same group, which begins to get messy.
I wonder whether anyone has any suggestions as to how to improve the key binding mechanism in 1.12?