IItemStack
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.IItemStack;
Implements
IItemStack
implements the following interfaces:
IIngredient
,IIngredientWithAmount
,CommandStringDisplayable
Operators
// ((ingredient as IIngredient) in IItemStack) as boolmyIIngredient in myIItemStack
Parameters:
Return Type:
bool
// (IItemStack * (amount as int)) as IIngredientWithAmountmyIItemStack * myInt
Parameters:
amount: int
Type: int
Return Type:
IIngredientWithAmount
// (IItemStack | (other as IIngredient)) as IIngredientListmyIItemStack | myIIngredient
Parameters:
other: IIngredient
Type: IIngredient
Return Type:
IIngredientList
// (IItemStack % (percentage as double)) as Percentaged<IItemStack>myIItemStack % myDouble
Parameters:
percentage: double
Type: double
Return Type:
Percentaged<IItemStack>
// (IItemStack * (amount as int)) as IItemStackmyIItemStack * myInt
Parameters:
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
// IItemStack.addGlobalAttributeModifier(attribute as Attribute, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[]);myIItemStack.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
// IItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[]);myIItemStack.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
// IItemStack.addGlobalAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[]);myIItemStack.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. // IItemStack.amount as intmyIItemStack.amount
Return Type:
int
// IItemStack.anyDamage() as IIngredientConditioned<IIngredient>;myIItemStack.anyDamage();
Return Type:
IngredientConditioned<IIngredient>
// IItemStack.asIIngredientWithAmount() as IIngredientWithAmount;myIItemStack.asIIngredientWithAmount();
Return Type:
IIngredientWithAmount
// IItemStack as IIngredientWithAmountmyIItemStack as IIngredientWithAmount
Return Type:
IIngredientWithAmount
// IItemStack.asImmutable() as IItemStack;myIItemStack.asImmutable();
Return Type:
IItemStack
// IItemStack as MapDatamyIItemStack as MapData
Return Type:
MapData
// IItemStack as Percentaged<IItemStack>myIItemStack as Percentaged<IItemStack>
Return Type:
Percentaged<IItemStack>
// IItemStack.BASE_ATTACK_DAMAGE_UUID as UUIDIItemStack.BASE_ATTACK_DAMAGE_UUID
Return Type:
UUID
// IItemStack.BASE_ATTACK_SPEED_UUID as UUIDIItemStack.BASE_ATTACK_SPEED_UUID
Return Type:
UUID
// IItemStack.baseRepairCost as intmyIItemStack.baseRepairCost
Return Type:
int
// IItemStack.burnTime as intmyIItemStack.burnTime
Return Type:
int
// IItemStack.burnTime = (time as int);myIItemStack.burnTime = myInt;
Parameters:
time: int
Type: int
- the new burn time // IItemStack.burnTime(time as int);myIItemStack.burnTime(500);
Parameters:
time: int
Type: int
- the new burn time // IItemStack.clearTooltip(leaveName as bool = false);myIItemStack.clearTooltip(myBool);
Parameters:
leaveName: bool
(optional) Type: bool
Default Value: false
// IItemStack.contains(ingredient as IIngredient) as bool;myIItemStack.contains((<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>));
Parameters:
Return Type:
bool
// IItemStack.copy() as IItemStack;myIItemStack.copy();
Return Type:
IItemStack
// IItemStack.CRAFTTWEAKER_DATA_KEY as stringIItemStack.CRAFTTWEAKER_DATA_KEY
Return Type:
string
// IItemStack.damage as intmyIItemStack.damage
Return Type:
int
// IItemStack.damageableItem as boolmyIItemStack.damageableItem
Return Type:
bool
// IItemStack.damaged as boolmyIItemStack.damaged
Return Type:
bool
// IItemStack.definition as ItemmyIItemStack.definition
Return Type:
ItemDefinition
// IItemStack as ItemmyIItemStack as Item
Return Type:
ItemDefinition
// IItemStack.descriptionId as stringmyIItemStack.descriptionId
Return Type:
string
// IItemStack.displayName as ComponentmyIItemStack.displayName
Return Type:
Component
// IItemStack.enchantments as Integer[Enchantment]myIItemStack.enchantments
Return Type:
Integer[Enchantment]
// IItemStack.enchantments = (enchantments as Integer[Enchantment]);myIItemStack.enchantments = myMap;
Parameters:
// IItemStack.enchantments() as Integer[Enchantment];myIItemStack.enchantments();
Return Type:
Integer[Enchantment]
Returns: This itemStack if it is mutable, a new one with the enchantments otherwise
// IItemStack.enchantments(enchantments as Integer[Enchantment]) as IItemStack;myIItemStack.enchantments(myMap);
Parameters:
Return Type:
IItemStack
// IItemStack.fireResistant as boolmyIItemStack.fireResistant
Return Type:
bool
If true, the item will not burn when thrown into fire or lava.
// IItemStack.fireResistant = (fireResistant as bool);myIItemStack.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.
// IItemStack.fireResistant() as bool;myIItemStack.fireResistant();
Return Type:
bool
If true, the item will not burn when thrown into fire or lava.
// IItemStack.fireResistant(fireResistant as bool);myIItemStack.fireResistant(myBool);
Parameters:
fireResistant: bool
Type: bool
- Should the item be immune to fire. // IItemStack.food as FoodPropertiesmyIItemStack.food
Return Type:
FoodProperties
// IItemStack.food = (food as FoodProperties);myIItemStack.food = myFoodProperties;
Parameters:
food: FoodProperties
Type: FoodProperties
// IItemStack.food(food as FoodProperties);myIItemStack.food(myFoodProperties);
Parameters:
food: FoodProperties
Type: FoodProperties
Returns: A Map of Attribute to a List of AttributeModifier for the given EquipmentSlot.
// IItemStack.getAttributes(slotType as EquipmentSlot) as List<AttributeModifier>[Attribute];myIItemStack.getAttributes(<constant:minecraft:equipmentslot:chest>);
Parameters:
Return Type:
List<AttributeModifier>[Attribute]
// IItemStack.getEnchantmentLevel(enchantment as Enchantment) as int;myIItemStack.getEnchantmentLevel(myEnchantment);
Parameters:
enchantment: Enchantment
Type: Enchantment
Return Type:
int
// IItemStack.getImmutableInternal() as ItemStack;myIItemStack.getImmutableInternal();
Return Type:
ItemStack
Returns: MapData of the ItemStack NBT Tag, empty tag if it doesn't exist.
// IItemStack.getOrCreateTag() as IData;myIItemStack.getOrCreateTag();
Return Type:
IData
// IItemStack.getRemainingItem(stack as IItemStack) as IItemStack;myIItemStack.getRemainingItem(<item:minecraft:iron_ingot>);
Parameters:
Return Type:
IItemStack
Returns: This IItemStack if mutable, a new one with the new amount otherwise.
// IItemStack.grow(amount as int = 1) as IItemStack;myIItemStack.grow(2);
Parameters:
amount: int
(optional) Type: int
- The amount to grow by.
Default Value: 1
Return Type:
IItemStack
// IItemStack.hasCustomHoverName as boolmyIItemStack.hasCustomHoverName
Return Type:
bool
Foil is the glint / effect that is added to enchanted ItemStacks (and other items).
// IItemStack.hasFoil as boolmyIItemStack.hasFoil
Return Type:
bool
// IItemStack.hasTag as boolmyIItemStack.hasTag
Return Type:
bool
This will give the raw name without the formatting that 'displayName' applies.
// IItemStack.hoverName as ComponentmyIItemStack.hoverName
Return Type:
Component
This will give the raw name without the formatting that 'displayName' applies.
Returns: The hover name of the ItemStack.
// IItemStack.hoverName() as Component;myIItemStack.hoverName();
Return Type:
Component
// IItemStack.isEdible as boolmyIItemStack.isEdible
Return Type:
bool
// IItemStack.isEdible() as bool;myIItemStack.isEdible();
Return Type:
bool
// IItemStack.isEnchantable as boolmyIItemStack.isEnchantable
Return Type:
bool
// IItemStack.isEnchanted as boolmyIItemStack.isEnchanted
Return Type:
bool
// IItemStack.isImmutable as boolmyIItemStack.isImmutable
Return Type:
bool
// IItemStack.isImmutable() as bool;myIItemStack.isImmutable();
Return Type:
bool
// IItemStack.isMutable as boolmyIItemStack.isMutable
Return Type:
bool
// IItemStack.isMutable() as bool;myIItemStack.isMutable();
Return Type:
bool
// IItemStack.items as IItemStack[]myIItemStack.items
Return Type:
IItemStack[]
// IItemStack.matches(stack as IItemStack) as bool;myIItemStack.matches(<item:minecraft:iron_ingot>);
Parameters:
Return Type:
bool
// IItemStack.maxDamage as intmyIItemStack.maxDamage
Return Type:
int
Setting the damage to
0
will make the item unbreakable.// IItemStack.maxDamage = (newMaxDamage as int);myIItemStack.maxDamage = myInt;
Parameters:
newMaxDamage: int
Type: int
- The new max damage of the ItemStack // IItemStack.maxStackSize as intmyIItemStack.maxStackSize
Return Type:
int
// IItemStack.maxStackSize = (newMaxStackSize as int);myIItemStack.maxStackSize = myInt;
Parameters:
newMaxStackSize: int
Type: int
- The new max stack size of the Item. Returns: Max stack size of the Item.
// IItemStack.maxStackSize() as int;myIItemStack.maxStackSize();
Return Type:
int
// IItemStack.maxStackSize(newMaxStackSize as int);myIItemStack.maxStackSize(16);
Parameters:
newMaxStackSize: int
Type: int
- The new max stack size of the Item. // IItemStack.modifyShiftTooltip(shiftedFunction as ITooltipFunction, unshiftedFunction as ITooltipFunction = null);myIItemStack.modifyShiftTooltip(myITooltipFunction, myITooltipFunction);
Parameters:
shiftedFunction: ITooltipFunction
Type: ITooltipFunction
// IItemStack.modifyTooltip(function as ITooltipFunction);myIItemStack.modifyTooltip(myITooltipFunction);
Parameters:
function: ITooltipFunction
Type: ITooltipFunction
// IItemStack.mul(amount as int) as IIngredientWithAmount;myIItemStack.mul(myInt);
Parameters:
amount: int
Type: int
Return Type:
IIngredientWithAmount
// IItemStack.only(condition as IIngredientCondition<IIngredient>) as IIngredientConditioned<IIngredient>;myIItemStack.only(myIIngredientCondition);
Parameters:
condition: IIngredientCondition<IIngredient>
Type: IIngredientCondition<IIngredient>
Return Type:
IngredientConditioned<IIngredient>
// IItemStack.onlyDamaged() as IIngredientConditioned<IIngredient>;myIItemStack.onlyDamaged();
Return Type:
IngredientConditioned<IIngredient>
// IItemStack.onlyDamagedAtLeast(minDamage as int) as IIngredientConditioned<IIngredient>;myIItemStack.onlyDamagedAtLeast(myInt);
Parameters:
minDamage: int
Type: int
Return Type:
IngredientConditioned<IIngredient>
// IItemStack.onlyDamagedAtMost(maxDamage as int) as IIngredientConditioned<IIngredient>;myIItemStack.onlyDamagedAtMost(myInt);
Parameters:
maxDamage: int
Type: int
Return Type:
IngredientConditioned<IIngredient>
// IItemStack.onlyIf(uid as string, function as function(t as IItemStack) as bool = null) as IIngredientConditioned<IIngredient>;myIItemStack.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>
// IItemStack.owner as stringmyIItemStack.owner
Return Type:
string
// IItemStack.percent(percentage as double) as Percentaged<IItemStack>;myIItemStack.percent(myDouble);
Parameters:
percentage: double
Type: double
Return Type:
Percentaged<IItemStack>
// IItemStack.rarity as RaritymyIItemStack.rarity
Return Type:
Rarity
Returns: Rarity of the Item.
// IItemStack.rarity() as Rarity;myIItemStack.rarity();
Return Type:
Rarity
// IItemStack.registryName as ResourceLocationmyIItemStack.registryName
Return Type:
ResourceLocation
Returns: This itemStack if it is mutable, a new one with the enchantment removed otherwise
// IItemStack.removeEnchantment(enchantment as Enchantment) as IItemStack;myIItemStack.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.
// IItemStack.removeGlobalAttribute(attribute as Attribute, slotTypes as EquipmentSlot[]);myIItemStack.removeGlobalAttribute(<attribute:minecraft:generic.attack_damage>, [<constant:minecraft:equipmentslot:chest>]);
Parameters:
// IItemStack.removeGlobalAttributeModifier(uuid as string, slotTypes as EquipmentSlot[]);myIItemStack.removeGlobalAttributeModifier("8c1b5535-9f79-448b-87ae-52d81480aaa3", [<constant:minecraft:equipmentslot:chest>]);
Parameters:
uuid: string
Type: string
- The unique id of the AttributeModifier to remove. // IItemStack.removeGlobalAttributeModifier(uuid as UUID, slotTypes as EquipmentSlot[]);myIItemStack.removeGlobalAttributeModifier(IItemStack.BASE_ATTACK_DAMAGE_UUID, [<constant:minecraft:equipmentslot:chest>]);
Parameters:
uuid: UUID
Type: UUID
- The unique id of the AttributeModifier to remove. // IItemStack.removeTooltip(regex as string);myIItemStack.removeTooltip(myString);
Parameters:
regex: string
Type: string
// IItemStack.resetHoverName();myIItemStack.resetHoverName();
// IItemStack.reuse() as IIngredientTransformed<IIngredient>;myIItemStack.reuse();
Return Type:
IIngredientTransformed<IIngredient>
Returns: This IItemStack if mutable, a new one with the new amount otherwise.
// IItemStack.shrink(amount as int = 1) as IItemStack;myIItemStack.shrink(2);
Parameters:
amount: int
(optional) Type: int
- The amount to shrink by.
Default Value: 1
Return Type:
IItemStack
// IItemStack.stackable as boolmyIItemStack.stackable
Return Type:
bool
// IItemStack.tag as IDatamyIItemStack.tag
Return Type:
IData
// IItemStack.transform(transformer as IIngredientTransformer<IIngredient>) as IIngredientTransformed<IIngredient>;myIItemStack.transform(myIIngredientTransformer);
Parameters:
transformer: IIngredientTransformer<IIngredient>
Type: IIngredientTransformer<IIngredient>
Return Type:
IIngredientTransformed<IIngredient>
// IItemStack.transformCustom(uid as string, function as function(r as IItemStack) as IItemStack = null) as IIngredientTransformed<IIngredient>;myIItemStack.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>
// IItemStack.transformDamage(amount as int = 1) as IIngredientTransformed<IIngredient>;myIItemStack.transformDamage(myInt);
Parameters:
amount: int
(optional) Type: int
Default Value: 1
Return Type:
IIngredientTransformed<IIngredient>
// IItemStack.transformReplace(replaceWith as IItemStack) as IIngredientTransformed<IIngredient>;myIItemStack.transformReplace(myIItemStack);
Parameters:
replaceWith: IItemStack
Type: IItemStack
Return Type:
IIngredientTransformed<IIngredient>
// IItemStack.useDuration as intmyIItemStack.useDuration
Return Type:
int
// IItemStack.useOnRelease as boolmyIItemStack.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).// IItemStack.withAttributeModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as IItemStack;myIItemStack.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).// IItemStack.withAttributeModifier(attribute as Attribute, uuid as UUID, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as IItemStack;myIItemStack.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).// IItemStack.withAttributeModifier(attribute as Attribute, name as string, value as double, operation as Operation, slotTypes as EquipmentSlot[], preserveDefaults as bool = false) as IItemStack;myIItemStack.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
// IItemStack.withDamage(damage as int) as IItemStack;myIItemStack.withDamage(10);
Parameters:
damage: int
Type: int
- the new damage value
Return Type:
IItemStack
// IItemStack.withDisplayName(name as Component) as IItemStack;myIItemStack.withDisplayName("totally not dirt");
Return Type:
IItemStack
Returns: This itemStack if it is mutable, a new one with the enchantment added otherwise
// IItemStack.withEnchantment(enchantment as Enchantment, level as int = 1) as IItemStack;myIItemStack.withEnchantment(<enchantment:minecraft:riptide>, 2);
Parameters:
level: int
(optional) Type: int
- The level of the enchantment
Default Value: 1
Return Type:
IItemStack
// IItemStack.withLore(lore as Component[]) as IItemStack;myIItemStack.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
// IItemStack.withoutTag() as IItemStack;myIItemStack.withoutTag();
Return Type:
IItemStack
Returns: This itemStack if it is mutable, a new one with the changed property otherwise
// IItemStack.withTag(tag as MapData) as IItemStack;myIItemStack.withTag({Display: {lore: ["Hello"]}});
Return Type:
IItemStack