IItemStack

This represents an item. It can be retrieved using an Item BEP. Is an IIngredient

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.item.IItemStack;

Implemented Interfaces

IItemStack implements the following interfaces. That means all methods defined in these interfaces are also available in IItemStack

Casters

Methods

addGlobalAttributeModifier

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

Return Type: void

ZenScript
Copy
// IItemStack.addGlobalAttributeModifier(attribute as Attribute, name as string, value as double, operation as AttributeOperation, slotTypes as MCEquipmentSlotType[]) as void

<item:minecraft:dirt>.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Extra Power", 10, AttributeOperation.ADDITION, [<equipmentslottype:chest>]);
ParameterTypeDescription
attributeAttributeThe Attribute of the modifier.
namestringThe name of the modifier.
valuedoubleThe value of the modifier.
operationAttributeOperationThe operation of the modifier.
slotTypesMCEquipmentSlotType[]What slots the modifier is valid for.
addGlobalAttributeModifier

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

Return Type: void

ZenScript
Copy
// IItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as AttributeOperation, slotTypes as MCEquipmentSlotType[]) as void

<item:minecraft:dirt>.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION, [<equipmentslottype:chest>]);
ParameterTypeDescription
attributeAttributeThe Attribute of the modifier.
uuidstringThe unique identifier of the modifier to replace.
namestringThe name of the modifier.
valuedoubleThe value of the modifier.
operationAttributeOperationThe operation of the modifier.
slotTypesMCEquipmentSlotType[]What slots the modifier is valid for.
addShiftTooltip

Return Type: void

ZenScript
Copy
IItemStack.addShiftTooltip(content as MCTextComponent, showMessage as MCTextComponent) as void
ParameterTypeDescriptionOptionalDefaultValue
contentMCTextComponentNo Description Providedfalse
showMessageMCTextComponentNo Description Providedtrue
addTooltip

Return Type: void

ZenScript
Copy
IItemStack.addTooltip(content as MCTextComponent) as void
ParameterTypeDescription
contentMCTextComponentNo Description Provided
anyDamage

Return Type: MCIngredientConditioned<IIngredient>

ZenScript
Copy
// IItemStack.anyDamage() as MCIngredientConditioned<IIngredient>

<item:minecraft:dirt>.anyDamage();
asIIngredientWithAmount

Return Type: IIngredientWithAmount

ZenScript
Copy
// IItemStack.asIIngredientWithAmount() as IIngredientWithAmount

<item:minecraft:dirt>.asIIngredientWithAmount();
asImmutable

Return Type: IItemStack

ZenScript
Copy
// IItemStack.asImmutable() as IItemStack

<item:minecraft:dirt>.asImmutable();
asVanillaIngredient

Create a Vanilla ingredient matching this one.

Return Type: Ingredient

ZenScript
Copy
// IItemStack.asVanillaIngredient() as Ingredient

<item:minecraft:dirt>.asVanillaIngredient();
clearCustomName

Clears any custom name set for this ItemStack

Return Type: void

ZenScript
Copy
// IItemStack.clearCustomName() as void

<item:minecraft:dirt>.clearCustomName();
clearTooltip

Return Type: void

ZenScript
Copy
// IItemStack.clearTooltip() as void

<item:minecraft:dirt>.clearTooltip();
contains

Does the ingredient contain the given ingredient?

Return Type: boolean

ZenScript
Copy
// IItemStack.contains(ingredient as IIngredient) as boolean

<item:minecraft:dirt>.contains((<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>));
ParameterTypeDescription
ingredientIIngredientThe ingredient to check
copy

Creates a copy

Return Type: IItemStack

ZenScript
Copy
// IItemStack.copy() as IItemStack

<item:minecraft:dirt>.copy();
getAttributes

Gets the Attributes and the AttributeModifiers on this IItemStack for the given EquipmentSlotType

Returns: A Map of Attribute to a List of AttributeModifier for the given EquipmentSlotType.
Return Type: stdlib.List<AttributeModifier>[Attribute]

ZenScript
Copy
// IItemStack.getAttributes(slotType as MCEquipmentSlotType) as stdlib.List<AttributeModifier>[Attribute]

<item:minecraft:dirt>.getAttributes(<equipmentslottype:chest>);
ParameterTypeDescription
slotTypeMCEquipmentSlotTypeThe slot to get the Attributes for.
getDefinition

Return Type: MCItemDefinition

ZenScript
Copy
// IItemStack.getDefinition() as MCItemDefinition

<item:minecraft:dirt>.getDefinition();
getEnchantmentLevel

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

Return Type: int

ZenScript
Copy
IItemStack.getEnchantmentLevel(enchantment as MCEnchantment) as int
ParameterTypeDescription
enchantmentMCEnchantmentNo Description Provided
getImmutableInternal

Return Type: ItemStack

ZenScript
Copy
// IItemStack.getImmutableInternal() as ItemStack

<item:minecraft:dirt>.getImmutableInternal();
getInternal

Gets the internal ItemStack for this IItemStack.

Returns: internal ItemStack
Return Type: ItemStack

ZenScript
Copy
// IItemStack.getInternal() as ItemStack

<item:minecraft:dirt>.getInternal();
getMaxStackSize

Returns the max stack size of the Item in the ItemStack

Returns: Max stack size of the Item.
Return Type: int

ZenScript
Copy
// IItemStack.getMaxStackSize() as int

<item:minecraft:dirt>.getMaxStackSize();
getRarity

Returns the rarity of the Item in the ItemStack

Returns: Rarity of the Item.
Return Type: Rarity

ZenScript
Copy
// IItemStack.getRarity() as Rarity

<item:minecraft:dirt>.getRarity();
getRemainingItem

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.

Return Type: IItemStack

ZenScript
Copy
// IItemStack.getRemainingItem(stack as IItemStack) as IItemStack

<item:minecraft:dirt>.getRemainingItem(<item:minecraft:iron_ingot>);
ParameterTypeDescription
stackIItemStackThe stack to provide for this ingredient.
isFood

Return Type: boolean

ZenScript
Copy
// IItemStack.isFood() as boolean

<item:minecraft:dirt>.isFood();
isImmuneToFire

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.
Return Type: boolean

ZenScript
Copy
// IItemStack.isImmuneToFire() as boolean

<item:minecraft:dirt>.isImmuneToFire();
isImmutable

Return Type: boolean

ZenScript
Copy
// IItemStack.isImmutable() as boolean

<item:minecraft:dirt>.isImmutable();
matches

Does the given stack match the ingredient?

Return Type: boolean

ZenScript
Copy
// IItemStack.matches(stack as IItemStack) as boolean

<item:minecraft:dirt>.matches(<item:minecraft:iron_ingot>);
ParameterTypeDescription
stackIItemStackThe stack to check
modifyShiftTooltip

Return Type: void

ZenScript
Copy
IItemStack.modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction as ITooltipFunction) as void
ParameterTypeDescriptionOptionalDefaultValue
shiftedFunctionITooltipFunctionNo Description Providedfalse
unshiftedFunctionITooltipFunctionNo Description Providedtrue
modifyTooltip

Return Type: void

ZenScript
Copy
IItemStack.modifyTooltip(function as ITooltipFunction) as void
ParameterTypeDescription
functionITooltipFunctionNo Description Provided
mutable

Return Type: IItemStack

ZenScript
Copy
// IItemStack.mutable() as IItemStack

<item:minecraft:dirt>.mutable();
only

Use this if you already have the condition from another ingredient

Return Type: MCIngredientConditioned<IIngredient>

ZenScript
Copy
IItemStack.only(condition as IIngredientCondition<IIngredient>) as MCIngredientConditioned<IIngredient>
ParameterTypeDescription
conditionIIngredientCondition<IIngredient>No Description Provided
onlyDamaged

Return Type: MCIngredientConditioned<IIngredient>

ZenScript
Copy
// IItemStack.onlyDamaged() as MCIngredientConditioned<IIngredient>

<item:minecraft:dirt>.onlyDamaged();
onlyIf

Return Type: MCIngredientConditioned<IIngredient>

ZenScript
Copy
IItemStack.onlyIf(uid as string, function as Predicate<IItemStack>) as MCIngredientConditioned<IIngredient>
ParameterTypeDescriptionOptionalDefaultValue
uidstringNo Description Providedfalse
functionPredicate<IItemStack>No Description Providedtrue
removeGlobalAttribute

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.

Return Type: void

ZenScript
Copy
// IItemStack.removeGlobalAttribute(attribute as Attribute, slotTypes as MCEquipmentSlotType[]) as void

<item:minecraft:dirt>.removeGlobalAttribute(<attribute:minecraft:generic.attack_damage>, [<equipmentslottype:chest>]);
ParameterTypeDescription
attributeAttributeThe attribute to remove.
slotTypesMCEquipmentSlotType[]The slot types to remove it from.
removeGlobalAttributeModifier

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

Return Type: void

ZenScript
Copy
// IItemStack.removeGlobalAttributeModifier(uuid as string, slotTypes as MCEquipmentSlotType[]) as void

<item:minecraft:dirt>.removeGlobalAttributeModifier("8c1b5535-9f79-448b-87ae-52d81480aaa3", [<equipmentslottype:chest>]);
ParameterTypeDescription
uuidstringThe unique id of the AttributeModifier to remove.
slotTypesMCEquipmentSlotType[]The slot types to remove it from.
removeTooltip

Return Type: void

ZenScript
Copy
IItemStack.removeTooltip(regex as string) as void
ParameterTypeDescription
regexstringNo Description Provided
setDisplayName

Sets the display name of the ItemStack

Return Type: IItemStack

ZenScript
Copy
// IItemStack.setDisplayName(name as string) as IItemStack

<item:minecraft:dirt>.setDisplayName("totally not dirt");
ParameterTypeDescription
namestringNew name of the stack.
setImmuneToFire

Sets if this IItemStack is immune to fire / lava.

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

Return Type: void

ZenScript
Copy
// IItemStack.setImmuneToFire(immuneToFire as boolean) as void

<item:minecraft:dirt>.setImmuneToFire(true);
ParameterTypeDescription
immuneToFirebooleanShould the item be immune to fire.
setMaxStackSize

Sets the max stacksize of the Item.

Return Type: void

ZenScript
Copy
// IItemStack.setMaxStackSize(newMaxStackSize as int) as void

<item:minecraft:dirt>.setMaxStackSize(16);
ParameterTypeDescription
newMaxStackSizeintThe new max stack size of the Item.
setRarity

Sets the rarity of the Item.

Return Type: void

ZenScript
Copy
// IItemStack.setRarity(newRarity as Rarity) as void

<item:minecraft:dirt>.setRarity(Rarity.UNCOMMON);
ParameterTypeDescription
newRarityRarityThe new rarity of the Item.
weight

Return Type: MCWeightedItemStack

ZenScript
Copy
IItemStack.weight(weight as double) as MCWeightedItemStack
ParameterTypeDescription
weightdoubleNo Description Provided
withAttributeModifier

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.

Return Type: IItemStack

ZenScript
Copy
// IItemStack.withAttributeModifier(attribute as Attribute, name as string, value as double, operation as AttributeOperation, slotTypes as MCEquipmentSlotType[]) as IItemStack

<item:minecraft:dirt>.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Extra Power", 10, AttributeOperation.ADDITION, [<equipmentslottype:chest>]);
ParameterTypeDescription
attributeAttributeThe Attribute of the modifier.
namestringThe name of the modifier.
valuedoubleThe value of the modifier.
operationAttributeOperationThe operation of the modifier.
slotTypesMCEquipmentSlotType[]What slots the modifier is valid for.
withAttributeModifier

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.

Return Type: IItemStack

ZenScript
Copy
// IItemStack.withAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as AttributeOperation, slotTypes as MCEquipmentSlotType[]) as IItemStack

<item:minecraft:dirt>.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION, [<equipmentslottype:chest>]);
ParameterTypeDescription
attributeAttributeThe Attribute of the modifier.
uuidstringThe unique identifier of the modifier to replace.
namestringThe name of the modifier.
valuedoubleThe value of the modifier.
operationAttributeOperationThe operation of the modifier.
slotTypesMCEquipmentSlotType[]What slots the modifier is valid for.
withDamage

Sets the damage of the ItemStack

Return Type: IItemStack

ZenScript
Copy
// IItemStack.withDamage(damage as int) as IItemStack

<item:minecraft:dirt>.withDamage(10);
ParameterTypeDescription
damageintthe new damage value
withTag

Sets the tag for the ItemStack.

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

ZenScript
Copy
// IItemStack.withTag(tag as IData) as IItemStack

<item:minecraft:dirt>.withTag({Display: {lore: ["Hello"]}});
ParameterTypeDescription
tagIDataThe tag to set.
withoutTag

Removes the tag from this ItemStack.

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

ZenScript
Copy
// IItemStack.withoutTag() as IItemStack

<item:minecraft:dirt>.withoutTag();

Operators

CONTAINS

Does the ingredient contain the given ingredient?

ZenScript
Copy
ingredient as IIngredient in myIItemStack
(<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>) in <item:minecraft:dirt>
MOD
ZenScript
Copy
myIItemStack % percentage as int
MUL

Sets the amount of the ItemStack

ZenScript
Copy
myIItemStack * amount as int
<item:minecraft:dirt> * 3
OR
ZenScript
Copy
myIItemStack | other as IIngredient

Properties

NameTypeHas GetterHas SetterDescription
amountinttruefalseGets the amount of Items in the ItemStack
burnTimeinttruetrueNo Description Provided
commandStringstringtruefalseReturns the BEP to get this stack
damageinttruefalseNo Description Provided
damageablebooleantruefalseReturns if the ItemStack is damageable
I.E Swords and tools are damageable, sticks are not.
damagedbooleantruefalseReturns if the ItemStack is damaged
I.E a Swords that is no at full durability is damaged.
definitionMCItemDefinitiontruefalseNo Description Provided
displayNamestringtruefalseGets the display name of the ItemStack
emptybooleantruefalseReturns if the ItemStack is empty
enchantmentsInteger[MCEnchantment]truefalseNo Description Provided
foodMCFood?truetrueNo Description Provided
getOrCreateIDatatruefalseReturns the NBT tag attached to this ItemStack or makes a new tag.
getRepairCostinttruefalseGets the repair cost of the ItemStack, or 0 if no repair is defined.
hasDisplayNamebooleantruefalseReturns true if the ItemStack has a display name.
hasEffectbooleantruefalseReturns true if this ItemStack has an effect.
hasTagbooleantruefalseReturns true if this ItemStack has a Tag
immuneToFirevoidtruetrueSets if this IItemStack is immune to fire / lava.

If true, the item will not burn when thrown into fire or lava.
isCrossbowbooleantruefalseReturns true if this stack is considered a crossbow item
isEnchantablebooleantruefalseCan this ItemStack be enchanted?
isEnchantedbooleantruefalseIs this ItemStack enchanted?
isImmutablebooleantruefalseNo Description Provided
itemsIItemStack[]truefalseNo Description Provided
maxDamageinttruetrueReturns the max damage of the ItemStack
This is the max durability of the ItemStack.
maxStackSizeinttruetrueReturns the max stack size of the Item in the ItemStack
ownerstringtruefalseGets owning mod for the Item in this IItemStack
rarityRaritytruetrueReturns the rarity of the Item in the ItemStack
registryNameMCResourceLocationtruefalseGets the registry name for the Item in this IItemStack
stackablebooleantruefalseReturns if the ItemStack can have an amount greater than 1
I.E Swords and tools are not stackable, sticks are.
tagIDatatruefalseReturns the NBT tag attached to this ItemStack.
toolTypesToolType[]truefalseNo Description Provided
translationKeystringtruefalseReturns the unlocalized Name of the Item in the ItemStack
useDurationinttruefalseGets the use duration of the ItemStack