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

InventoryClickEvent does not detect middle clicks (Survival mode) #11465

Open
Klyser8 opened this issue Oct 3, 2024 · 4 comments
Open

InventoryClickEvent does not detect middle clicks (Survival mode) #11465

Klyser8 opened this issue Oct 3, 2024 · 4 comments
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1

Comments

@Klyser8
Copy link

Klyser8 commented Oct 3, 2024

Expected behavior

When printing out the result of event.getClick() during the InventoryClickEvent, I was expecting ClickType.MIDDLE to get printed upon clicking with the mousewheel on an item.

Observed/Actual behavior

Instead, what I've found out is that no matter what one tries doing, ClickType.MIDDLE can never be detected.
Upon middle clicking an item in an inventory (could be any inventory from what I saw), the only click being detected is ClickType.UNKNOWN.
On discord I was initially told that detecting middle clicks isn't supported, though I find it really strange that the only way to get an UNKNOWN click type is through middle-clicking an item in Survival Mode.

Steps/models to reproduce

  1. Create a barebones plugin, one which simply listens to the InventoryClickEvent
  2. Print out event.getClick()
  3. In survival mode, try all types of clicks that are meant to be available (Left, right, shift-left, shift-right, double left, switch hand, number key, drop, ctrl drop, middle click)
  4. All click types get printed like expected, except for ClickType.MIDDLE

Plugin and Datapack List

None, simply the above stated barebones plugin.

Paper version

This server is running Paper version 1.21.1-99-master@1bc02e6 (2024-09-25T02:41:02Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)

Other

No response

@Klyser8 Klyser8 added status: needs triage type: bug Something doesn't work as it was intended to. labels Oct 3, 2024
@Klyser8
Copy link
Author

Klyser8 commented Oct 3, 2024

Update: Turns out that the behavior breaks when rebinding the middle mouse button to another button (As I have, since I develop on my macbook and there is no middle mouse button to use).
It seems that rebinding the middle mouse button to a keyboard key (in my case, R) breaks the way that the middle button is detected to behave like I described above.

@SoSeDiK
Copy link
Contributor

SoSeDiK commented Oct 3, 2024

Was able to reproduce this. Remapping MMB (to M on keyboard in my case) leads to invalid(?) actions being sent from the client:

  • Having air on cursor and pressing remapped MMB over an item in inventory sends CLONE action with 0 (LMB) button num.
  • And having any item on the cursor will lead to PICKUP action with 3 (MMB).

Both of these are unmapped/unknown actions, so it falls back to UNKNOWN.

@Machine-Maker
Copy link
Member

Hmm, the javadocs for ClickType.MIDDLE kinda specifically state that it's the middle mouse button being used, not "whatever action the middle mouse button does by default". I think, because of that, we have to add another enum value and then maybe a helper method to check if it's either MIDDLE or whatever the new one is, like isCloneAction() or something.

@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Oct 4, 2024
@Klyser8
Copy link
Author

Klyser8 commented Oct 5, 2024

Hmm, the javadocs for ClickType.MIDDLE kinda specifically state that it's the middle mouse button being used, not "whatever action the middle mouse button does by default". I think, because of that, we have to add another enum value and then maybe a helper method to check if it's either MIDDLE or whatever the new one is, like isCloneAction() or something.

That's fair enough. Either way though, I think it's important to be able to pick up whether a user rebound the key or not as especially those on laptops may have, and plugins which rely on middle click functionality would break completely.

Also, while I'm at it, from what I can tell there might be a possibility to detect a player's middle-mouse click (or whatever the button was rebound to) while they are on survival, with no item on cursor yet an item in the slot beneath it. As it servers no functionality in survival it might be a handy way to provide plugin makers with a way to implement functionality in InventoryClickEvents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1
Projects
Status: ✅ Accepted
Development

No branches or pull requests

3 participants