Legacy Fabric-Api

Legacy Fabric-Api

70.5k Downloads

[KeyBindingAPI] Keybinding works but doesn't appear in controls list screen.

thecatcore opened this issue · 7 comments

commented
commented

Upstream seemed to have a similar issue on this week snapshot which was because loader entrypoint was too late for this version. I’ll test if it got fixed at the same time and else I’ll open an issue in loader repo.

commented

I fixed this in speedrunigt by just initializing keys in GameOptions (RedLime/SpeedRunIGT#88)

commented

I've determined that this issue has 2 causes:

  1. In newer versions, the game options are loaded after mod initialization. In 7.10, the game options are loaded before mod initialization. Legacy Fabric Keybinding API injects the modded keybinds via a mixin for game options loading, introducing a race condition where mod keybinds haven't been registered yet when the API attempts to inject them. I've worked around this here: https://github.com/Nolij/Zume/blob/844e625eb94e55ade0828271ef3de0d4d3cd98a3/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java#L26-L31
  2. If keybinds are added for a non-existent category, no category is registered. I've worked around this here: https://github.com/Nolij/Zume/blob/master/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java

With the two workarounds I linked, the issue doesn't occur (at least for my mod; other mods will still have problems). The second fix is necessary for all Legacy Fabric versions. The first one is only necessary for <=7.10.

commented

I fixed this in speedrunigt by just initializing keys in GameOptions (RedLime/SpeedRunIGT#88)

Actually this is way better I'm going to do that instead.

commented

Just realized I forgot to open the issue on loader repo.

commented

Just realized I forgot to open the issue on loader repo.

Link?

commented

We can probably add a KeybindingsRegistryEvent to help with it. You would have to subscribe to it from a ModInitializer instead of a ClientModInitializer tho.