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.

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

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

addTooltip

Return Type: void

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

anyDamage

Return Type: MCIngredientConditioned<IIngredient>

IItemStack.anyDamage() as MCIngredientConditioned<IIngredient>
<item:minecraft:dirt>.anyDamage();

asIIngredientWithAmount

Return Type: IIngredientWithAmount

IItemStack.asIIngredientWithAmount() as IIngredientWithAmount
<item:minecraft:dirt>.asIIngredientWithAmount();

asVanillaIngredient

Create a Vanilla ingredient matching this one.

Return Type: Ingredient

IItemStack.asVanillaIngredient() as Ingredient
<item:minecraft:dirt>.asVanillaIngredient();

clearCustomName

Clears any custom name set for this ItemStack

Return Type: void

IItemStack.clearCustomName() as void
<item:minecraft:dirt>.clearCustomName();

clearTooltip

Return Type: void

IItemStack.clearTooltip() as void
<item:minecraft:dirt>.clearTooltip();

contains

Does the ingredient contain the given ingredient?

Return Type: boolean

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

IItemStack.copy() as IItemStack
<item:minecraft:dirt>.copy();

getDefinition

Return Type: MCItemDefinition

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

getInternal

Gets the internal ItemStack for this IItemStack.

Return Type: ItemStack

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

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

IItemStack.isFood() as boolean
<item:minecraft:dirt>.isFood();

matches

Does the given stack match the ingredient?

Return Type: boolean

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

modifyTooltip

Return Type: void

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

mutable

Return Type: IItemStack

IItemStack.mutable() as IItemStack
<item:minecraft:dirt>.mutable();

only

Use this if you already have the condition from another ingredient

Return Type: MCIngredientConditioned<IIngredient>

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

onlyDamaged

Return Type: MCIngredientConditioned<IIngredient>

IItemStack.onlyDamaged() as MCIngredientConditioned<IIngredient>
<item:minecraft:dirt>.onlyDamaged();

onlyIf

Return Type: MCIngredientConditioned<IIngredient>

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

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

setDisplayName

Sets the display name of the ItemStack

Return Type: IItemStack

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

weight

Return Type: MCWeightedItemStack

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

withDamage

Sets the damage of the ItemStack

Return Type: IItemStack

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

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?

ingredient as IIngredient in myIItemStack
(<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>) in <item:minecraft:dirt>

MOD

myIItemStack % percentage as int

MUL

Sets the amount of the ItemStack

myIItemStack * amount as int
<item:minecraft:dirt> * 3

OR

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