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

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();

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();

getDefinition

Return Type: MCItemDefinition

ZenScript
Copy
IItemStack.getDefinition() as MCItemDefinition
<item:minecraft:dirt>.getDefinition();

getInternal

Gets the internal ItemStack for this IItemStack.

Return Type: ItemStack

ZenScript
Copy
IItemStack.getInternal() as ItemStack
<item:minecraft:dirt>.getInternal();

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();

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

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

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.

weight

Return Type: MCWeightedItemStack

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

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.

Return Type: IItemStack

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

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 Setter
amountinttruefalse
burnTimeinttruetrue
commandStringstringtruefalse
damageinttruefalse
damageablebooleantruefalse
damagedbooleantruefalse
definitionMCItemDefinitiontruefalse
displayNamestringtruefalse
emptybooleantruefalse
foodMCFood?truetrue
getOrCreateIDatatruefalse
getRepairCostinttruefalse
hasDisplayNamebooleantruefalse
hasEffectbooleantruefalse
hasTagbooleantruefalse
isCrossbowbooleantruefalse
isEnchantablebooleantruefalse
isEnchantedbooleantruefalse
itemsIItemStack[]truefalse
maxDamageinttruefalse
maxStackSizeinttruefalse
ownerstringtruefalse
registryNameMCResourceLocationtruefalse
stackablebooleantruefalse
tagIDatatruefalse
translationKeystringtruefalse
useDurationinttruefalse