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 Details

  • Method Details

    • registerDynamicKey

      public net.minecraft.client.KeyMapping registerDynamicKey(String id, int keyCode, String category, Optional<DynamicKeybindAction> action)
      Description copied from interface: DynamicKeyRegistry
      Register a new dynamic key at runtime.
      Specified by:
      registerDynamicKey in interface DynamicKeyRegistry
      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 organization
      action - the action to trigger when pressed (optional)
      Returns:
      the registered KeyMapping
    • registerDynamicKey

      public net.minecraft.client.KeyMapping registerDynamicKey(String id, int keyCode, String category, Optional<DynamicKeybindAction> action, DisplaySpec displaySpec)
      Description copied from interface: DynamicKeyRegistry
      Register a new dynamic key at runtime with custom display metadata.
      Specified by:
      registerDynamicKey in interface DynamicKeyRegistry
      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 organization
      action - the action to trigger when pressed (optional)
      displaySpec - custom display metadata for the keybind label
      Returns:
      the registered KeyMapping
    • unregisterDynamicKey

      public void unregisterDynamicKey(net.minecraft.client.KeyMapping keyBinding)
      Description copied from interface: DynamicKeyRegistry
      Unregister an existing dynamic key.
      Specified by:
      unregisterDynamicKey in interface DynamicKeyRegistry
      Parameters:
      keyBinding - the key binding to unregister
    • getAllDynamicKeys

      public Collection<net.minecraft.client.KeyMapping> getAllDynamicKeys()
      Description copied from interface: DynamicKeyRegistry
      Get all currently registered dynamic keys.
      Specified by:
      getAllDynamicKeys in interface DynamicKeyRegistry
      Returns:
      immutable collection of all dynamic key bindings
    • getKeyBindById

      public net.minecraft.client.KeyMapping getKeyBindById(String id)
      Description copied from interface: DynamicKeyRegistry
      Get a specific keybind by its ID.
      Specified by:
      getKeyBindById in interface DynamicKeyRegistry
      Parameters:
      id - the keybind identifier
      Returns:
      the KeyMapping, or null if not found
    • getKeyBindAction

      public Optional<DynamicKeybindAction> getKeyBindAction(net.minecraft.client.KeyMapping keyBinding)
      Description copied from interface: DynamicKeyRegistry
      Get the action associated with a keybind.
      Specified by:
      getKeyBindAction in interface DynamicKeyRegistry
      Parameters:
      keyBinding - the key mapping to query
      Returns:
      the action, or empty if not set
    • getKeyBindId

      public Optional<String> getKeyBindId(net.minecraft.client.KeyMapping keyBinding)
      Description copied from interface: DynamicKeyRegistry
      Resolve the stable keybind ID for a registered mapping.
      Specified by:
      getKeyBindId in interface DynamicKeyRegistry
      Parameters:
      keyBinding - the key mapping instance
      Returns:
      keybind ID, or empty if mapping is unknown to this registry
    • applyServerSnapshot

      public void applyServerSnapshot(List<StoredKeybind> serverKeybinds, org.slf4j.Logger logger)
      Description copied from interface: ServerSynchronizedDynamicKeyRegistry
      Replaces current client state with a server-authoritative snapshot.
      Specified by:
      applyServerSnapshot in interface ServerSynchronizedDynamicKeyRegistry
    • clearLocalState

      public void clearLocalState(org.slf4j.Logger logger)
      Description copied from interface: ServerSynchronizedDynamicKeyRegistry
      Clears local keybind state without sending removal packets.
      Specified by:
      clearLocalState in interface ServerSynchronizedDynamicKeyRegistry