[Bug]: Holding CTRL or SHIFT prevents left- and right-clicking (attacking / using) when Amecs is installed
unilock opened this issue ยท 6 comments
Steps to Reproduce the Bug
- Install Amecs and JEI on Fabric 1.20.1
- Start the game, load a world, etc.
- Hold the "CTRL" key (control)
- While holding "CTRL", left-click
Expected Behavior
The player's hand swings as they attack whatever is in front of them
Actual Behavior
Nothing happens - it's as if the left-clicking is ignored
Mod Pack URL (Optional)
N/A
Mod Pack Version (Optional)
N/A
Extra Notes (Optional)
Likely related to this commit: c844479
latest.log
https://gist.github.com/unilock/cafa3cc3aadf5bb30646c9f399c0954c
I have debugged this deeply and found the source of the bug and some unexpected things as well.
Built into the vanilla game: If you're on a mac, holding control will convert left-click into right-click.
That means control-left-click cannot break blocks.
So let's just look at shift-click, which is still an issue.
When a key and modifier are pressed, AMECS tries to find all keys that exactly match.
For example, shift-left-click.
Normally in vanilla there is no exact match, so AMECS will then look for things that match without shift (which includes the vanilla 'attack' which is bound to left-click).
With JEI's keybinds added, AMECS does find a perfect match and so it prevents the 'attack' from getting the click at all.
This seems to happen with any keybinds, really. It's not specific to JEI's keybind implementation. If I bind shift-click to open the inventory then my inventory opens instead of breaking the block.
The difference is that JEI has an additional restriction: its keybind will not trigger unless you're in a GUI. AMECS doesn't know about that though, and so it thinks JEI used that shift-click.
Thanks for the report!
I tried messing around with this for a long time, but I believe it may be a bug in AMECS when you bind shift-click to something.
Please report it to them and link back to this issue so I can help out.
Unbinding all of JEI's keybinds appears to resolve the issue.
...it may be a bug in AMECS when you bind shift-click to something.
Interestingly, if I bind SHIFT + LEFT-CLICK to something unrelated to JEI - opening the player's inventory, for example - everything works fine. However, if I use the same key combination for a control added by JEI, the issue I originally described returns.
@Siphalor, do you have any ideas?
As an aside - why doesn't JEI just use the vanilla KeyMapping
class when Amecs is detected, instead of its own implementation? Since Amecs already handles all the additional logic for vanilla keybindings.
Thank you, that's a helpful find. I think the issue must be with JEI's integration.
JEI has a concept of "context" that allows for keybinds to avoid conflicts between different GUIs for example. To support that, the JEI integration with AMECS has some custom logic on top.
I have recreated this same issue in 1.20.1 using only these mods:
- Fabric API 0.92.2
- Just Enough Items 15.20.0.104
- Mouse Wheelie 1.13.0
@nycki93 That makes sense, as Amecs API is embedded in Mouse Wheelie.