Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Holding CTRL or SHIFT prevents left- and right-clicking (attacking / using) when Amecs is installed #3774

Open
unilock opened this issue Sep 18, 2024 · 5 comments

Comments

@unilock
Copy link

unilock commented Sep 18, 2024

Steps to Reproduce the Bug

  1. Install Amecs and JEI on Fabric 1.20.1
  2. Start the game, load a world, etc.
  3. Hold the "CTRL" key (control)
  4. 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

@mezz mezz added the bug label Sep 20, 2024
@mezz
Copy link
Owner

mezz commented Sep 20, 2024

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.

@mezz mezz removed the bug label Sep 20, 2024
mezz added a commit that referenced this issue Sep 20, 2024
mezz added a commit that referenced this issue Sep 20, 2024
@unilock
Copy link
Author

unilock commented Sep 20, 2024

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.

@mezz
Copy link
Owner

mezz commented Sep 21, 2024

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.

@mezz
Copy link
Owner

mezz commented Sep 21, 2024

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.

@nycki93
Copy link

nycki93 commented Oct 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants