Record Class DynamicKeybindAction
java.lang.Object
java.lang.Record
dev.munebase.dynamickeybinds.action.DynamicKeybindAction
- Record Components:
actionID- unique identifier for the action type (e.g., "example:read_block_above")data- NBT compound containing action-specific data (e.g., {dimension, pos})
public record DynamicKeybindAction(String actionID, net.minecraft.nbt.CompoundTag data)
extends Record
Represents a custom action triggered by a dynamic keybind.
This immutable record stores an action identifier and optional NBT data payload,
allowing third-party mods to define custom context-aware keybind behaviors.
The action can be serialized to NBT for persistence and network synchronization.
Purpose: Enables extensibility by allowing other mods to create contextual keybind actions. For example, a library mod might define an action that stores block coordinates and dimension, enabling the keybind to perform different operations depending on where in the world it was created.
Example:
// Create an action with custom data
CompoundTag data = new CompoundTag();
data.putInt("dimension", 0);
data.putInt("x", 250);
data.putInt("y", 64);
data.putInt("z", 300);
DynamicKeybindAction action = new DynamicKeybindAction("example:read_block_above", data);
-
Constructor Summary
ConstructorsConstructorDescriptionDynamicKeybindAction(String actionID) Convenience constructor for actions without data payload.DynamicKeybindAction(String actionID, net.minecraft.nbt.CompoundTag data) Creates a new DynamicKeybindAction with null-safe data. -
Method Summary
Modifier and TypeMethodDescriptionactionID()Returns the value of theactionIDrecord component.net.minecraft.nbt.CompoundTagdata()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
DynamicKeybindAction
Convenience constructor for actions without data payload.- Parameters:
actionID- the action identifier
-
DynamicKeybindAction
Creates a new DynamicKeybindAction with null-safe data.- Parameters:
actionID- the action identifierdata- the action data (null values become empty CompoundTag)
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
actionID
Returns the value of theactionIDrecord component.- Returns:
- the value of the
actionIDrecord component
-
data
public net.minecraft.nbt.CompoundTag data()Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-