DataComponentPatch

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.DataComponentPatch;

Description

Stores information about changes that should be made to a DataComponentMap, keeping track of which DataComponentTypes should be added or removed.

Members

static builder() as Builder
Creates a new DataComponentPatch.Builder.

Returns: A new DataComponentPatch.Builder.

script.zs
// DataComponentPatch.builder() as DataComponentPatchBuilder;
DataComponentPatch.builder();

Return Type: DataComponentPatchBuilder

forget(component as DataComponentType<T>) as DataComponentPatch
Removes a DataComponentType from the DataComponentPatch.

Returns: The DataComponentPatch with the DataComponentType removed.

script.zs
// DataComponentPatch.forget<T>(component as DataComponentType<T>) as DataComponentPatch;
myDataComponentPatch.forget<T>(myDataComponentType);

Parameters:

component Type: DataComponentType<T> - The DataComponentType to remove.

Return Type: DataComponentPatch

getComponent(type as DataComponentType<T>) as T?
Gets the value for the given DataComponentType.

Returns: The value for the given DataComponentType.

script.zs
// DataComponentPatch.getComponent<T>(type as DataComponentType<T>) as T?;
myDataComponentPatch.getComponent<T>(myDataComponentType);

Parameters:

type Type: DataComponentType<T> - The DataComponentType to get the value for.

Return Type: T?

Getter
Checks if the DataComponentPatch is empty.
script.zs
// DataComponentPatch.isEmpty as bool
myDataComponentPatch.isEmpty

Return Type: bool

Getter
Gets the size of the DataComponentPatch.
script.zs
// DataComponentPatch.size as int
myDataComponentPatch.size

Return Type: int

split() as SplitResult
Splits the DataComponentPatch into a DataComponentPatch.SplitResult containing the added and removed DataComponentMaps.

Returns: A DataComponentPatch.SplitResult containing the added and removed DataComponentMaps.

script.zs
// DataComponentPatch.split() as DataComponentPatchSplitResult;
myDataComponentPatch.split();

Return Type: DataComponentPatchSplitResult