ReBind

ReBind

690k Downloads

[1.7.10] Incompatibility with Macros litemod

DracoScythem opened this issue ยท 9 comments

commented

If the Macros litemod is installed alongside ReBind opening the controls menu crashes the game.
MC: 1.7.10
Versions: 2.7.0 [latest] (ReBind) / 0.10.12 [latest] (Macros)
Full log: https://paste.ee/p/H7zWG (normal) / https://paste.ee/p/Oz3qH (incl. debug and trace logs)
Macros MCF thread: https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1275039-macro-keybind-mod

If you need more information, please don't hesitate to ask :)

commented

The owner has mysteriously disappeared, but nevertheless I'm having the same problem - a crash when opening the options keybinding UI when both CustomNPCs and COFHCore are installed. Only the three mods are necessary to cause the crash, so if you're interested in experimenting, use these three and nothing else.

commented

This problems should be fixed in ver: 2.7.3. Thank you both for help.

commented

After some more digging I think I might've found the cause:

Macros adds 3 special keybinds to the game, that aren't extensions of GuiKeyBindingList.KeyEntry but custom implementations of GuiListExtended.IGuiListEntry. Also they aren't actually registered in any regular way, but instead injected into GuiKeyBindingList.field_148190_m by replacing that Array via reflection in every instance of GuiControls on the first render tick of the encapsulated GuiKeyBindingList.

So the moment an instance of GuiKeyBindingList is rendered its KeyEntry Array (field_148190_m) will be replaced by Macros with one that's 3 slots longer to add Macros' own special keybinds.

That's the same Array that is being replaced by ReBinds sorting Method immediatly before the AOOBE is thrown. That sorting function - being reliant on ReBinds independent KeyBindingProperty system - does not know of those 3 keybindings' existance and will not contain them.
This then leads to field_148190_m being 3 slots too short, which will ultimately cause the AOOBE.

Hypothetically this should be fixable by changing the L5 block of GuiKeyBindingList. to create a bigger Array if Macros is loaded (which can be detected - although not very elegantly - by checking for net.eq2online.macros.LiteModMacros.class on Launch.classloader).
There's probably a better (cleaner and more general) solution, it's just what I could come up with on the spot ^^

commented

Your conclusions helped me to figure it out so soon. The main problem was Macros created two KeyBinding instances, but didn't add it to GameSettings#keyBindings array. KeyBindingProperty instances are created for every KeyBinding so i just added extra keybindings check from KeyBindingProperty map to ReBindHooks#removeHiddenKeybindings() (which called after all mods postinit) and now all unregistered keybindings will be added to GameSettings#keyBindings array. Thus GuiListExtended.IGuiListEntry array in GuiKeyBindingList will be created with proper size.

You can download and test working build from my google drive: link. At least it will not crash. But because of custom GuiListExtended.IGuiListEntry there are some limitations for this keybindings manipulation via ReBind config. It's impossible to hide or disable Macros keybindings, but other features should work.

Waiting for your response.

commented

Thank you for detailed report. As i can see Macros also does significant changes to controls. It isn't get detected by Forge loader and this causes wrong keybinding identification. I try to resolve it later, but i can't do anything with such problems in the near future.

commented

Such thing have happenned in 2.7.1 if you didn't remove old config. File "keybindings.json" hasn't been created and "rebind.json" hasn't been updated. In ver. 2.7.2 it was fixed, configs will be created properly even if old "rebind.json" wasn't removed. This version will be available on Curse soon.

commented

Seems to work perfectly ๐Ÿ‘

One minor thing I noticed during testing though: For some reason the contents of keybindings.json were appended to the rebind.json instead of getting their own file (only seems to affect initial creation as everything worked normally after extracting the files from the jar manually)

commented

I can confirm the fix working in the release version, however I found a new issue that seems to be related to this (or its fix):
In certain installations (I was unable to find a minimal setup to reproduce the issue) opening the controls menu still crashes the game (https://paste.ee/p/C5nCa) - as it seems due to GuiKeyBindingList.field_148190_m containing null values (perhaps it's too long?).

Additional info I hope to be useful:
Filtering those null values immediatly after GuiKeyBindingList.() / L4 results in https://paste.ee/p/ytrk1
EDIT: This is also the crash 2.7.1 ends up with (without Macros installed)

If there's any additional information I can provide don't hesitate to ask :)

commented

Okay, some more testing later I still haven't found a way to reproduce this with a reasonably small modlist, however it seems that KeyCombinations is unaffected by this which makes me question my original assumption of this being directly related to the original issue...