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