ItemStack
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.
import crafttweaker.api.item.ItemStack;Description
This is the vanilla ItemStack. It is recommended that you useIItemStack whenever possible
They can be cast from each other, though.
Implements
ItemStack
implements the following interfaces:
DataComponentHolder,MutableDataComponentHolder
Undocumented Interfaces
IItemStackExtension,IDataComponentHolderExtension
Operators
myDataComponentType<?> in myItemStackParameters:
Return Type:
bool
Members
myItemStack.applyComponents(myDataComponentMap);Parameters:
components: DataComponentMap Type: DataComponentMap myItemStack.applyComponents(myDataComponentPatch);Parameters:
patch: DataComponentPatch Type: DataComponentPatch // ItemStack as IIngredientmyItemStack as IIngredient
Return Type:
IIngredient
// ItemStack as IItemStackmyItemStack as IItemStack
Return Type:
IItemStack
// ItemStack.components as DataComponentMapmyItemStack.components
Return Type:
DataComponentMap
myItemStack.copyFrom(myDataComponentHolder, myDataComponentType<?>[]);Parameters:
src: DataComponentHolder Type: DataComponentHolder componentTypes: DataComponentType<?>[] Type: DataComponentType<?>[] Returns: The value if it exists or null.
myItemStack.getComponent<T>(<componenttype:minecraft:stack_size>);Parameters:
Return Type:
T
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
myItemStack.getJsonComponent(<componenttype:minecraft:stack_size>);Parameters:
Return Type:
IData
Returns: The value if it exists or the default value.
myItemStack.getOrDefault<T>(<componenttype:minecraft:stack_size>, 64);Parameters:
defaultValue: T Type: T
- The default value to return in the event that the holder does not have the component.
Return Type:
T
Returns: Whether the holder contains the DataComponent.
myItemStack.has(<componenttype:minecraft:stack_size>);Parameters:
Return Type:
bool
myItemStack.remove<T>(myDataComponentType);Parameters:
componentType: DataComponentType<T> Type: DataComponentType<T>
Return Type:
T?
myItemStack.setComponent<T>(myDataComponentType, myT);Parameters:
componentType: DataComponentType<T> Type: DataComponentType<T> value: T? Type: T?
Return Type:
T?
// ItemStack.update<T>(componentType as DataComponentType<T>, value as T, updater as UnaryOperator<T>) as T?;myItemStack.update<T>(myDataComponentType, myT, myUnaryOperator);Parameters:
componentType: DataComponentType<T> Type: DataComponentType<T> value: T Type: T updater: UnaryOperator<T> Type: UnaryOperator<T>
Return Type:
T?
// ItemStack.update<T, U>(componentType as DataComponentType<T>, value as T, updateContext as U, updater as BiFunction<T, T, U>) as T?;myItemStack.update<T, U>(myDataComponentType, myT, myU, myBiFunction);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?