TypedDataComponent

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.

script.zs
import crafttweaker.api.component.TypedDataComponent;

Description

Holds a DataComponentType and its value.

Members

applyTo(patchedMap as PatchedDataComponentMap)
Applies the TypedDataComponent to a PatchedDataComponentMap.
script.zs
// TypedDataComponent<T>.applyTo<T>(patchedMap as PatchedDataComponentMap);
myTypedDataComponent.applyTo<T>(myPatchedDataComponentMap);

Parameters:

patchedMap Type: PatchedDataComponentMap - The PatchedDataComponentMap to apply the TypedDataComponent to.
asIData() as IData
Converts the TypedDataComponent to an IData.

Returns: The IData representation of the TypedDataComponent.

script.zs
// TypedDataComponent<T>.asIData() as IData;
myTypedDataComponent.asIData();

Return Type: IData

implicit as IData
Converts the TypedDataComponent to an IData.
script.zs
// TypedDataComponent<T> as IData
myTypedDataComponent as IData

Return Type: IData

static of<T>(type as DataComponentType<T>, value as T) as TypedDataComponent<T>
Creates a new TypedDataComponent.

Returns: A new TypedDataComponent.

script.zs
// TypedDataComponent<T>.of<T>(type as DataComponentType<T>, value as T) as TypedDataComponent<T>;
TypedDataComponent<T>.of<T>(myDataComponentType, myT);

Parameters:

type Type: DataComponentType<T> - The DataComponentType of the component.
value Type: T - The value of the component.

Return Type: TypedDataComponent<T>

Getter
Gets the registry name of the stored DataComponentType.
script.zs
// TypedDataComponent<T>.registryName as ResourceLocation
myTypedDataComponent.registryName

Return Type: ResourceLocation

type() as DataComponentType<T>
Gets the DataComponentType of the TypedDataComponent.

Returns: The DataComponentType of the TypedDataComponent.

script.zs
// TypedDataComponent<T>.type<T>() as DataComponentType<T>;
myTypedDataComponent.type<T>();

Return Type: DataComponentType<T>

value() as T
Gets the value of the TypedDataComponent.

Returns: The value of the TypedDataComponent.

script.zs
// TypedDataComponent<T>.value<T>() as T;
myTypedDataComponent.value<T>();

Return Type: T