Home Commands Examples Getting Started With Scripts Global Keywords
IIngredient IIngredientWithAmount
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

IIngredient

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.

script.zs
import crafttweaker.api.ingredient.IIngredient;

Description

The CraftTweaker Ingredient class which is used to power our recipes and ItemStack matching.

Implements

IIngredient implements the following interfaces:

CommandStringDisplayable

Operators

in(ingredient as IIngredient) as bool
Does the ingredient contain the given ingredient?
script.zs
// ((ingredient as IIngredient) in IIngredient) as bool
myIIngredient in myIIngredient

Parameters:

ingredient Type: 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
// (IIngredient * (amount as int)) as IIngredientWithAmount
myIIngredient * myInt

Parameters:

amount Type: int

Return Type: IIngredientWithAmount

|(other as IIngredient) as IIngredientList
script.zs
// (IIngredient | (other as IIngredient)) as IIngredientList
myIIngredient | myIIngredient

Parameters:

other Type: IIngredient

Return Type: IIngredientList

Members

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
// IIngredient.addGlobalAttributeModifier(attribute as Attribute, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[]);
myIIngredient.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>]);

Parameters:

attribute Type: Attribute - The Attribute of the modifier.
name Type: string - The name of the modifier.
value Type: double - The value of the modifier.
operation Type: AttributeOperation - The operation of the modifier.
slotTypes Type: 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
// IIngredient.addGlobalAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[]);
myIIngredient.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>]);

Parameters:

attribute Type: Attribute - The Attribute of the modifier.
uuid Type: string - The unique identifier of the modifier to replace.
name Type: string - The name of the modifier.
value Type: double - The value of the modifier.
operation Type: AttributeOperation - The operation of the modifier.
slotTypes Type: 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
// IIngredient.addGlobalAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[]);
myIIngredient.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, IItemStack.BASE_ATTACK_DAMAGE_UUID, "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>]);

Parameters:

attribute Type: Attribute - The Attribute of the modifier.
uuid Type: UUID - The unique identifier of the modifier to replace.
name Type: string - The name of the modifier.
value Type: double - The value of the modifier.
operation Type: AttributeOperation - The operation of the modifier.
slotTypes Type: EquipmentSlot[] - What slots the modifier is valid for.
addShiftTooltip(content as Component, showMessage as Component = null)
script.zs
// IIngredient.addShiftTooltip(content as Component, showMessage as Component = null);
myIIngredient.addShiftTooltip(myComponent, myComponent);

Parameters:

content Type: Component
showMessage (optional) Type: Component

Default Value: null

addTooltip(content as Component)
script.zs
// IIngredient.addTooltip(content as Component);
myIIngredient.addTooltip(myComponent);

Parameters:

content Type: Component
anyDamage() as IIngredientConditioned<IIngredient>
script.zs
// IIngredient.anyDamage() as IIngredientConditioned<IIngredient>;
myIIngredient.anyDamage();

Return Type: IngredientConditioned<IIngredient>

implicit as IData
script.zs
// IIngredient as IData
myIIngredient as IData

Return Type: IData

asIIngredientWithAmount() as IIngredientWithAmount
Used implicitly when a machine can accept more than one item but you only provide one.
script.zs
// IIngredient.asIIngredientWithAmount() as IIngredientWithAmount;
myIIngredient.asIIngredientWithAmount();

Return Type: IIngredientWithAmount

implicit as IIngredientWithAmount
Used implicitly when a machine can accept more than one item but you only provide one.
script.zs
// IIngredient as IIngredientWithAmount
myIIngredient as IIngredientWithAmount

Return Type: IIngredientWithAmount

implicit as MapData
script.zs
// IIngredient as MapData
myIIngredient as MapData

Return Type: MapData

asVanillaIngredient() as Ingredient
Create a Vanilla ingredient matching this one.
script.zs
// IIngredient.asVanillaIngredient() as Ingredient;
myIIngredient.asVanillaIngredient();

Return Type: Ingredient

implicit as Ingredient
Create a Vanilla ingredient matching this one.
script.zs
// IIngredient as Ingredient
myIIngredient as Ingredient

Return Type: Ingredient

Setter
Sets the burn time of this ingredient, for use in the furnace and other machines
script.zs
// IIngredient.burnTime = (time as int);
myIIngredient.burnTime = myInt;

Parameters:

time Type: 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
// IIngredient.burnTime(time as int);
myIIngredient.burnTime(500);

Parameters:

time Type: int - the new burn time
clearTooltip(leaveName as bool = false)
script.zs
// IIngredient.clearTooltip(leaveName as bool = false);
myIIngredient.clearTooltip(myBool);

Parameters:

leaveName (optional) Type: bool

Default Value: false

Getter
Returns the BEP to get this stack
script.zs
// IIngredient.commandString as string
myIIngredient.commandString

Return Type: string

contains(ingredient as IIngredient) as bool
Does the ingredient contain the given ingredient?
script.zs
// IIngredient.contains(ingredient as IIngredient) as bool;
myIIngredient.contains((<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>));

Parameters:

ingredient Type: IIngredient - The ingredient to check

Return Type: bool

Getter
Checks if this ingredient is empty.
script.zs
// IIngredient.empty as bool
myIIngredient.empty

Return Type: bool

empty() as bool
Checks if this ingredient is empty.

Returns: true if empty, false otherwise

script.zs
// IIngredient.empty() as bool;
myIIngredient.empty();

Return Type: bool

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
// IIngredient.getRemainingItem(stack as IItemStack) as IItemStack;
myIIngredient.getRemainingItem(<item:minecraft:iron_ingot>);

Parameters:

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

Return Type: IItemStack

Getter
script.zs
// IIngredient.items as IItemStack[]
myIIngredient.items

Return Type: IItemStack[]

matches(stack as IItemStack) as bool
Does the given stack match the ingredient?
script.zs
// IIngredient.matches(stack as IItemStack) as bool;
myIIngredient.matches(<item:minecraft:iron_ingot>);

Parameters:

stack Type: IItemStack - The stack to check

Return Type: bool

matches(stack as IItemStack, ignoreDamage as bool) as bool
Does the given stack match the ingredient?
script.zs
// IIngredient.matches(stack as IItemStack, ignoreDamage as bool) as bool;
myIIngredient.matches(<item:minecraft:iron_ingot>, myBool);

Parameters:

stack Type: IItemStack - The stack to check
ignoreDamage Type: bool - Should damage be checked?

Return Type: bool

modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction as ITooltipFunction = null)
script.zs
// IIngredient.modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction as ITooltipFunction = null);
myIIngredient.modifyShiftTooltip(myITooltipFunction, myITooltipFunction);

Parameters:

shiftedFunction Type: ITooltipFunction
unshiftedFunction (optional) Type: ITooltipFunction

Default Value: null

modifyTooltip(function as ITooltipFunction)
script.zs
// IIngredient.modifyTooltip(function as ITooltipFunction);
myIIngredient.modifyTooltip(myITooltipFunction);

Parameters:

mul(amount as int) as IIngredientWithAmount
Use this in contexts where machines accept more than one item to state that fact.
script.zs
// IIngredient.mul(amount as int) as IIngredientWithAmount;
myIIngredient.mul(myInt);

Parameters:

amount Type: int

Return Type: IIngredientWithAmount

only(condition as IIngredientCondition<IIngredient>) as IIngredientConditioned<IIngredient>
Use this if you already have the condition from another ingredient
script.zs
// IIngredient.only(condition as IIngredientCondition<IIngredient>) as IIngredientConditioned<IIngredient>;
myIIngredient.only(myIIngredientCondition);

Return Type: IngredientConditioned<IIngredient>

onlyDamaged() as IIngredientConditioned<IIngredient>
script.zs
// IIngredient.onlyDamaged() as IIngredientConditioned<IIngredient>;
myIIngredient.onlyDamaged();

Return Type: IngredientConditioned<IIngredient>

onlyDamagedAtLeast(minDamage as int) as IIngredientConditioned<IIngredient>
script.zs
// IIngredient.onlyDamagedAtLeast(minDamage as int) as IIngredientConditioned<IIngredient>;
myIIngredient.onlyDamagedAtLeast(myInt);

Parameters:

minDamage Type: int

Return Type: IngredientConditioned<IIngredient>

onlyDamagedAtMost(maxDamage as int) as IIngredientConditioned<IIngredient>
script.zs
// IIngredient.onlyDamagedAtMost(maxDamage as int) as IIngredientConditioned<IIngredient>;
myIIngredient.onlyDamagedAtMost(myInt);

Parameters:

maxDamage Type: int

Return Type: IngredientConditioned<IIngredient>

onlyIf(uid as string, function as function(t as IItemStack) as bool = null) as IIngredientConditioned<IIngredient>
script.zs
// IIngredient.onlyIf(uid as string, function as function(t as IItemStack) as bool = null) as IIngredientConditioned<IIngredient>;
myIIngredient.onlyIf(myString, myPredicate);

Parameters:

uid Type: string
function (optional) Type: function(t as IItemStack) as bool

Default Value: null

Return Type: IngredientConditioned<IIngredient>

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
// IIngredient.removeGlobalAttribute(attribute as Attribute, slotTypes as EquipmentSlot[]);
myIIngredient.removeGlobalAttribute(<attribute:minecraft:generic.attack_damage>, [<constant:minecraft:equipmentslot:chest>]);

Parameters:

attribute Type: Attribute - The attribute to remove.
slotTypes Type: EquipmentSlot[] - The slot types to remove it from.
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
// IIngredient.removeGlobalAttributeModifier(uuid as string, slotTypes as EquipmentSlot[]);
myIIngredient.removeGlobalAttributeModifier("8c1b5535-9f79-448b-87ae-52d81480aaa3", [<constant:minecraft:equipmentslot:chest>]);

Parameters:

uuid Type: string - The unique id of the AttributeModifier to remove.
slotTypes Type: 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
// IIngredient.removeGlobalAttributeModifier(uuid as UUID, slotTypes as EquipmentSlot[]);
myIIngredient.removeGlobalAttributeModifier(IItemStack.BASE_ATTACK_DAMAGE_UUID, [<constant:minecraft:equipmentslot:chest>]);

Parameters:

uuid Type: UUID - The unique id of the AttributeModifier to remove.
slotTypes Type: EquipmentSlot[] - The slot types to remove it from.
removeTooltip(regex as string)
script.zs
// IIngredient.removeTooltip(regex as string);
myIIngredient.removeTooltip(myString);

Parameters:

regex Type: string
reuse() as IIngredientTransformed<IIngredient>
script.zs
// IIngredient.reuse() as IIngredientTransformed<IIngredient>;
myIIngredient.reuse();

Return Type: IIngredientTransformed<IIngredient>

transform(transformer as IIngredientTransformer<IIngredient>) as IIngredientTransformed<IIngredient>
Use this if you already have the transformer from another ingredient
script.zs
// IIngredient.transform(transformer as IIngredientTransformer<IIngredient>) as IIngredientTransformed<IIngredient>;
myIIngredient.transform(myIIngredientTransformer);

Return Type: IIngredientTransformed<IIngredient>

transformCustom(uid as string, function as function(r as IItemStack) as IItemStack = null) as IIngredientTransformed<IIngredient>
script.zs
// IIngredient.transformCustom(uid as string, function as function(r as IItemStack) as IItemStack = null) as IIngredientTransformed<IIngredient>;
myIIngredient.transformCustom(myString, myFunction);

Parameters:

uid Type: string
function (optional) Type: function(r as IItemStack) as IItemStack

Default Value: null

Return Type: IIngredientTransformed<IIngredient>

transformDamage(amount as int = 1) as IIngredientTransformed<IIngredient>
script.zs
// IIngredient.transformDamage(amount as int = 1) as IIngredientTransformed<IIngredient>;
myIIngredient.transformDamage(myInt);

Parameters:

amount (optional) Type: int

Default Value: 1

Return Type: IIngredientTransformed<IIngredient>

transformReplace(replaceWith as IItemStack) as IIngredientTransformed<IIngredient>
script.zs
// IIngredient.transformReplace(replaceWith as IItemStack) as IIngredientTransformed<IIngredient>;
myIIngredient.transformReplace(myIItemStack);

Parameters:

replaceWith Type: IItemStack

Return Type: IIngredientTransformed<IIngredient>