Class NetworkedDynamicKeyRegistry
java.lang.Object
dev.munebase.dynamickeybinds.client.NetworkedDynamicKeyRegistry
- All Implemented Interfaces:
ServerSynchronizedDynamicKeyRegistry,DynamicKeyRegistry
public final class NetworkedDynamicKeyRegistry
extends Object
implements ServerSynchronizedDynamicKeyRegistry
Client-side dynamic key registry that always uses server networking for add/remove operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyServerSnapshot(List<StoredKeybind> serverKeybinds, org.slf4j.Logger logger) Replaces current client state with a server-authoritative snapshot.voidclearLocalState(org.slf4j.Logger logger) Clears local keybind state without sending removal packets.Collection<net.minecraft.client.KeyMapping>Get all currently registered dynamic keys.getKeyBindAction(net.minecraft.client.KeyMapping keyBinding) Get the action associated with a keybind.net.minecraft.client.KeyMappinggetKeyBindById(String id) Get a specific keybind by its ID.net.minecraft.client.KeyMappingregisterDynamicKey(String id, int keyCode, String category, Optional<DynamicKeybindAction> action) Register a new dynamic key at runtime.voidunregisterDynamicKey(net.minecraft.client.KeyMapping keyBinding) Unregister an existing dynamic key.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.munebase.dynamickeybinds.DynamicKeyRegistry
unregisterDynamicKey
-
Constructor Details
-
NetworkedDynamicKeyRegistry
-
-
Method Details
-
registerDynamicKey
public net.minecraft.client.KeyMapping registerDynamicKey(String id, int keyCode, String category, Optional<DynamicKeybindAction> action) Description copied from interface:DynamicKeyRegistryRegister a new dynamic key at runtime.- Specified by:
registerDynamicKeyin interfaceDynamicKeyRegistry- Parameters:
id- unique identifier for the keybind (e.g., "mymod:key_name")keyCode- the GLFW key code (e.g., GLFW.GLFW_KEY_K)category- the keybind category for menu organizationaction- the action to trigger when pressed (optional)- Returns:
- the registered KeyMapping
-
unregisterDynamicKey
public void unregisterDynamicKey(net.minecraft.client.KeyMapping keyBinding) Description copied from interface:DynamicKeyRegistryUnregister an existing dynamic key.- Specified by:
unregisterDynamicKeyin interfaceDynamicKeyRegistry- Parameters:
keyBinding- the key binding to unregister
-
getAllDynamicKeys
Description copied from interface:DynamicKeyRegistryGet all currently registered dynamic keys.- Specified by:
getAllDynamicKeysin interfaceDynamicKeyRegistry- Returns:
- immutable collection of all dynamic key bindings
-
getKeyBindById
Description copied from interface:DynamicKeyRegistryGet a specific keybind by its ID.- Specified by:
getKeyBindByIdin interfaceDynamicKeyRegistry- Parameters:
id- the keybind identifier- Returns:
- the KeyMapping, or null if not found
-
getKeyBindAction
Description copied from interface:DynamicKeyRegistryGet the action associated with a keybind.- Specified by:
getKeyBindActionin interfaceDynamicKeyRegistry- Parameters:
keyBinding- the key mapping to query- Returns:
- the action, or empty if not set
-
applyServerSnapshot
Description copied from interface:ServerSynchronizedDynamicKeyRegistryReplaces current client state with a server-authoritative snapshot.- Specified by:
applyServerSnapshotin interfaceServerSynchronizedDynamicKeyRegistry
-
clearLocalState
public void clearLocalState(org.slf4j.Logger logger) Description copied from interface:ServerSynchronizedDynamicKeyRegistryClears local keybind state without sending removal packets.- Specified by:
clearLocalStatein interfaceServerSynchronizedDynamicKeyRegistry
-