Class DataComponent<T>
java.lang.Object
com.github.darksoulq.abyssallib.world.item.component.DataComponent<T>
- Type Parameters:
T- The type of the value stored within this component.
An abstract base class representing a single piece of metadata attached to an item or block.
DataComponents are used to store structured, type-safe information (such as names, custom markers, or durability).
-
Constructor Summary
ConstructorsConstructorDescriptionDataComponent(T value) Constructs a new DataComponent with the specified value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this component against another object for equality.abstract DataComponentType<?> getType()Retrieves the specific type definition associated with this component instance.getValue()Gets the current value stored in this component.inthashCode()Returns a hash code value for the component.toString()Returns a string representation of the DataComponent.
-
Constructor Details
-
DataComponent
Constructs a new DataComponent with the specified value.- Parameters:
value- The initial value to be stored in this component.
-
-
Method Details
-
getType
Retrieves the specific type definition associated with this component instance.This is used by the registry and serialization systems to identify how to handle the component's data.
- Returns:
- The
DataComponentTyperepresenting this component's category.
-
getValue
-
equals
Compares this component against another object for equality.Two components are considered equal if they share the exact same type and their internal values are logically equivalent.
-
hashCode
-
toString
Returns a string representation of the DataComponent.This method attempts to resolve the component's unique identifier from
Registries.DATA_COMPONENT_TYPES. If not found, it falls back to the simple name of the type class.
-