DataComponentMap

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

Description

A map of DataComponentTypes to their values.

Implements

Undocumented Interfaces

Iterable<TypedDataComponent<?>>

Operators

in(type as DataComponentType<?>) as bool
Checks if the data component map has a DataComponentType.
script.zs
// ((type as DataComponentType<?>) in DataComponentMap) as bool
myDataComponentType<?> in myDataComponentMap

Parameters:

type Type: DataComponentType<?> - The DataComponentType to check for.

Return Type: bool

Members

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

Returns: A new DataComponentMap.Builder.

script.zs
// DataComponentMap.builder() as DataComponentMapBuilder;
DataComponentMap.builder();

Return Type: DataComponentMapBuilder

static composite(a as DataComponentMap, b as DataComponentMap) as DataComponentMap
Combines two DataComponentMaps.

Returns: A new DataComponentMap that is the result of combining the two DataComponentMaps.

script.zs
// DataComponentMap.composite(a as DataComponentMap, b as DataComponentMap) as DataComponentMap;
DataComponentMap.composite(myDataComponentMap, myDataComponentMap);

Parameters:

a Type: DataComponentMap - The first DataComponentMap to combine.
b Type: DataComponentMap - The second DataComponentMap to combine.

Return Type: DataComponentMap

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

Returns: The value of the data component for the given type.

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

Parameters:

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

Return Type: T?

getOrDefault(type as DataComponentType<T>, defaultValue as T) as T
Gets the value of the data component for the given DataComponentType. If the data component is not present, the default value is returned.

Returns: The value of the data component for the given type.

script.zs
// DataComponentMap.getOrDefault<T>(type as DataComponentType<T>, defaultValue as T) as T;
myDataComponentMap.getOrDefault<T>(myDataComponentType, myT);

Parameters:

type Type: DataComponentType<T> - The DataComponentType to get the value of.
defaultValue Type: T - The default value to return if the data component is not present.

Return Type: T

getTyped(type as DataComponentType<T>) as TypedDataComponent<T>
Gets the TypedDataComponent for the given DataComponentType.

Returns: The TypedDataComponent for the given type.

script.zs
// DataComponentMap.getTyped<T>(type as DataComponentType<T>) as TypedDataComponent<T>;
myDataComponentMap.getTyped<T>(myDataComponentType);

Parameters:

Return Type: TypedDataComponent<T>

has(type as DataComponentType<?>) as bool
Checks if the data component map has a DataComponentType.

Returns: True if the data component map has the DataComponentType, false otherwise.

script.zs
// DataComponentMap.has(type as DataComponentType<?>) as bool;
myDataComponentMap.has(myDataComponentType);

Parameters:

type Type: DataComponentType<?> - The DataComponentType to check for.

Return Type: bool

Getter
Checks if the data component map is empty.
script.zs
// DataComponentMap.isEmpty as bool
myDataComponentMap.isEmpty

Return Type: bool

Getter
Gets the set of DataComponentTypes in the data component map.
script.zs
// DataComponentMap.keySet as Set<DataComponentType<?>>
myDataComponentMap.keySet

Return Type: Set<DataComponentType<?>>

Getter
script.zs
// DataComponentMap.list as List<TypedDataComponent<?>>
myDataComponentMap.list

Return Type: List<TypedDataComponent<?>>

Getter
Gets the size of the data component map.
script.zs
// DataComponentMap.size as int
myDataComponentMap.size

Return Type: int