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