IItemStack - CraftTweaker Documentation
IItemStack - CraftTweaker Documentation
1 Search
Home
Previous Equipable Ingredient Next
Commands
Examples
IItemStack
Getting Started With Scripts
Global Keywords Importing the class
Tutorials
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to
Vanilla import it. Simply add the import at the top of the file.
Api
script.zs
Advancement
Block import crafttweaker.api.item.IItemStack;
Bracket
Command Implements
Data IItemStack implements the following interfaces:
Entity IIngredient , IIngredientWithAmount , CommandStringDisplayable
Event
Fluid
Operators
Food in
Game
Ingredient in(ingredient as IIngredient) as bool
Item
Does the ingredient contain the given ingredient?
Alchemy
script.zs
Enchantment
Property // ((ingredient as IIngredient) in IItemStack) as bool
Tooltip
Parameters:
ingredient: IIngredient - The ingredient to check
Return Type: bool
Use this in contexts where machines accept more than one item to state that fact.
script.zs
Parameters:
amount: int
Return Type: IIngredientWithAmount
script.zs
Parameters:
other: IIngredient
script.zs
Parameters:
percentage: double
Parameters:
amount: int - new amount
Members
addGlobalAttributeModifier
Parameters:
attribute: Attribute - The Attribute of the modifier.
Parameters:
attribute: Attribute - The Attribute of the modifier.
Parameters:
attribute: Attribute - The Attribute of the modifier.
uuid: UUID - The unique identifier of the modifier to replace.
name: string - The name of the modifier.
addShiftTooltip
script.zs
Parameters:
content: Component
showMessage: Component (optional)
Default Value: null
addTooltip
addTooltip(content as Component)
script.zs
// IItemStack.addTooltip(content as Component);
myIItemStack.addTooltip(myComponent);
Parameters:
content: Component
amount
Getter
// IItemStack.amount as int
myIItemStack.amount
anyDamage
anyDamage() as IIngredientConditioned<IIngredient>
script.zs
// IItemStack.anyDamage() as IngredientConditioned<IIngredient>;
myIItemStack.anyDamage();
asIIngredientWithAmount
asIIngredientWithAmount() as IIngredientWithAmount
script.zs
// IItemStack.asIIngredientWithAmount() as IIngredientWithAmount;
myIItemStack.asIIngredientWithAmount();
implicit as IIngredientWithAmount
script.zs
// IItemStack as IIngredientWithAmount
myIItemStack as IIngredientWithAmount
asImmutable
asImmutable() as IItemStack
script.zs
// IItemStack.asImmutable() as IItemStack;
myIItemStack.asImmutable();
asItemLike
asItemLike() as ItemLike
script.zs
// IItemStack.asItemLike() as ItemLike;
myIItemStack.asItemLike();
implicit as ItemLike
script.zs
// IItemStack as ItemLike
myIItemStack as ItemLike
asMapData
implicit as MapData
script.zs
// IItemStack as MapData
myIItemStack as MapData
asMutable
asMutable() as IItemStack
script.zs
// IItemStack.asMutable() as IItemStack;
myIItemStack.asMutable();
asWeightedItemStack
implicit as Percentaged<IItemStack>
script.zs
// IItemStack as Percentaged<IItemStack>
myIItemStack as Percentaged<IItemStack>
BASE_ATTACK_DAMAGE_UUID
Field
script.zs
// IItemStack.BASE_ATTACK_DAMAGE_UUID as UUID
IItemStack.BASE_ATTACK_DAMAGE_UUID
BASE_ATTACK_SPEED_UUID
Field
script.zs
// IItemStack.BASE_ATTACK_SPEED_UUID as UUID
IItemStack.BASE_ATTACK_SPEED_UUID
baseRepairCost
Getter
// IItemStack.baseRepairCost as int
myIItemStack.baseRepairCost
burnTime
Getter
script.zs
// IItemStack.burnTime as int
myIItemStack.burnTime
Setter
Sets the burn time of this ingredient, for use in the furnace and other machines
script.zs
Parameters:
time: 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
// IItemStack.burnTime(time as int);
myIItemStack.burnTime(500);
Parameters:
time: int - the new burn time
clearTooltip
script.zs
Parameters:
leaveName: bool (optional)
Default Value: false
contains
Parameters:
ingredient: IIngredient - The ingredient to check
copy
copy() as IItemStack
Creates a copy
script.zs
// IItemStack.copy() as IItemStack;
myIItemStack.copy();
CRAFTTWEAKER_DATA_KEY
Field
script.zs
// IItemStack.CRAFTTWEAKER_DATA_KEY as string
IItemStack.CRAFTTWEAKER_DATA_KEY
damage
Getter
script.zs
// IItemStack.damage as int
myIItemStack.damage
damageableItem
Getter
Returns if the ItemStack is damageable I.E Swords and tools are damageable, sticks are not.
script.zs
// IItemStack.damageableItem as bool
myIItemStack.damageableItem
damaged
Getter
Returns if the ItemStack is damaged I.E a Swords that is no at full durability is damaged.
script.zs
// IItemStack.damaged as bool
myIItemStack.damaged
definition
Getter
script.zs
// IItemStack.definition as ItemDefinition
myIItemStack.definition
definition() as Item
script.zs
// IItemStack.definition() as ItemDefinition;
myIItemStack.definition();
implicit as Item
script.zs
// IItemStack as ItemDefinition
myIItemStack as Item
descriptionId
Getter
// IItemStack.descriptionId as string
myIItemStack.descriptionId
displayName
Getter
// IItemStack.displayName as Component
myIItemStack.displayName
enchantments
Getter
script.zs
// IItemStack.enchantments as Integer[Enchantment]
myIItemStack.enchantments
Setter
Parameters:
enchantments: Integer[Enchantment] - The new enchantments
enchantments() as Integer[Enchantment]
script.zs
// IItemStack.enchantments() as Integer[Enchantment];
myIItemStack.enchantments();
script.zs
Parameters:
enchantments: Integer[Enchantment] - The new enchantments
fireResistant
Getter
Checks if this IItemStack burns when thrown into fire / lava or damaged by fire.
script.zs
// IItemStack.fireResistant as bool
myIItemStack.fireResistant
Setter
Parameters:
fireResistant: bool - Should the item be immune to fire.
fireResistant() as bool
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.
script.zs
// IItemStack.fireResistant() as bool;
myIItemStack.fireResistant();
fireResistant(fireResistant as bool)
// IItemStack.fireResistant(fireResistant as bool);
myIItemStack.fireResistant(myBool);
Parameters:
fireResistant: bool - Should the item be immune to fire.
food
Getter
script.zs
// IItemStack.food as FoodProperties
myIItemStack.food
Setter
script.zs
Parameters:
food: FoodProperties
food() as FoodProperties
script.zs
// IItemStack.food() as FoodProperties;
myIItemStack.food();
food(food as FoodProperties)
script.zs
// IItemStack.food(food as FoodProperties);
myIItemStack.food(myFoodProperties);
Parameters:
food: FoodProperties
getAttributes
Gets the Attributes and the AttributeModifiers on this IItemStack for the given EquipmentSlot
Returns: A Map of Attribute to a List of AttributeModifier for the given EquipmentSlot.
script.zs
Parameters:
slotType: EquipmentSlot - The slot to get the Attributes for.
Return Type: List<AttributeModifier>[Attribute]
getEnchantmentLevel
Gets the level of the given enchantment on the item. Returns 0 if the item doesn't have the given
enchantment.
script.zs
Parameters:
enchantment: Enchantment
Return Type: int
getImmutableInternal
getImmutableInternal() as ItemStack
script.zs
// IItemStack.getImmutableInternal() as ItemStack;
myIItemStack.getImmutableInternal();
getInternal
getInternal() as ItemStack
script.zs
// IItemStack.getInternal() as ItemStack;
myIItemStack.getInternal();
implicit as ItemStack
// IItemStack as ItemStack
myIItemStack as ItemStack
getOrCreateTag
getOrCreateTag() as IData
Returns the NBT tag attached to this ItemStack or makes a new tag.
Returns: MapData of the ItemStack NBT Tag, empty tag if it doesn't exist.
script.zs
// IItemStack.getOrCreateTag() as IData;
myIItemStack.getOrCreateTag();
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.
script.zs
Parameters:
stack: IItemStack - The stack to provide for this ingredient.
Return Type: IItemStack
grow
Grows this IItemStack's stack size by the given amount, or 1 if no amount is given.
Returns: This IItemStack if mutable, a new one with the new amount otherwise.
script.zs
Parameters:
amount: int (optional) - The amount to grow by.
Default Value: 1
Return Type: IItemStack
hasCustomHoverName
Getter
// IItemStack.hasCustomHoverName as bool
myIItemStack.hasCustomHoverName
hasFoil
Getter
// IItemStack.hasFoil as bool
myIItemStack.hasFoil
hasTag
Getter
// IItemStack.hasTag as bool
myIItemStack.hasTag
hoverName
Getter
script.zs
// IItemStack.hoverName as Component
myIItemStack.hoverName
hoverName() as Component
script.zs
// IItemStack.hoverName() as Component;
myIItemStack.hoverName();
isEdible
Getter
script.zs
// IItemStack.isEdible as bool
myIItemStack.isEdible
isEdible() as bool
script.zs
// IItemStack.isEdible() as bool;
myIItemStack.isEdible();
isEnchantable
Getter
// IItemStack.isEnchantable as bool
myIItemStack.isEnchantable
isEnchanted
Getter
// IItemStack.isEnchanted as bool
myIItemStack.isEnchanted
isImmutable
Getter
script.zs
// IItemStack.isImmutable as bool
myIItemStack.isImmutable
isImmutable() as bool
script.zs
// IItemStack.isImmutable() as bool;
myIItemStack.isImmutable();
isMutable
Getter
script.zs
// IItemStack.isMutable as bool
myIItemStack.isMutable
isMutable() as bool
script.zs
// IItemStack.isMutable() as bool;
myIItemStack.isMutable();
items
Getter
script.zs
// IItemStack.items as IItemStack[]
myIItemStack.items
matches
Parameters:
stack: IItemStack - The stack to check
maxDamage
Getter
Returns the max damage of the ItemStack This is the max durability of the ItemStack.
script.zs
// IItemStack.maxDamage as int
myIItemStack.maxDamage
Setter
Parameters:
newMaxDamage: int - The new max damage of the ItemStack
maxStackSize
Getter
// IItemStack.maxStackSize as int
myIItemStack.maxStackSize
Setter
Parameters:
newMaxStackSize: int - The new max stack size of the Item.
maxStackSize() as int
script.zs
// IItemStack.maxStackSize() as int;
myIItemStack.maxStackSize();
maxStackSize(newMaxStackSize as int)
// IItemStack.maxStackSize(newMaxStackSize as int);
myIItemStack.maxStackSize(16);
Parameters:
newMaxStackSize: int - The new max stack size of the Item.
modifyShiftTooltip
script.zs
Parameters:
shiftedFunction: ITooltipFunction
unshiftedFunction: ITooltipFunction (optional)
Default Value: null
modifyTooltip
modifyTooltip(function as ITooltipFunction)
script.zs
// IItemStack.modifyTooltip(function as ITooltipFunction);
myIItemStack.modifyTooltip(myITooltipFunction);
Parameters:
function: ITooltipFunction
mul
Use this in contexts where machines accept more than one item to state that fact.
script.zs
Parameters:
amount: int
Return Type: IIngredientWithAmount
only
only(condition as IIngredientCondition<IIngredient>) as
IIngredientConditioned<IIngredient>
Use this if you already have the condition from another ingredient
script.zs
Parameters:
condition: IIngredientCondition<IIngredient>
Return Type: IngredientConditioned<IIngredient>
onlyDamaged
onlyDamaged() as IIngredientConditioned<IIngredient>
script.zs
// IItemStack.onlyDamaged() as IngredientConditioned<IIngredient>;
myIItemStack.onlyDamaged();
onlyDamagedAtLeast
script.zs
Parameters:
minDamage: int
onlyDamagedAtMost
script.zs
Parameters:
maxDamage: int
Return Type: IngredientConditioned<IIngredient>
onlyIf
script.zs
Parameters:
uid: string
function: function(t as IItemStack) as bool (optional)
Default Value: null
Return Type: IngredientConditioned<IIngredient>
owner
Getter
// IItemStack.owner as string
myIItemStack.owner
percent
script.zs
Parameters:
percentage: double
rarity
Getter
// IItemStack.rarity as Rarity
myIItemStack.rarity
Setter
Parameters:
newRarity: Rarity - The new rarity of the Item.
rarity() as Rarity
script.zs
// IItemStack.rarity() as Rarity;
myIItemStack.rarity();
rarity(newRarity as Rarity)
// IItemStack.rarity(newRarity as Rarity);
myIItemStack.rarity(Rarity.UNCOMMON);
Parameters:
newRarity: Rarity - The new rarity of the Item.
registryName
Getter
// IItemStack.registryName as ResourceLocation
myIItemStack.registryName
removeEnchantment
script.zs
Parameters:
enchantment: Enchantment - The enchantment to remove.
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.
script.zs
Parameters:
attribute: Attribute - The attribute to remove.
removeGlobalAttributeModifier
Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.
script.zs
Parameters:
uuid: string - The unique id of the AttributeModifier to remove.
slotTypes: EquipmentSlot[] - The slot types to remove it from.
Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.
script.zs
Parameters:
uuid: UUID - The unique id of the AttributeModifier to remove.
slotTypes: EquipmentSlot[] - The slot types to remove it from.
removeTooltip
removeTooltip(regex as string)
script.zs
// IItemStack.removeTooltip(regex as string);
myIItemStack.removeTooltip(myString);
Parameters:
regex: string
resetHoverName
resetHoverName()
// IItemStack.resetHoverName();
myIItemStack.resetHoverName();
reuse
reuse() as IIngredientTransformed<IIngredient>
script.zs
// IItemStack.reuse() as IIngredientTransformed<IIngredient>;
myIItemStack.reuse();
shrink
Shrinks this IItemStack's stack size by the given amount, or 1 if no amount is given.
Returns: This IItemStack if mutable, a new one with the new amount otherwise.
script.zs
Parameters:
amount: int (optional) - The amount to shrink by.
Default Value: 1
Return Type: IItemStack
stackable
Getter
Returns if the ItemStack can have an amount greater than 1 I.E Swords and tools are not stackable,
sticks are.
script.zs
// IItemStack.stackable as bool
myIItemStack.stackable
tag
Getter
// IItemStack.tag as IData
myIItemStack.tag
transform
transform(transformer as IIngredientTransformer<IIngredient>) as
IIngredientTransformed<IIngredient>
Use this if you already have the transformer from another ingredient
script.zs
Parameters:
transformer: IIngredientTransformer<IIngredient>
transformCustom
script.zs
Parameters:
uid: string
function: function(r as IItemStack) as IItemStack (optional)
Default Value: null
Return Type: IIngredientTransformed<IIngredient>
transformDamage
script.zs
Parameters:
amount: int (optional)
Default Value: 1
Return Type: IIngredientTransformed<IIngredient>
transformReplace
script.zs
Parameters:
replaceWith: IItemStack
useDuration
Getter
// IItemStack.useDuration as int
myIItemStack.useDuration
useOnRelease
Getter
// IItemStack.useOnRelease as bool
myIItemStack.useOnRelease
withAttributeModifier
Parameters:
attribute: Attribute - The Attribute of the modifier.
Parameters:
attribute: Attribute - The Attribute of the modifier.
Parameters:
attribute: Attribute - The Attribute of the modifier.
name: string - The name of the modifier.
preserveDefaults: bool (optional) - Should the default Item Attribute Modifiers be preserved
when adding this modifier.
Default Value: false
Return Type: IItemStack
withDamage
Parameters:
damage: int - the new damage value
withDisplayName
Parameters:
name: Component - New name of the stack.
withEnchantment
script.zs
Parameters:
enchantment: Enchantment - The enchantment to add.
level: int (optional) - The level of the enchantment
Default Value: 1
Return Type: IItemStack
withLore
Parameters:
lore: Component[] - the new Lore of the ItemStack.
Return Type: IItemStack
withoutTag
withoutTag() as IItemStack
script.zs
// IItemStack.withoutTag() as IItemStack;
myIItemStack.withoutTag();
withTag
script.zs
Parameters:
tag: MapData - The tag to set.