MCItemStack
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.
import crafttweaker.api.item.MCItemStack;Implements
MCItemStack
implements the following interfaces:
ForgeItemStack,IItemStack,IIngredient,IIngredientWithAmount,CommandStringDisplayable
Operators
myIIngredient in myMCItemStackParameters:
Return Type:
bool
// (MCItemStack == (o as Object)) as boolmyMCItemStack == myObjectParameters:
o: Object  Type: Object   
Return Type:
bool
// (MCItemStack * (amount as int)) as IIngredientWithAmountmyMCItemStack * myIntParameters:
amount: int  Type: int   
Return Type:
IIngredientWithAmount
myMCItemStack | myIIngredientParameters:
other: IIngredient  Type: IIngredient   
Return Type:
IIngredientList
myMCItemStack % myDoubleParameters:
percentage: double  Type: double   
Return Type:
Percentaged<IItemStack>
// (MCItemStack * (amount as int)) as IItemStackmyMCItemStack * myIntParameters:
amount: int  Type: int 
- new amount   
Return Type:
IItemStack
Members
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
// MCItemStack.addGlobalAttributeModifier(attribute as Attribute, name as string, value as double, operation as AttributeOperation, slotTypes as EquipmentSlot[]);myMCItemStack.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>]);Parameters:
name: string  Type: string 
- The name of the modifier.   value: double  Type: double 
- The value of the modifier.   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
// MCItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as AttributeOperation, slotTypes as EquipmentSlot[]);myMCItemStack.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>]);Parameters:
uuid: string  Type: string 
- The unique identifier of the modifier to replace.   name: string  Type: string 
- The name of the modifier.   value: double  Type: double 
- The value of the modifier.   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
// MCItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value as double, operation as AttributeOperation, slotTypes as EquipmentSlot[]);myMCItemStack.addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, IItemStack.BASE_ATTACK_DAMAGE_UUID, "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>]);Parameters:
uuid: UUID  Type: UUID 
- The unique identifier of the modifier to replace.   name: string  Type: string 
- The name of the modifier.   value: double  Type: double 
- The value of the modifier.   // MCItemStack.amount as intmyMCItemStack.amount
Return Type:
int
// MCItemStack.amount as intmyMCItemStack.amount
Return Type:
int
myMCItemStack.asIIngredientWithAmount();
Return Type:
IIngredientWithAmount
// MCItemStack as IIngredientWithAmountmyMCItemStack as IIngredientWithAmount
Return Type:
IIngredientWithAmount
// MCItemStack as IIngredientWithAmountmyMCItemStack as IIngredientWithAmount
Return Type:
IIngredientWithAmount
myMCItemStack.asVanillaIngredient();
Return Type:
Ingredient
// MCItemStack as IngredientmyMCItemStack as Ingredient
Return Type:
Ingredient
myMCItemStack as Percentaged<IItemStack>
Return Type:
Percentaged<IItemStack>
// MCItemStack.BASE_ATTACK_DAMAGE_UUID as UUIDMCItemStack.BASE_ATTACK_DAMAGE_UUID
Return Type:
UUID
// MCItemStack.BASE_ATTACK_SPEED_UUID as UUIDMCItemStack.BASE_ATTACK_SPEED_UUID
Return Type:
UUID
// MCItemStack.baseRepairCost as intmyMCItemStack.baseRepairCost
Return Type:
int
// MCItemStack.burnTime as intmyMCItemStack.burnTime
Return Type:
int
// MCItemStack.burnTime = (time as int);myMCItemStack.burnTime = myInt;Parameters:
time: int  Type: int 
- the new burn time   // MCItemStack.burnTime(time as int);myMCItemStack.burnTime(500);Parameters:
time: int  Type: int 
- the new burn time   // MCItemStack.clearTooltip(leaveName as bool = false);myMCItemStack.clearTooltip(myBool);Parameters:
leaveName: bool (optional)  Type: bool  
Default Value: false 
// MCItemStack.commandString as stringmyMCItemStack.commandString
Return Type:
string
// MCItemStack.commandString as stringmyMCItemStack.commandString
Return Type:
string
// MCItemStack.commandString() as string;myMCItemStack.commandString();
Return Type:
string
myMCItemStack.contains((<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>));Parameters:
Return Type:
bool
// MCItemStack.CRAFTTWEAKER_DATA_KEY as stringMCItemStack.CRAFTTWEAKER_DATA_KEY
Return Type:
string
// MCItemStack.damage as intmyMCItemStack.damage
Return Type:
int
// MCItemStack.damageableItem as boolmyMCItemStack.damageableItem
Return Type:
bool
// MCItemStack.damaged as boolmyMCItemStack.damaged
Return Type:
bool
// MCItemStack.definition as ItemDefinitionmyMCItemStack.definition
Return Type:
ItemDefinition
// MCItemStack as ItemDefinitionmyMCItemStack as Item
Return Type:
ItemDefinition
// MCItemStack.descriptionId as stringmyMCItemStack.descriptionId
Return Type:
string
// MCItemStack.empty as boolmyMCItemStack.empty
Return Type:
bool
Returns: true if empty, false otherwise
// MCItemStack.empty() as bool;myMCItemStack.empty();
Return Type:
bool
myMCItemStack.enchantments
Return Type:
Integer[Enchantment]
myMCItemStack.enchantments = myMap;Parameters:
Returns: This itemStack if it is mutable, a new one with the enchantments otherwise
myMCItemStack.enchantments(myMap);Parameters:
Return Type:
IItemStack
// MCItemStack.fireResistant as boolmyMCItemStack.fireResistant
Return Type:
bool
If true, the item will not burn when thrown into fire or lava.
// MCItemStack.fireResistant = (fireResistant as bool);myMCItemStack.fireResistant = myBool;Parameters:
fireResistant: bool  Type: bool 
- Should the item be immune to fire.   Returns: True if this IItemStack is immune to fire. False otherwise.
// MCItemStack.fireResistant() as bool;myMCItemStack.fireResistant();
Return Type:
bool
If true, the item will not burn when thrown into fire or lava.
// MCItemStack.fireResistant(fireResistant as bool);myMCItemStack.fireResistant(myBool);Parameters:
fireResistant: bool  Type: bool 
- Should the item be immune to fire.   // MCItemStack.food as FoodPropertiesmyMCItemStack.food
Return Type:
FoodProperties
myMCItemStack.food = myFoodProperties;Parameters:
food: FoodProperties  Type: FoodProperties   myMCItemStack.food(myFoodProperties);Parameters:
food: FoodProperties  Type: FoodProperties   Returns: A Map of Attribute to a List of AttributeModifier for the given EquipmentSlot.
myMCItemStack.getAttributes(<constant:minecraft:equipmentslot:chest>);Parameters:
Return Type:
List<AttributeModifier>[Attribute]
myMCItemStack.getBurnTime(myIRecipeManager);Parameters:
manager: IRecipeManager<Recipe>  Type: IRecipeManager<Recipe>   
Return Type:
int
myMCItemStack.getEnchantmentLevel(myEnchantment);Parameters:
enchantment: Enchantment  Type: Enchantment   
Return Type:
int
myMCItemStack.getRemainingItem(<item:minecraft:iron_ingot>);Parameters:
Return Type:
IItemStack
Returns: This IItemStack if mutable, a new one with the new amount otherwise.
myMCItemStack.grow(2);Parameters:
amount: int (optional)  Type: int 
- The amount to grow by.  
Default Value: 1 
Return Type:
IItemStack
// MCItemStack.hasCustomHoverName as boolmyMCItemStack.hasCustomHoverName
Return Type:
bool
Foil is the glint / effect that is added to enchanted ItemStacks (and other items).
// MCItemStack.hasFoil as boolmyMCItemStack.hasFoil
Return Type:
bool
// MCItemStack.hasTag as boolmyMCItemStack.hasTag
Return Type:
bool
// MCItemStack.ingredient as IIngredientmyMCItemStack.ingredient
Return Type:
IIngredient
// MCItemStack.isEdible as boolmyMCItemStack.isEdible
Return Type:
bool
// MCItemStack.isEdible() as bool;myMCItemStack.isEdible();
Return Type:
bool
// MCItemStack.isEnchantable as boolmyMCItemStack.isEnchantable
Return Type:
bool
// MCItemStack.isEnchanted as boolmyMCItemStack.isEnchanted
Return Type:
bool
// MCItemStack.isMutable as boolmyMCItemStack.isMutable
Return Type:
bool
// MCItemStack.isMutable() as bool;myMCItemStack.isMutable();
Return Type:
bool
myMCItemStack.matches(<item:minecraft:iron_ingot>);Parameters:
Return Type:
bool
myMCItemStack.matches(<item:minecraft:iron_ingot>, myBool);Parameters:
ignoreDamage: bool  Type: bool 
- Should damage be checked?   
Return Type:
bool
// MCItemStack.maxDamage as intmyMCItemStack.maxDamage
Return Type:
int
Setting the damage to
0 will make the item unbreakable.// MCItemStack.maxDamage = (newMaxDamage as int);myMCItemStack.maxDamage = myInt;Parameters:
newMaxDamage: int  Type: int 
- The new max damage of the ItemStack   // MCItemStack.maxStackSize as intmyMCItemStack.maxStackSize
Return Type:
int
// MCItemStack.maxStackSize = (newMaxStackSize as int);myMCItemStack.maxStackSize = myInt;Parameters:
newMaxStackSize: int  Type: int 
- The new max stack size of the Item.   Returns: Max stack size of the Item.
// MCItemStack.maxStackSize() as int;myMCItemStack.maxStackSize();
Return Type:
int
// MCItemStack.maxStackSize(newMaxStackSize as int);myMCItemStack.maxStackSize(16);Parameters:
newMaxStackSize: int  Type: int 
- The new max stack size of the Item.   // MCItemStack.modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction as ITooltipFunction = null);myMCItemStack.modifyShiftTooltip(myITooltipFunction, myITooltipFunction);Parameters:
shiftedFunction: ITooltipFunction  Type: ITooltipFunction   myMCItemStack.modifyTooltip(myITooltipFunction);Parameters:
function: ITooltipFunction  Type: ITooltipFunction   myMCItemStack.mul(myInt);Parameters:
amount: int  Type: int   
Return Type:
IIngredientWithAmount
// MCItemStack.only(condition as IIngredientCondition<IIngredient>) as IngredientConditioned<IIngredient>;myMCItemStack.only(myIIngredientCondition);Parameters:
condition: IIngredientCondition<IIngredient>  Type: IIngredientCondition<IIngredient>   
Return Type:
IngredientConditioned<IIngredient>
myMCItemStack.onlyDamagedAtLeast(myInt);Parameters:
minDamage: int  Type: int   
Return Type:
IngredientConditioned<IIngredient>
myMCItemStack.onlyDamagedAtMost(myInt);Parameters:
maxDamage: int  Type: int   
Return Type:
IngredientConditioned<IIngredient>
// MCItemStack.onlyIf(uid as string, function as function(t as IItemStack) as bool = null) as IngredientConditioned<IIngredient>;myMCItemStack.onlyIf(myString, myPredicate);Parameters:
uid: string  Type: string   function: function(t as IItemStack) as bool (optional)  Type: function(t as IItemStack) as bool  
Default Value: null 
Return Type:
IngredientConditioned<IIngredient>
// MCItemStack.owner as stringmyMCItemStack.owner
Return Type:
string
myMCItemStack.percent(myDouble);Parameters:
percentage: double  Type: double   
Return Type:
Percentaged<IItemStack>
// MCItemStack.registryName as ResourceLocationmyMCItemStack.registryName
Return Type:
ResourceLocation
Returns: This itemStack if it is mutable, a new one with the enchantment removed otherwise
myMCItemStack.removeEnchantment(<enchantment:minecraft:riptide>);Parameters:
Return Type:
IItemStack
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.
myMCItemStack.removeGlobalAttribute(<attribute:minecraft:generic.attack_damage>, [<constant:minecraft:equipmentslot:chest>]);Parameters:
myMCItemStack.removeGlobalAttributeModifier("8c1b5535-9f79-448b-87ae-52d81480aaa3", [<constant:minecraft:equipmentslot:chest>]);Parameters:
uuid: string  Type: string 
- The unique id of the AttributeModifier to remove.   myMCItemStack.removeGlobalAttributeModifier(IItemStack.BASE_ATTACK_DAMAGE_UUID, [<constant:minecraft:equipmentslot:chest>]);Parameters:
uuid: UUID  Type: UUID 
- The unique id of the AttributeModifier to remove.   // MCItemStack.removeTooltip(regex as string);myMCItemStack.removeTooltip(myString);Parameters:
regex: string  Type: string   // MCItemStack.resetHoverName();myMCItemStack.resetHoverName();myMCItemStack.setBurnTime(500, myIRecipeManager);Parameters:
time: int  Type: int 
- the new burn time   manager: IRecipeManager<Recipe>  Type: IRecipeManager<Recipe>   Returns: This IItemStack if mutable, a new one with the new amount otherwise.
myMCItemStack.shrink(2);Parameters:
amount: int (optional)  Type: int 
- The amount to shrink by.  
Default Value: 1 
Return Type:
IItemStack
// MCItemStack.stackable as boolmyMCItemStack.stackable
Return Type:
bool
// MCItemStack.transform(transformer as IIngredientTransformer<IIngredient>) as IIngredientTransformed<IIngredient>;myMCItemStack.transform(myIIngredientTransformer);Parameters:
transformer: IIngredientTransformer<IIngredient>  Type: IIngredientTransformer<IIngredient>   
Return Type:
IIngredientTransformed<IIngredient>
// MCItemStack.transformCustom(uid as string, function as function(r as IItemStack) as IItemStack = null) as IIngredientTransformed<IIngredient>;myMCItemStack.transformCustom(myString, myFunction);Parameters:
uid: string  Type: string   function: function(r as IItemStack) as IItemStack (optional)  Type: function(r as IItemStack) as IItemStack  
Default Value: null 
Return Type:
IIngredientTransformed<IIngredient>
myMCItemStack.transformDamage(myInt);Parameters:
amount: int (optional)  Type: int  
Default Value: 1 
Return Type:
IIngredientTransformed<IIngredient>
myMCItemStack.transformReplace(myIItemStack);Parameters:
replaceWith: IItemStack  Type: IItemStack   
Return Type:
IIngredientTransformed<IIngredient>
// MCItemStack.useDuration as intmyMCItemStack.useDuration
Return Type:
int
// MCItemStack.useOnRelease as boolmyMCItemStack.useOnRelease
Return Type:
bool
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).// MCItemStack.withAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as AttributeOperation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as IItemStack;myMCItemStack.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>], true);Parameters:
uuid: string  Type: string 
- The unique identifier of the modifier to replace.   name: string  Type: string 
- The name of the modifier.   value: double  Type: double 
- The value of the modifier.   preserveDefaults: bool (optional)  Type: bool 
- Should the default Item Attribute Modifiers be preserved when adding this modifier.  
Default Value: false 
Return Type:
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).// MCItemStack.withAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value as double, operation as AttributeOperation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as IItemStack;myMCItemStack.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>], true);Parameters:
uuid: UUID  Type: UUID 
- The unique identifier of the modifier to replace.   name: string  Type: string 
- The name of the modifier.   value: double  Type: double 
- The value of the modifier.   preserveDefaults: bool (optional)  Type: bool 
- Should the default Item Attribute Modifiers be preserved when adding this modifier.  
Default Value: false 
Return Type:
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).// MCItemStack.withAttributeModifier(attribute as Attribute, name as string, value as double, operation as AttributeOperation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as IItemStack;myMCItemStack.withAttributeModifier(<attribute:minecraft:generic.attack_damage>, "Extra Power", 10, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:chest>], true);Parameters:
name: string  Type: string 
- The name of the modifier.   value: double  Type: double 
- The value of the modifier.   preserveDefaults: bool (optional)  Type: bool 
- Should the default Item Attribute Modifiers be preserved when adding this modifier.  
Default Value: false 
Return Type:
IItemStack
myMCItemStack.withDamage(10);Parameters:
damage: int  Type: int 
- the new damage value   
Return Type:
IItemStack
myMCItemStack.withDisplayName("totally not dirt");
Return Type:
IItemStack
Returns: This itemStack if it is mutable, a new one with the enchantment added otherwise
myMCItemStack.withEnchantment(<enchantment:minecraft:riptide>, 2);Parameters:
level: int (optional)  Type: int 
- The level of the enchantment  
Default Value: 1 
Return Type:
IItemStack
myMCItemStack.withLore(new crafttweaker.api.text.TextComponent("I am the lore I speak for the trees"););
Return Type:
IItemStack
Returns: This itemStack if it is mutable, a new one with the changed property otherwise
myMCItemStack.withoutTag();
Return Type:
IItemStack
Returns: This itemStack if it is mutable, a new one with the changed property otherwise
myMCItemStack.withTag({Display: {lore: ["Hello"]}});
Return Type:
IItemStack