0% found this document useful (0 votes)
44 views1 page

IItemStack - CraftTweaker Documentation

The CraftTweaker Documentation for version 1.20.1 provides detailed information on using the IItemStack interface, including commands, parameters, and return types for various functions. It covers how to manipulate item stacks, add attributes, manage tooltips, and handle enchantments. The documentation serves as a comprehensive guide for users to effectively script and customize items within the CraftTweaker environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

IItemStack - CraftTweaker Documentation

The CraftTweaker Documentation for version 1.20.1 provides detailed information on using the IItemStack interface, including commands, parameters, and return types for various functions. It covers how to manipulate item stacks, add attributes, manage tooltips, and handle enchantments. The documentation serves as a comprehensive guide for users to effectively script and customize items within the CraftTweaker environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CraftTweaker Documentation 1.20.

1 Search

Home
Previous Equipable Ingredient Next
Commands
Examples
IItemStack
Getting Started With Scripts
Global Keywords Importing the class
Tutorials
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to
Vanilla import it. Simply add the import at the top of the file.
Api
script.zs
Advancement
Block import crafttweaker.api.item.IItemStack;

Bracket
Command Implements
Data IItemStack implements the following interfaces:
Entity IIngredient , IIngredientWithAmount , CommandStringDisplayable

Event
Fluid
Operators
Food in
Game
Ingredient in(ingredient as IIngredient) as bool
Item
Does the ingredient contain the given ingredient?
Alchemy
script.zs
Enchantment
Property // ((ingredient as IIngredient) in IItemStack) as bool

Tiered myIIngredient in myIItemStack

Tooltip
Parameters:
ingredient: IIngredient - The ingredient to check
Return Type: bool

*(amount as int) as IIngredientWithAmount

Use this in contexts where machines accept more than one item to state that fact.
script.zs

// (IItemStack * (amount as int)) as IIngredientWithAmount


myIItemStack * myInt

Parameters:
amount: int
Return Type: IIngredientWithAmount

|(other as IIngredient) as IIngredientList

script.zs

// (IItemStack | (other as IIngredient)) as IIngredientList


myIItemStack | myIIngredient

Parameters:
other: IIngredient

Return Type: IIngredientList

%(percentage as double) as Percentaged<IItemStack>

script.zs

// (IItemStack % (percentage as double)) as Percentaged<IItemStack>


myIItemStack % myDouble

Parameters:
percentage: double

Return Type: Percentaged<IItemStack>

*(amount as int) as IItemStack

Sets the amount of the ItemStack


script.zs

// (IItemStack * (amount as int)) as IItemStack


myIItemStack * myInt

Parameters:
amount: int - new amount

Return Type: IItemStack

Members
addGlobalAttributeModifier

addGlobalAttributeModifier(attribute as Attribute, name as string, value as double,


operation as Operation, slotTypes as EquipmentSlot[])

Adds an AttributeModifier to this IIngredient.


Attributes added with this method appear on all ItemStacks that match this IIngredient, regardless
of how or when the ItemStack was made, if you want to have the attribute on a single specific
ItemStack (such as a specific Diamond Sword made in a recipe), then you should use
IItemStack#withAttributeModifier
script.zs

// IItemStack.addGlobalAttributeModifier(attribute as Attribute, name as string, value a


myIItemStack.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Ex

Parameters:
attribute: Attribute - The Attribute of the modifier.

name: string - The name of the modifier.

value: double - The value of the modifier.


operation: AttributeOperation - The operation of the modifier.

slotTypes: EquipmentSlot[] - What slots the modifier is valid for.

addGlobalAttributeModifier(attribute as Attribute, uuid as string, name as string, value


as double, operation as Operation, slotTypes as EquipmentSlot[])

Adds an AttributeModifier to this IIngredient using a specific UUID.


The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You
can use /ct hand attributes to get the UUID of the attributes on an ItemStack.
Attributes added with this method appear on all ItemStacks that match this IIngredient, regardless
of how or when the ItemStack was made, if you want to have the attribute on a single specific
ItemStack (such as a specific Diamond Sword made in a recipe), then you should use
IItemStack#withAttributeModifier
script.zs

// IItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as string, name as


myIItemStack.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c

Parameters:
attribute: Attribute - The Attribute of the modifier.

uuid: string - The unique identifier of the modifier to replace.


name: string - The name of the modifier.

value: double - The value of the modifier.


operation: AttributeOperation - The operation of the modifier.
slotTypes: EquipmentSlot[] - What slots the modifier is valid for.

addGlobalAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value


as double, operation as Operation, slotTypes as EquipmentSlot[])

Adds an AttributeModifier to this IIngredient using a specific UUID.


The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You
can use /ct hand attributes to get the UUID of the attributes on an ItemStack.
Attributes added with this method appear on all ItemStacks that match this IIngredient, regardless
of how or when the ItemStack was made, if you want to have the attribute on a single specific
ItemStack (such as a specific Diamond Sword made in a recipe), then you should use
IItemStack#withAttributeModifier
script.zs

// IItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as UUID, name as s


myIItemStack.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, IIt

Parameters:
attribute: Attribute - The Attribute of the modifier.
uuid: UUID - The unique identifier of the modifier to replace.
name: string - The name of the modifier.

value: double - The value of the modifier.


operation: AttributeOperation - The operation of the modifier.
slotTypes: EquipmentSlot[] - What slots the modifier is valid for.

addShiftTooltip

addShiftTooltip(content as Component, showMessage as Component = null)

script.zs

// IItemStack.addShiftTooltip(content as Component, showMessage as Component = null);


myIItemStack.addShiftTooltip(myComponent, myComponent);

Parameters:
content: Component
showMessage: Component (optional)
Default Value: null

addTooltip

addTooltip(content as Component)

script.zs

// IItemStack.addTooltip(content as Component);
myIItemStack.addTooltip(myComponent);

Parameters:
content: Component

amount

Getter

Gets the amount of Items in the ItemStack


script.zs

// IItemStack.amount as int
myIItemStack.amount

Return Type: int

anyDamage

anyDamage() as IIngredientConditioned<IIngredient>

script.zs

// IItemStack.anyDamage() as IngredientConditioned<IIngredient>;
myIItemStack.anyDamage();

Return Type: IngredientConditioned<IIngredient>

asIIngredientWithAmount

asIIngredientWithAmount() as IIngredientWithAmount

script.zs

// IItemStack.asIIngredientWithAmount() as IIngredientWithAmount;
myIItemStack.asIIngredientWithAmount();

Return Type: IIngredientWithAmount

implicit as IIngredientWithAmount

script.zs

// IItemStack as IIngredientWithAmount
myIItemStack as IIngredientWithAmount

Return Type: IIngredientWithAmount

asImmutable

asImmutable() as IItemStack

script.zs

// IItemStack.asImmutable() as IItemStack;
myIItemStack.asImmutable();

Return Type: IItemStack

asItemLike

asItemLike() as ItemLike

script.zs

// IItemStack.asItemLike() as ItemLike;
myIItemStack.asItemLike();

Return Type: ItemLike

implicit as ItemLike

script.zs

// IItemStack as ItemLike
myIItemStack as ItemLike

Return Type: ItemLike

asMapData

implicit as MapData

script.zs

// IItemStack as MapData
myIItemStack as MapData

Return Type: MapData

asMutable

asMutable() as IItemStack

script.zs

// IItemStack.asMutable() as IItemStack;
myIItemStack.asMutable();

Return Type: IItemStack

asWeightedItemStack

implicit as Percentaged<IItemStack>

script.zs

// IItemStack as Percentaged<IItemStack>
myIItemStack as Percentaged<IItemStack>

Return Type: Percentaged<IItemStack>

BASE_ATTACK_DAMAGE_UUID

Field

script.zs

// IItemStack.BASE_ATTACK_DAMAGE_UUID as UUID
IItemStack.BASE_ATTACK_DAMAGE_UUID

Return Type: UUID

BASE_ATTACK_SPEED_UUID

Field

script.zs

// IItemStack.BASE_ATTACK_SPEED_UUID as UUID
IItemStack.BASE_ATTACK_SPEED_UUID

Return Type: UUID

baseRepairCost

Getter

Gets the base repair cost of the ItemStack, or 0 if no repair is defined.


script.zs

// IItemStack.baseRepairCost as int
myIItemStack.baseRepairCost

Return Type: int

burnTime

Getter

script.zs

// IItemStack.burnTime as int
myIItemStack.burnTime

Return Type: int

Setter

Sets the burn time of this ingredient, for use in the furnace and other machines
script.zs

// IItemStack.burnTime = (time as int);


myIItemStack.burnTime = myInt;

Parameters:
time: int - the new burn time

burnTime(time as int)

Sets the burn time of this ingredient, for use in the furnace and other machines
script.zs

// IItemStack.burnTime(time as int);
myIItemStack.burnTime(500);

Parameters:
time: int - the new burn time

clearTooltip

clearTooltip(leaveName as bool = false)

script.zs

// IItemStack.clearTooltip(leaveName as bool = false);


myIItemStack.clearTooltip(myBool);

Parameters:
leaveName: bool (optional)
Default Value: false

contains

contains(ingredient as IIngredient) as bool

Does the ingredient contain the given ingredient?


script.zs

// IItemStack.contains(ingredient as IIngredient) as bool;


myIItemStack.contains((<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>));

Parameters:
ingredient: IIngredient - The ingredient to check

Return Type: bool

copy

copy() as IItemStack

Creates a copy
script.zs

// IItemStack.copy() as IItemStack;
myIItemStack.copy();

Return Type: IItemStack

CRAFTTWEAKER_DATA_KEY

Field

script.zs

// IItemStack.CRAFTTWEAKER_DATA_KEY as string
IItemStack.CRAFTTWEAKER_DATA_KEY

Return Type: string

damage

Getter

script.zs

// IItemStack.damage as int
myIItemStack.damage

Return Type: int

damageableItem

Getter

Returns if the ItemStack is damageable I.E Swords and tools are damageable, sticks are not.
script.zs

// IItemStack.damageableItem as bool
myIItemStack.damageableItem

Return Type: bool

damaged

Getter

Returns if the ItemStack is damaged I.E a Swords that is no at full durability is damaged.
script.zs

// IItemStack.damaged as bool
myIItemStack.damaged

Return Type: bool

definition

Getter

script.zs

// IItemStack.definition as ItemDefinition
myIItemStack.definition

Return Type: ItemDefinition

definition() as Item

script.zs

// IItemStack.definition() as ItemDefinition;
myIItemStack.definition();

Return Type: ItemDefinition

implicit as Item

script.zs

// IItemStack as ItemDefinition
myIItemStack as Item

Return Type: ItemDefinition

descriptionId

Getter

Returns the unlocalized Name of the Item in the ItemStack


script.zs

// IItemStack.descriptionId as string
myIItemStack.descriptionId

Return Type: string

displayName

Getter

Gets the display name of the ItemStack


script.zs

// IItemStack.displayName as Component
myIItemStack.displayName

Return Type: Component

enchantments

Getter

script.zs

// IItemStack.enchantments as Integer[Enchantment]
myIItemStack.enchantments

Return Type: Integer[Enchantment]

Setter

Sets the enchantments on this IItemStack.


script.zs

// IItemStack.enchantments = (enchantments as Integer[Enchantment]);


myIItemStack.enchantments = myMap;

Parameters:
enchantments: Integer[Enchantment] - The new enchantments

enchantments() as Integer[Enchantment]

script.zs

// IItemStack.enchantments() as Integer[Enchantment];
myIItemStack.enchantments();

Return Type: Integer[Enchantment]

enchantments(enchantments as Integer[Enchantment]) as IItemStack

Sets the enchantments on this IItemStack.


Returns: This itemStack if it is mutable, a new one with the enchantments otherwise

script.zs

// IItemStack.enchantments(enchantments as Integer[Enchantment]) as IItemStack;


myIItemStack.enchantments(myMap);

Parameters:
enchantments: Integer[Enchantment] - The new enchantments

Return Type: IItemStack

fireResistant

Getter

Checks if this IItemStack burns when thrown into fire / lava or damaged by fire.
script.zs

// IItemStack.fireResistant as bool
myIItemStack.fireResistant

Return Type: bool

Setter

Sets if this IItemStack is immune to fire / lava.


If true, the item will not burn when thrown into fire or lava.
script.zs

// IItemStack.fireResistant = (fireResistant as bool);


myIItemStack.fireResistant = myBool;

Parameters:
fireResistant: bool - Should the item be immune to fire.

fireResistant() as bool

Checks if this IItemStack burns when thrown into fire / lava or damaged by fire.
Returns: True if this IItemStack is immune to fire. False otherwise.

script.zs

// IItemStack.fireResistant() as bool;
myIItemStack.fireResistant();

Return Type: bool

fireResistant(fireResistant as bool)

Sets if this IItemStack is immune to fire / lava.


If true, the item will not burn when thrown into fire or lava.
script.zs

// IItemStack.fireResistant(fireResistant as bool);
myIItemStack.fireResistant(myBool);

Parameters:
fireResistant: bool - Should the item be immune to fire.

food

Getter

script.zs

// IItemStack.food as FoodProperties
myIItemStack.food

Return Type: FoodProperties

Setter

script.zs

// IItemStack.food = (food as FoodProperties);


myIItemStack.food = myFoodProperties;

Parameters:
food: FoodProperties

food() as FoodProperties

script.zs

// IItemStack.food() as FoodProperties;
myIItemStack.food();

Return Type: FoodProperties

food(food as FoodProperties)

script.zs

// IItemStack.food(food as FoodProperties);
myIItemStack.food(myFoodProperties);

Parameters:
food: FoodProperties

getAttributes

getAttributes(slotType as EquipmentSlot) as List<AttributeModifier>[Attribute]

Gets the Attributes and the AttributeModifiers on this IItemStack for the given EquipmentSlot
Returns: A Map of Attribute to a List of AttributeModifier for the given EquipmentSlot.

script.zs

// IItemStack.getAttributes(slotType as EquipmentSlot) as List<AttributeModifier>[Attrib


myIItemStack.getAttributes(<constant:minecraft:equipmentslot:chest>);

Parameters:
slotType: EquipmentSlot - The slot to get the Attributes for.
Return Type: List<AttributeModifier>[Attribute]

getEnchantmentLevel

getEnchantmentLevel(enchantment as Enchantment) as int

Gets the level of the given enchantment on the item. Returns 0 if the item doesn't have the given
enchantment.
script.zs

// IItemStack.getEnchantmentLevel(enchantment as Enchantment) as int;


myIItemStack.getEnchantmentLevel(myEnchantment);

Parameters:
enchantment: Enchantment
Return Type: int

getImmutableInternal

getImmutableInternal() as ItemStack

script.zs

// IItemStack.getImmutableInternal() as ItemStack;
myIItemStack.getImmutableInternal();

Return Type: ItemStack

getInternal

getInternal() as ItemStack

Gets the internal ItemStack for this IItemStack.


Returns: internal ItemStack

script.zs

// IItemStack.getInternal() as ItemStack;
myIItemStack.getInternal();

Return Type: ItemStack

implicit as ItemStack

Gets the internal ItemStack for this IItemStack.


script.zs

// IItemStack as ItemStack
myIItemStack as ItemStack

Return Type: ItemStack

getOrCreateTag

getOrCreateTag() as IData

Returns the NBT tag attached to this ItemStack or makes a new tag.
Returns: MapData of the ItemStack NBT Tag, empty tag if it doesn't exist.

script.zs

// IItemStack.getOrCreateTag() as IData;
myIItemStack.getOrCreateTag();

Return Type: IData

getRemainingItem

getRemainingItem(stack as IItemStack) as IItemStack

When this ingredient stack is crafted, what will remain in the grid? Does not check if the stack
matches though! Used e.g. in Crafting Table recipes.
script.zs

// IItemStack.getRemainingItem(stack as IItemStack) as IItemStack;


myIItemStack.getRemainingItem(<item:minecraft:iron_ingot>);

Parameters:
stack: IItemStack - The stack to provide for this ingredient.
Return Type: IItemStack

grow

grow(amount as int = 1) as IItemStack

Grows this IItemStack's stack size by the given amount, or 1 if no amount is given.
Returns: This IItemStack if mutable, a new one with the new amount otherwise.

script.zs

// IItemStack.grow(amount as int = 1) as IItemStack;


myIItemStack.grow(2);

Parameters:
amount: int (optional) - The amount to grow by.
Default Value: 1
Return Type: IItemStack

hasCustomHoverName

Getter

Returns true if the ItemStack has a display name.


script.zs

// IItemStack.hasCustomHoverName as bool
myIItemStack.hasCustomHoverName

Return Type: bool

hasFoil

Getter

Returns true if this ItemStack has a foil effect.


Foil is the glint / effect that is added to enchanted ItemStacks (and other items).
script.zs

// IItemStack.hasFoil as bool
myIItemStack.hasFoil

Return Type: bool

hasTag

Getter

Returns true if this ItemStack has a Tag


script.zs

// IItemStack.hasTag as bool
myIItemStack.hasTag

Return Type: bool

hoverName

Getter

Gets the hover name of the ItemStack.


This will give the raw name without the formatting that 'displayName' applies.

script.zs

// IItemStack.hoverName as Component
myIItemStack.hoverName

Return Type: Component

hoverName() as Component

Gets the hover name of the ItemStack.


This will give the raw name without the formatting that 'displayName' applies.

Returns: The hover name of the ItemStack.

script.zs

// IItemStack.hoverName() as Component;
myIItemStack.hoverName();

Return Type: Component

isEdible

Getter

script.zs

// IItemStack.isEdible as bool
myIItemStack.isEdible

Return Type: bool

isEdible() as bool

script.zs

// IItemStack.isEdible() as bool;
myIItemStack.isEdible();

Return Type: bool

isEnchantable

Getter

Can this ItemStack be enchanted?


script.zs

// IItemStack.isEnchantable as bool
myIItemStack.isEnchantable

Return Type: bool

isEnchanted

Getter

Is this ItemStack enchanted?


script.zs

// IItemStack.isEnchanted as bool
myIItemStack.isEnchanted

Return Type: bool

isImmutable

Getter

script.zs

// IItemStack.isImmutable as bool
myIItemStack.isImmutable

Return Type: bool

isImmutable() as bool

script.zs

// IItemStack.isImmutable() as bool;
myIItemStack.isImmutable();

Return Type: bool

isMutable

Getter

script.zs

// IItemStack.isMutable as bool
myIItemStack.isMutable

Return Type: bool

isMutable() as bool

script.zs

// IItemStack.isMutable() as bool;
myIItemStack.isMutable();

Return Type: bool

items

Getter

script.zs

// IItemStack.items as IItemStack[]
myIItemStack.items

Return Type: IItemStack[]

matches

matches(stack as IItemStack) as bool

Does the given stack match the ingredient?


script.zs

// IItemStack.matches(stack as IItemStack) as bool;


myIItemStack.matches(<item:minecraft:iron_ingot>);

Parameters:
stack: IItemStack - The stack to check

Return Type: bool

maxDamage

Getter

Returns the max damage of the ItemStack This is the max durability of the ItemStack.
script.zs

// IItemStack.maxDamage as int
myIItemStack.maxDamage

Return Type: int

Setter

Sets the max damage of the ItemStack.


Setting the damage to 0 will make the item unbreakable.
script.zs

// IItemStack.maxDamage = (newMaxDamage as int);


myIItemStack.maxDamage = myInt;

Parameters:
newMaxDamage: int - The new max damage of the ItemStack

maxStackSize

Getter

Returns the max stack size of the Item in the ItemStack


script.zs

// IItemStack.maxStackSize as int
myIItemStack.maxStackSize

Return Type: int

Setter

Sets the max stacksize of the Item.


script.zs

// IItemStack.maxStackSize = (newMaxStackSize as int);


myIItemStack.maxStackSize = myInt;

Parameters:
newMaxStackSize: int - The new max stack size of the Item.

maxStackSize() as int

Returns the max stack size of the Item in the ItemStack


Returns: Max stack size of the Item.

script.zs

// IItemStack.maxStackSize() as int;
myIItemStack.maxStackSize();

Return Type: int

maxStackSize(newMaxStackSize as int)

Sets the max stacksize of the Item.


script.zs

// IItemStack.maxStackSize(newMaxStackSize as int);
myIItemStack.maxStackSize(16);

Parameters:
newMaxStackSize: int - The new max stack size of the Item.

modifyShiftTooltip

modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction as


ITooltipFunction = null)

script.zs

// IItemStack.modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction


myIItemStack.modifyShiftTooltip(myITooltipFunction, myITooltipFunction);

Parameters:
shiftedFunction: ITooltipFunction
unshiftedFunction: ITooltipFunction (optional)
Default Value: null

modifyTooltip

modifyTooltip(function as ITooltipFunction)

script.zs

// IItemStack.modifyTooltip(function as ITooltipFunction);
myIItemStack.modifyTooltip(myITooltipFunction);

Parameters:
function: ITooltipFunction

mul

mul(amount as int) as IIngredientWithAmount

Use this in contexts where machines accept more than one item to state that fact.
script.zs

// IItemStack.mul(amount as int) as IIngredientWithAmount;


myIItemStack.mul(myInt);

Parameters:
amount: int
Return Type: IIngredientWithAmount

only

only(condition as IIngredientCondition<IIngredient>) as
IIngredientConditioned<IIngredient>

Use this if you already have the condition from another ingredient
script.zs

// IItemStack.only(condition as IIngredientCondition<IIngredient>) as IngredientConditio


myIItemStack.only(myIIngredientCondition);

Parameters:
condition: IIngredientCondition<IIngredient>
Return Type: IngredientConditioned<IIngredient>

onlyDamaged

onlyDamaged() as IIngredientConditioned<IIngredient>

script.zs

// IItemStack.onlyDamaged() as IngredientConditioned<IIngredient>;
myIItemStack.onlyDamaged();

Return Type: IngredientConditioned<IIngredient>

onlyDamagedAtLeast

onlyDamagedAtLeast(minDamage as int) as IIngredientConditioned<IIngredient>

script.zs

// IItemStack.onlyDamagedAtLeast(minDamage as int) as IngredientConditioned<IIngredient>


myIItemStack.onlyDamagedAtLeast(myInt);

Parameters:
minDamage: int

Return Type: IngredientConditioned<IIngredient>

onlyDamagedAtMost

onlyDamagedAtMost(maxDamage as int) as IIngredientConditioned<IIngredient>

script.zs

// IItemStack.onlyDamagedAtMost(maxDamage as int) as IngredientConditioned<IIngredient>;


myIItemStack.onlyDamagedAtMost(myInt);

Parameters:
maxDamage: int
Return Type: IngredientConditioned<IIngredient>

onlyIf

onlyIf(uid as string, function as function(t as IItemStack) as bool = null) as


IIngredientConditioned<IIngredient>

script.zs

// IItemStack.onlyIf(uid as string, function as function(t as IItemStack) as bool = null


myIItemStack.onlyIf(myString, myPredicate);

Parameters:
uid: string
function: function(t as IItemStack) as bool (optional)
Default Value: null
Return Type: IngredientConditioned<IIngredient>

owner

Getter

Gets owning mod for the Item in this IItemStack


script.zs

// IItemStack.owner as string
myIItemStack.owner

Return Type: string

percent

percent(percentage as double) as Percentaged<IItemStack>

script.zs

// IItemStack.percent(percentage as double) as Percentaged<IItemStack>;


myIItemStack.percent(myDouble);

Parameters:
percentage: double

Return Type: Percentaged<IItemStack>

rarity

Getter

Returns the rarity of the Item in the ItemStack


script.zs

// IItemStack.rarity as Rarity
myIItemStack.rarity

Return Type: Rarity

Setter

Sets the rarity of the Item.


script.zs

// IItemStack.rarity = (newRarity as Rarity);


myIItemStack.rarity = myRarity;

Parameters:
newRarity: Rarity - The new rarity of the Item.

rarity() as Rarity

Returns the rarity of the Item in the ItemStack


Returns: Rarity of the Item.

script.zs

// IItemStack.rarity() as Rarity;
myIItemStack.rarity();

Return Type: Rarity

rarity(newRarity as Rarity)

Sets the rarity of the Item.


script.zs

// IItemStack.rarity(newRarity as Rarity);
myIItemStack.rarity(Rarity.UNCOMMON);

Parameters:
newRarity: Rarity - The new rarity of the Item.

registryName

Getter

Gets the registry name for the Item in this IItemStack


script.zs

// IItemStack.registryName as ResourceLocation
myIItemStack.registryName

Return Type: ResourceLocation

removeEnchantment

removeEnchantment(enchantment as Enchantment) as IItemStack

Removes the given enchantment from this IItemStack.


Returns: This itemStack if it is mutable, a new one with the enchantment removed otherwise

script.zs

// IItemStack.removeEnchantment(enchantment as Enchantment) as IItemStack;


myIItemStack.removeEnchantment(<enchantment:minecraft:riptide>);

Parameters:
enchantment: Enchantment - The enchantment to remove.

Return Type: IItemStack

removeGlobalAttribute

removeGlobalAttribute(attribute as Attribute, slotTypes as EquipmentSlot[])

Removes all AttributeModifiers that use the given Attribute from this IIngredient.
Attributes removed with this method are removed from ItemStacks that match this IIngredient,
regardless of how or when the ItemStack was made, if you want to remove the attribute on a single
specific ItemStack (such as a specific Diamond Sword made in a recipe), then you should use
IItemStack#withoutAttribute.
This method can only remove default Attributes from an ItemStack, it is still possible that an
ItemStack can override it.
script.zs

// IItemStack.removeGlobalAttribute(attribute as Attribute, slotTypes as EquipmentSlot[]


myIItemStack.removeGlobalAttribute(<attribute:minecraft:generic.attack_damage>, [<consta

Parameters:
attribute: Attribute - The attribute to remove.

slotTypes: EquipmentSlot[] - The slot types to remove it from.

removeGlobalAttributeModifier

removeGlobalAttributeModifier(uuid as string, slotTypes as EquipmentSlot[])

Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.
script.zs

// IItemStack.removeGlobalAttributeModifier(uuid as string, slotTypes as EquipmentSlot[]


myIItemStack.removeGlobalAttributeModifier("8c1b5535-9f79-448b-87ae-52d81480aaa3", [<con

Parameters:
uuid: string - The unique id of the AttributeModifier to remove.
slotTypes: EquipmentSlot[] - The slot types to remove it from.

removeGlobalAttributeModifier(uuid as UUID, slotTypes as EquipmentSlot[])

Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.
script.zs

// IItemStack.removeGlobalAttributeModifier(uuid as UUID, slotTypes as EquipmentSlot[]);


myIItemStack.removeGlobalAttributeModifier(IItemStack.BASE_ATTACK_DAMAGE_UUID, [<constan

Parameters:
uuid: UUID - The unique id of the AttributeModifier to remove.
slotTypes: EquipmentSlot[] - The slot types to remove it from.

removeTooltip

removeTooltip(regex as string)

script.zs

// IItemStack.removeTooltip(regex as string);
myIItemStack.removeTooltip(myString);

Parameters:
regex: string

resetHoverName

resetHoverName()

Clears any custom name set for this ItemStack


script.zs

// IItemStack.resetHoverName();
myIItemStack.resetHoverName();

reuse

reuse() as IIngredientTransformed<IIngredient>

script.zs

// IItemStack.reuse() as IIngredientTransformed<IIngredient>;
myIItemStack.reuse();

Return Type: IIngredientTransformed<IIngredient>

shrink

shrink(amount as int = 1) as IItemStack

Shrinks this IItemStack's stack size by the given amount, or 1 if no amount is given.
Returns: This IItemStack if mutable, a new one with the new amount otherwise.

script.zs

// IItemStack.shrink(amount as int = 1) as IItemStack;


myIItemStack.shrink(2);

Parameters:
amount: int (optional) - The amount to shrink by.
Default Value: 1
Return Type: IItemStack

stackable

Getter

Returns if the ItemStack can have an amount greater than 1 I.E Swords and tools are not stackable,
sticks are.
script.zs

// IItemStack.stackable as bool
myIItemStack.stackable

Return Type: bool

tag

Getter

Returns the NBT tag attached to this ItemStack.


script.zs

// IItemStack.tag as IData
myIItemStack.tag

Return Type: IData

transform

transform(transformer as IIngredientTransformer<IIngredient>) as
IIngredientTransformed<IIngredient>

Use this if you already have the transformer from another ingredient
script.zs

// IItemStack.transform(transformer as IIngredientTransformer<IIngredient>) as IIngredie


myIItemStack.transform(myIIngredientTransformer);

Parameters:
transformer: IIngredientTransformer<IIngredient>

Return Type: IIngredientTransformed<IIngredient>

transformCustom

transformCustom(uid as string, function as function(r as IItemStack) as IItemStack =


null) as IIngredientTransformed<IIngredient>

script.zs

// IItemStack.transformCustom(uid as string, function as function(r as IItemStack) as II


myIItemStack.transformCustom(myString, myFunction);

Parameters:
uid: string
function: function(r as IItemStack) as IItemStack (optional)
Default Value: null
Return Type: IIngredientTransformed<IIngredient>

transformDamage

transformDamage(amount as int = 1) as IIngredientTransformed<IIngredient>

script.zs

// IItemStack.transformDamage(amount as int = 1) as IIngredientTransformed<IIngredient>;


myIItemStack.transformDamage(myInt);

Parameters:
amount: int (optional)
Default Value: 1
Return Type: IIngredientTransformed<IIngredient>

transformReplace

transformReplace(replaceWith as IItemStack) as IIngredientTransformed<IIngredient>

script.zs

// IItemStack.transformReplace(replaceWith as IItemStack) as IIngredientTransformed<IIng


myIItemStack.transformReplace(myIItemStack);

Parameters:
replaceWith: IItemStack

Return Type: IIngredientTransformed<IIngredient>

useDuration

Getter

Gets the use duration of the ItemStack


script.zs

// IItemStack.useDuration as int
myIItemStack.useDuration

Return Type: int

useOnRelease

Getter

Returns true if this stack is considered a crossbow item


script.zs

// IItemStack.useOnRelease as bool
myIItemStack.useOnRelease

Return Type: bool

withAttributeModifier

withAttributeModifier(attribute as Attribute, uuid as string, name as string, value as


double, operation as Operation, slotTypes as EquipmentSlot[], preserveDefaults as bool =
false) as IItemStack

Adds an AttributeModifier to this IItemStack using a specific UUID.


The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You
can use /ct hand attributes to get the UUID of the attributes on an ItemStack.
Attributes added with this method will only appear on this specific IItemStack.
By defaults, adding a modifier will remove the default Attribute Modifiers on the Item, like the
Diamond Chestplate's Armor and Toughness values. When preserveDefaults is set to true (by
default it is false.), the default Attribute Modifiers will be preserved when adding this modifier. This
means that if you were adding the forge:nametag_distance attribute to an Item, it would keep its
default attributes (like Armor and Toughness values).
script.zs

// IItemStack.withAttributeModifier(attribute as Attribute, uuid as string, name as stri


myIItemStack.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b553

Parameters:
attribute: Attribute - The Attribute of the modifier.

uuid: string - The unique identifier of the modifier to replace.

name: string - The name of the modifier.


value: double - The value of the modifier.

operation: AttributeOperation - The operation of the modifier.

slotTypes: EquipmentSlot[] - What slots the modifier is valid for.


preserveDefaults: bool (optional) - Should the default Item Attribute Modifiers be preserved
when adding this modifier.
Default Value: false
Return Type: IItemStack

withAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value as


double, operation as Operation, slotTypes as EquipmentSlot[], preserveDefaults as bool =
false) as IItemStack

Adds an AttributeModifier to this IItemStack using a specific UUID.


The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You
can use /ct hand attributes to get the UUID of the attributes on an ItemStack.
Attributes added with this method will only appear on this specific IItemStack.
By defaults, adding a modifier will remove the default Attribute Modifiers on the Item, like the
Diamond Chestplate's Armor and Toughness values. When preserveDefaults is set to true (by
default it is false.), the default Attribute Modifiers will be preserved when adding this modifier. This
means that if you were adding the forge:nametag_distance attribute to an Item, it would keep its
default attributes (like Armor and Toughness values).
script.zs

// IItemStack.withAttributeModifier(attribute as Attribute, uuid as UUID, name as string


myIItemStack.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b553

Parameters:
attribute: Attribute - The Attribute of the modifier.

uuid: UUID - The unique identifier of the modifier to replace.

name: string - The name of the modifier.


value: double - The value of the modifier.

operation: AttributeOperation - The operation of the modifier.

slotTypes: EquipmentSlot[] - What slots the modifier is valid for.


preserveDefaults: bool (optional) - Should the default Item Attribute Modifiers be preserved
when adding this modifier.
Default Value: false
Return Type: IItemStack

withAttributeModifier(attribute as Attribute, name as string, value as double, operation


as Operation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as
IItemStack

Adds an AttributeModifier to this IItemStack.


The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You
can use /ct hand attributes to get the UUID of the attributes on an ItemStack.
Attributes added with this method will only appear on this specific IItemStack.
By defaults, adding a modifier will remove the default Attribute Modifiers on the Item, like the
Diamond Chestplate's Armor and Toughness values. When preserveDefaults is set to true (by
default it is false.), the default Attribute Modifiers will be preserved when adding this modifier. This
means that if you were adding the forge:nametag_distance attribute to an Item, it would keep its
default attributes (like Armor and Toughness values).
script.zs

// IItemStack.withAttributeModifier(attribute as Attribute, name as string, value as dou


myIItemStack.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Extra P

Parameters:
attribute: Attribute - The Attribute of the modifier.
name: string - The name of the modifier.

value: double - The value of the modifier.

operation: AttributeOperation - The operation of the modifier.


slotTypes: EquipmentSlot[] - What slots the modifier is valid for.

preserveDefaults: bool (optional) - Should the default Item Attribute Modifiers be preserved
when adding this modifier.
Default Value: false
Return Type: IItemStack

withDamage

withDamage(damage as int) as IItemStack

Sets the damage of the ItemStack


script.zs

// IItemStack.withDamage(damage as int) as IItemStack;


myIItemStack.withDamage(10);

Parameters:
damage: int - the new damage value

Return Type: IItemStack

withDisplayName

withDisplayName(name as Component) as IItemStack

Sets the display name of the ItemStack


script.zs

// IItemStack.withDisplayName(name as Component) as IItemStack;


myIItemStack.withDisplayName("totally not dirt");

Parameters:
name: Component - New name of the stack.

Return Type: IItemStack

withEnchantment

withEnchantment(enchantment as Enchantment, level as int = 1) as IItemStack

Enchants this IItemStack with the given Enchantment.


Returns: This itemStack if it is mutable, a new one with the enchantment added otherwise

script.zs

// IItemStack.withEnchantment(enchantment as Enchantment, level as int = 1) as IItemStac


myIItemStack.withEnchantment(<enchantment:minecraft:riptide>, 2);

Parameters:
enchantment: Enchantment - The enchantment to add.
level: int (optional) - The level of the enchantment
Default Value: 1
Return Type: IItemStack

withLore

withLore(lore as Component[]) as IItemStack

Sets the lore of the ItemStack


script.zs

// IItemStack.withLore(lore as Component[]) as IItemStack;


myIItemStack.withLore(new crafttweaker.api.text.TextComponent("I am the lore I speak for

Parameters:
lore: Component[] - the new Lore of the ItemStack.
Return Type: IItemStack

withoutTag

withoutTag() as IItemStack

Removes the tag from this ItemStack.


Returns: This itemStack if it is mutable, a new one with the changed property otherwise

script.zs

// IItemStack.withoutTag() as IItemStack;
myIItemStack.withoutTag();

Return Type: IItemStack

withTag

withTag(tag as MapData) as IItemStack

Sets the tag for the ItemStack.


Returns: This itemStack if it is mutable, a new one with the changed property otherwise

script.zs

// IItemStack.withTag(tag as MapData) as IItemStack;


myIItemStack.withTag({Display: {lore: ["Hello"]}});

Parameters:
tag: MapData - The tag to set.

Return Type: IItemStack

Previous Equipable Ingredient Next

You might also like