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

Synced Keybinds API #104

Merged
merged 3 commits into from
Jan 25, 2025
Merged

Synced Keybinds API #104

merged 3 commits into from
Jan 25, 2025

Conversation

serenibyss
Copy link
Member

Creates a new API for syncing player client key presses to the server for specified keys.

Supports two different types of key checks:

  • "Key Held" - If the key is currently being held down by the player
  • "Key Pressed" - Fired for a registered set of listeners when the key is pressed

Supports lightweight keybinds for a Keyboard key code, wrapped MC KeyBinding types with server syncing, and brand new KeyBinding binds with configuration available on the controls page like normal

@serenibyss serenibyss requested a review from a team January 23, 2025 20:47
@Caedis
Copy link
Member

Caedis commented Jan 23, 2025

How will this interact with https://github.com/Nova-Committee/ModernKeyBinding/tree/Forge/1.7.10 ?
Have not gotten around to merging it into our Controlling fork

@Caedis
Copy link
Member

Caedis commented Jan 23, 2025

Because you are calling, keybind.isKeyPressed, it should be fine

Copy link
Member

@Lyfts Lyfts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we would need to register a listener for every player per keybind?
I can think of loads of keybinds that only exist to send a packet to the server so it would be nice to have the option of always doing an action server-side when a player presses the keybind.
(registering a Consumer that gets called when it's pressed maybe?) Scratch that, just a global listener with the existing interface would be great

@serenibyss
Copy link
Member Author

Is there a reason why we would need to register a listener for every player per keybind? I can think of loads of keybinds that only exist to send a packet to the server so it would be nice to have the option of always doing an action server-side when a player presses the keybind. (registering a Consumer that gets called when it's pressed maybe?) Scratch that, just a global listener with the existing interface would be great

Originally when I wrote this code (quite some time ago for another project), it was written primarily for armor keybinds, so the armor item could subscribe for a player in that case. I think there's merit to both ways of listening though, so I'll look into supporting either way

Copy link
Member

@Lyfts Lyfts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works well, great work!

@serenibyss serenibyss enabled auto-merge (squash) January 25, 2025 15:23
@serenibyss serenibyss merged commit 656c98d into master Jan 25, 2025
1 check passed
@serenibyss serenibyss deleted the server-backed-keybinds-api branch January 25, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants