Chocohead / Rift

A lightweight mod loader and API for Minecraft 1.13
MIT License
62 stars 22 forks source link

Fix crash when a keybinding with a category not known to MC gets added #11

Open gbl opened 5 years ago

gbl commented 5 years ago

When a KeyBinding gets added that uses a category that's unknown to Minecraft, opening the "Controls" option dialog results in a crash.

This is because KeyBinding.java initializes a map (called CATEGORY_ORDER) from category name to a sorting index, and this map doesn't get updated when the KeyBind is added, resulting in an NPE when the GUI actually tries sorting existing indexes.

This patch fixes this behaviour by providing a Mixin that appends the new category name to the CATEGORY_ORDER map whenever a KeyBind with an yet-unknown name gets added.

gbl commented 5 years ago

This is the pull request for the LocalCommandAdder interface + supporting Mixins to allow commands be executed on the client thread without ever being sent to the server, and combining client + server commands in the command line GUI suggestions.