![[LEGACY] InvMove (Forge)](https://media.forgecdn.net/avatars/thumbnails/496/107/256/256/637810258742975073.png)
Conflict with Key Binding Patch mod
Giant-Salted-Fish opened this issue ยท 0 comments
Someone has reported that InvMove-1.12.2-0.4.6 does not work with my [MC-1.12.2] Key Binding Patch v1.3.3.0 - 2024-11-17 mod on Minecraft 1.12.2 (probably also on other MC versions as well). The original github issue can be found here.
I have reproduced this problem in my dev environment, and the cause is that my update logic will check IKeyConflictContext#active()
to prioritize key bindings, but the movement keys are using KeyConflictContext#IN_GAME
in default, which will always return false
if any GUI is open. I initially removed the check for IKeyConflictContext#active()
in KBP v1.3.3.1 to solve this issue. But I think it is better to fix this on InvMove side rather than my side after thinking twice on this. InvMove just need to set KeyConflictContext#UNIVERSAL
for movement key bindings during game start. And this brings several benefits:
- The bounden key will be marked in red (conflict) if someone try to assign
W
,A
,S
,D
to a key binding withKeyConflictContext#GUI
context. - Check key binding activation directly via
KeyBinding#isKeyDown()
, rather than reflection on private fieldKeyBinding#pressed
. - Compatible with mods like Key Binding Patch which rely on the correct semantic of the
IKeyConflictContext
.
Building a customized IKeyConflictContext
that only return true
on GUIs that are supported by InvMove should also work. But be aware that the IKeyConflictContext#active()
method could be called for each key binding on input update, you may want to cache the test result at tick start before calling KeyBinding#updateKeyBindState();
in your code.