MutableDataComponentHolder
Importing the class
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.
Description
An interface that stores DataComponentsImplements
MutableDataComponentHolder
implements the following interfaces:
Undocumented Interfaces
IDataComponentHolderExtension
Operators
in(type as DataComponentType<?>) as bool
Checks whether the holder contains the given DataComponent, which is indentified by the type.
Parameters:
Return Type:
bool
Members
applyComponents(components as DataComponentMap)
Parameters:
components: DataComponentMap
Type: DataComponentMap
applyComponents(patch as DataComponentPatch)
Parameters:
patch: DataComponentPatch
Type: DataComponentPatch
Getter
Gets the internal map of ComponentType -> Data
Return Type:
DataComponentMap
copyFrom(src as DataComponentHolder, componentTypes as DataComponentType<?>[])
Parameters:
src: DataComponentHolder
Type: DataComponentHolder
componentTypes: DataComponentType<?>[]
Type: DataComponentType<?>[]
getComponent(type as DataComponentType<T>) as T
Gets the data identified by the given DataComponentType. If the ComponentHolder does not have the Component, then null is returned.
Returns: The value if it exists or null.
Parameters:
Return Type:
T
getJsonComponent(type as DataComponentType<T>) as IData
Get an arbitrary component by type. This is useful to interact with components added by mods that do not have a CraftTweaker method.
If the ComponentAccess does not have the type, an exception is thrown. If the ComponentAccess is not serializable, an exception is thrown.
If the ComponentAccess does not have the type, an exception is thrown. If the ComponentAccess is not serializable, an exception is thrown.
Returns: A IData
representation of the Serialized DataComponent
Parameters:
Return Type:
IData
getOrDefault(type as DataComponentType<T>, defaultValue as T) as T
Gets the data identified by the given DataComponentType. If the ComponentHolder does not have the Component, then the default value is returned.
Returns: The value if it exists or the default value.
Parameters:
defaultValue: T
Type: T
- The default value to return in the event that the holder does not have the component.
Return Type:
T
has(type as DataComponentType<?>) as bool
Checks whether the holder contains the given DataComponent, which is indentified by the type.
Returns: Whether the holder contains the DataComponent.
Parameters:
Return Type:
bool
remove(componentType as DataComponentType<T>) as T?
Parameters:
componentType: DataComponentType<T>
Type: DataComponentType<T>
Return Type:
T?
setComponent(componentType as DataComponentType<T>, value as T?) as T?
Parameters:
componentType: DataComponentType<T>
Type: DataComponentType<T>
value: T?
Type: T?
Return Type:
T?
update(componentType as DataComponentType<T>, value as T, updater as UnaryOperator<T>) as T?
Parameters:
componentType: DataComponentType<T>
Type: DataComponentType<T>
value: T
Type: T
updater: UnaryOperator<T>
Type: UnaryOperator<T>
Return Type:
T?
update(componentType as DataComponentType<T>, value as T, updateContext as U, updater as BiFunction<T, T, U>) as T?
Parameters:
componentType: DataComponentType<T>
Type: DataComponentType<T>
value: T
Type: T
updateContext: U
Type: U
updater: BiFunction<T, T, U>
Type: BiFunction<T, T, U>
Return Type:
T?