Class ExpandDataComponentHolder
java.lang.Object
com.blamejared.crafttweaker.natives.component.ExpandDataComponentHolder
An interface that stores DataComponents
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TgetComponent(net.minecraft.core.component.DataComponentHolder internal, Class<T> tClass, net.minecraft.core.component.DataComponentType<T> type) Gets the data identified by the given DataComponentType.static net.minecraft.core.component.DataComponentMapgetComponents(net.minecraft.core.component.DataComponentHolder internal) Gets the internal map of ComponentType -> Datastatic IDatagetJsonComponent(net.minecraft.core.component.DataComponentHolder internal, net.minecraft.core.component.DataComponentType type) Get an arbitrary component by type.static <T> TgetOrDefault(net.minecraft.core.component.DataComponentHolder internal, Class<T> tClass, net.minecraft.core.component.DataComponentType<T> type, T defaultValue) Gets the data identified by the given DataComponentType.static booleanhas(net.minecraft.core.component.DataComponentHolder internal, net.minecraft.core.component.DataComponentType<?> type) Checks whether the holder contains the given DataComponent, which is indentified by the type.
-
Constructor Details
-
ExpandDataComponentHolder
public ExpandDataComponentHolder()
-
-
Method Details
-
getComponents
public static net.minecraft.core.component.DataComponentMap getComponents(net.minecraft.core.component.DataComponentHolder internal) Gets the internal map of ComponentType -> Data- Returns:
- The internal map.
-
has
public static boolean has(net.minecraft.core.component.DataComponentHolder internal, net.minecraft.core.component.DataComponentType<?> type) Checks whether the holder contains the given DataComponent, which is indentified by the type.- Parameters:
type- The componenttype to check for.- Returns:
- Whether the holder contains the DataComponent.
- DocParam:
- type invalid input: '<'componenttype:minecraft:stack_size>
-
getOrDefault
public static <T> T getOrDefault(net.minecraft.core.component.DataComponentHolder internal, Class<T> tClass, net.minecraft.core.component.DataComponentType<T> type, T defaultValue) Gets the data identified by the given DataComponentType. If the ComponentHolder does not have the Component, then the default value is returned.- Type Parameters:
T- The type of the ComponentType- Parameters:
tClass- The type of the class stored within the component.type- The componenttype to getdefaultValue- The default value to return in the event that the holder does not have the component.- Returns:
- The value if it exists or the default value.
- DocParam:
int?, type invalid input: '<'componenttype:minecraft:stack_size>, defaultValue 64
-
getComponent
public static <T> T getComponent(net.minecraft.core.component.DataComponentHolder internal, Class<T> tClass, net.minecraft.core.component.DataComponentType<T> type) Gets the data identified by the given DataComponentType. If the ComponentHolder does not have the Component, then null is returned.- Type Parameters:
T- The type of the class stored within the component.- Parameters:
type- The componenttype to get- Returns:
- The value if it exists or null.
- DocParam:
int?, type invalid input: '<'componenttype:minecraft:stack_size>, defaultValue 64
-
getJsonComponent
public static IData getJsonComponent(net.minecraft.core.component.DataComponentHolder internal, net.minecraft.core.component.DataComponentType type) 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.- Parameters:
type- The componenttype to target.- Returns:
- A
IDatarepresentation of the Serialized DataComponent - DocParam:
- type invalid input: '<'componenttype:minecraft:stack_size>
-