Interface IItemStack
- All Superinterfaces:
CommandStringDisplayable,IIngredient,IIngredientWithAmount
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault IDataasIData()default IIngredientWithAmountUsed implicitly when a machine can accept more than one item but you only provide one.default net.minecraft.world.level.ItemLikedefault net.minecraft.world.item.crafting.IngredientCreate a Vanilla ingredient matching this one.default Percentaged<IItemStack>copy()Creates a copydefault intGets the amount of Items in the ItemStackdefault Map<net.minecraft.world.entity.ai.attributes.Attribute,List<net.minecraft.world.entity.ai.attributes.AttributeModifier>> getAttributes(net.minecraft.world.entity.EquipmentSlot slotType) Gets the Attributes and the AttributeModifiers on this IItemStack for the given EquipmentSlotdefault intGets the base repair cost of the ItemStack, or 0 if no repair is defined.default intdefault intdefault net.minecraft.world.item.Itemdefault StringReturns the unlocalized Name of the Item in the ItemStackdefault net.minecraft.network.chat.ComponentGets the display name of the ItemStackdefault intgetEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantment enchantment) Gets the level of the given enchantment on the item.default net.minecraft.world.food.FoodPropertiesgetFood()default net.minecraft.network.chat.ComponentGets the hover name of the ItemStack.default net.minecraft.world.item.ItemStackdefault IItemStackThe backing ingredientnet.minecraft.world.item.ItemStackGets the internalItemStackfor this IItemStack.default intReturns the max damage of the ItemStack This is the max durability of the ItemStack.default intReturns the max stack size of the Item in the ItemStackdefault MapDataReturns the NBT tag attached to this ItemStack or makes a new tag.default StringgetOwner()Gets owning mod for the Item in this IItemStackdefault net.minecraft.world.item.RarityReturns the rarity of the Item in the ItemStackdefault net.minecraft.resources.ResourceLocationGets the registry name for the Item in this IItemStackdefault MapDatagetTag()Returns the NBT tag attached to this ItemStack.default intGets the use duration of the ItemStackdefault IItemStackgrow(int amount) Grows this IItemStack's stack size by the given amount, or 1 if no amount is given.default booleanReturns true if the ItemStack has a display name.default booleanhasFoil()Returns true if this ItemStack has a foil effect.default booleanhasTag()Returns true if this ItemStack has a Tagdefault booleanReturns if the ItemStack is damageable I.E Swords and tools are damageable, sticks are not.default booleanReturns if the ItemStack is damaged I.E a Swords that is no at full durability is damaged.default booleanisEdible()default booleanisEmpty()Returns if the ItemStack is emptydefault booleanCan this ItemStack be enchanted?default booleanIs this ItemStack enchanted?default booleanChecks if this IItemStack burns when thrown into fire / lava or damaged by fire.booleandefault booleandefault booleanReturns if the ItemStack can have an amount greater than 1 I.E Swords and tools are not stackable, sticks are.default booleanmatches(IItemStack stack, boolean ignoreDamage) Does the given stack match the ingredient?default Percentaged<IItemStack>percent(double percentage) default IItemStackremoveEnchantment(net.minecraft.world.item.enchantment.Enchantment enchantment) Removes the given enchantment from this IItemStack.default voidClears any custom name set for this ItemStackdefault IItemStacksetAmount(int amount) Sets the amount of the ItemStackdefault IItemStacksetEnchantments(Map<net.minecraft.world.item.enchantment.Enchantment, Integer> enchantments) Sets the enchantments on this IItemStack.default voidsetFireResistant(boolean fireResistant) Sets if this IItemStack is immune to fire / lava.default voidsetFood(net.minecraft.world.food.FoodProperties food) default voidsetMaxDamage(int newMaxDamage) Sets the max damage of the ItemStack.default voidsetMaxStackSize(int newMaxStackSize) Sets the max stacksize of the Item.default voidsetRarity(net.minecraft.world.item.Rarity newRarity) Sets the rarity of the Item.default IItemStackshrink(int amount) Shrinks this IItemStack's stack size by the given amount, or 1 if no amount is given.default booleanReturns true if this stack is considered a crossbow itemdefault IItemStackwithAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes, boolean preserveDefaults) Adds an AttributeModifier to this IItemStack.default IItemStackwithAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes, boolean preserveDefaults) Adds an AttributeModifier to this IItemStack using a specific UUID.default IItemStackwithAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, UUID uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes, boolean preserveDefaults) Adds an AttributeModifier to this IItemStack using a specific UUID.default IItemStackwithDamage(int damage) Sets the damage of the ItemStackdefault IItemStackwithDisplayName(net.minecraft.network.chat.Component name) Sets the display name of the ItemStackdefault IItemStackwithEnchantment(net.minecraft.world.item.enchantment.Enchantment enchantment, int level) Enchants this IItemStack with the given Enchantment.default IItemStackwithLore(net.minecraft.network.chat.Component... lore) Sets the lore of the ItemStackdefault IItemStackRemoves the tag from this ItemStack.default IItemStackSets the tag for the ItemStack.Methods inherited from interface com.blamejared.crafttweaker.api.ingredient.IIngredient
addGlobalAttributeModifier, addGlobalAttributeModifier, addGlobalAttributeModifier, addShiftTooltip, addTooltip, anyDamage, asMapData, clearTooltip, contains, getCommandString, getItems, getRemainingItem, matches, modifyShiftTooltip, modifyTooltip, mul, only, onlyDamaged, onlyDamagedAtLeast, onlyDamagedAtMost, onlyIf, or, removeGlobalAttribute, removeGlobalAttributeModifier, removeGlobalAttributeModifier, removeTooltip, reuse, setBurnTime, transform, transformCustom, transformDamage, transformReplace
-
Field Details
-
CRAFTTWEAKER_DATA_KEY
- See Also:
-
BASE_ATTACK_DAMAGE_UUID
-
BASE_ATTACK_SPEED_UUID
-
-
Method Details
-
copy
IItemStack copy()Creates a copy -
getRegistryName
default net.minecraft.resources.ResourceLocation getRegistryName()Gets the registry name for the Item in this IItemStack- Returns:
- registry name of the Item this IItemStack represents
-
getOwner
Gets owning mod for the Item in this IItemStack- Returns:
- owning mod of the Item this IItemStack represents
-
isEmpty
default boolean isEmpty()Returns if the ItemStack is empty- Specified by:
isEmptyin interfaceIIngredient- Returns:
- true if empty, false if not
-
getMaxStackSize
default int getMaxStackSize()Returns the max stack size of the Item in the ItemStack- Returns:
- Max stack size of the Item.
-
setMaxStackSize
default void setMaxStackSize(int newMaxStackSize) Sets the max stacksize of the Item.- Parameters:
newMaxStackSize- The new max stack size of the Item.- DocParam:
- newMaxStackSize 16
-
getRarity
default net.minecraft.world.item.Rarity getRarity()Returns the rarity of the Item in the ItemStack- Returns:
- Rarity of the Item.
-
setRarity
default void setRarity(net.minecraft.world.item.Rarity newRarity) Sets the rarity of the Item.- Parameters:
newRarity- The new rarity of the Item.- DocParam:
- newRarity Rarity.UNCOMMON
-
withLore
Sets the lore of the ItemStack- Parameters:
lore- the new Lore of the ItemStack.- DocParam:
- lore new crafttweaker.api.text.TextComponent("I am the lore I speak for the trees");
-
getDisplayName
default net.minecraft.network.chat.Component getDisplayName()Gets the display name of the ItemStack- Returns:
- formatted display name of the ItemStack.
-
withDisplayName
Sets the display name of the ItemStack- Parameters:
name- New name of the stack.- DocParam:
- name "totally not dirt"
-
getHoverName
default net.minecraft.network.chat.Component getHoverName()Gets the hover name of the ItemStack.This will give the raw name without the formatting that 'displayName' applies.
- Returns:
- The hover name of the ItemStack.
-
resetHoverName
default void resetHoverName()Clears any custom name set for this ItemStack -
hasDisplayName
default boolean hasDisplayName()Returns true if the ItemStack has a display name.- Returns:
- true if a display name is present on the ItemStack.
-
hasFoil
default boolean hasFoil()Returns true if this ItemStack has a foil effect. Foil is the glint / effect that is added to enchanted ItemStacks (and other items).- Returns:
- true if this ItemStack has a foil effect.
-
isEnchantable
default boolean isEnchantable()Can this ItemStack be enchanted?- Returns:
- true if this ItemStack can be enchanted.
-
isEnchanted
default boolean isEnchanted()Is this ItemStack enchanted?- Returns:
- true if this ItemStack is enchanted.
-
getBaseRepairCost
default int getBaseRepairCost()Gets the base repair cost of the ItemStack, or 0 if no repair is defined.- Returns:
- ItemStack repair cost or 0 if no repair is set.
-
getAmount
default int getAmount()Gets the amount of Items in the ItemStack- Specified by:
getAmountin interfaceIIngredientWithAmount- Returns:
- ItemStack's amount
-
setAmount
Sets the amount of the ItemStack- Parameters:
amount- new amount- DocParam:
- amount 3
-
grow
Grows this IItemStack's stack size by the given amount, or 1 if no amount is given.- Parameters:
amount- The amount to grow by.- Returns:
- This IItemStack if mutable, a new one with the new amount otherwise.
- DocParam:
- amount 2
-
shrink
Shrinks this IItemStack's stack size by the given amount, or 1 if no amount is given.- Parameters:
amount- The amount to shrink by.- Returns:
- This IItemStack if mutable, a new one with the new amount otherwise.
- DocParam:
- amount 2
-
isStackable
default boolean isStackable()Returns if the ItemStack can have an amount greater than 1 I.E Swords and tools are not stackable, sticks are.- Returns:
- true if this ItemStack can contain more than one item.
-
withDamage
Sets the damage of the ItemStack- Parameters:
damage- the new damage value- DocParam:
- damage 10
-
withAttributeModifier
default IItemStack withAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes, boolean preserveDefaults) Adds an AttributeModifier to this IItemStack using a specific UUID. 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).- Parameters:
uuid- The unique identifier of the modifier to replace.attribute- The Attribute of the modifier.name- The name of the modifier.value- The value of the modifier.operation- The operation of the modifier.slotTypes- What slots the modifier is valid for.preserveDefaults- Should the default Item Attribute Modifiers be preserved when adding this modifier.- DocParam:
- attribute <attribute:minecraft:generic.attack_damage>, uuid "8c1b5535-9f79-448b-87ae-52d81480aaa3", name "Extra Power", value 10, operation AttributeOperation.ADDITION, slotTypes [<constant:minecraft:equipmentslot:chest>], preserveDefaults true
-
withAttributeModifier
default IItemStack withAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, UUID uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes, boolean preserveDefaults) Adds an AttributeModifier to this IItemStack using a specific UUID. 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).- Parameters:
uuid- The unique identifier of the modifier to replace.attribute- The Attribute of the modifier.name- The name of the modifier.value- The value of the modifier.operation- The operation of the modifier.slotTypes- What slots the modifier is valid for.preserveDefaults- Should the default Item Attribute Modifiers be preserved when adding this modifier.- DocParam:
- attribute <attribute:minecraft:generic.attack_damage>, uuid "8c1b5535-9f79-448b-87ae-52d81480aaa3", name "Extra Power", value 10, operation AttributeOperation.ADDITION, slotTypes [<constant:minecraft:equipmentslot:chest>], preserveDefaults true
-
withAttributeModifier
default IItemStack withAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes, boolean preserveDefaults) Adds an AttributeModifier to this 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).- Parameters:
attribute- The Attribute of the modifier.name- The name of the modifier.value- The value of the modifier.operation- The operation of the modifier.slotTypes- What slots the modifier is valid for.preserveDefaults- Should the default Item Attribute Modifiers be preserved when adding this modifier.- DocParam:
- attribute <attribute:minecraft:generic.attack_damage>, name "Extra Power", value 10, operation AttributeOperation.ADDITION, slotTypes [<constant:minecraft:equipmentslot:chest>], preserveDefaults true
-
getAttributes
default Map<net.minecraft.world.entity.ai.attributes.Attribute,List<net.minecraft.world.entity.ai.attributes.AttributeModifier>> getAttributes(net.minecraft.world.entity.EquipmentSlot slotType) Gets the Attributes and the AttributeModifiers on this IItemStack for the given EquipmentSlot- Parameters:
slotType- The slot to get the Attributes for.- Returns:
- A Map of Attribute to a List of AttributeModifier for the given EquipmentSlot.
- DocParam:
- slotType <constant:minecraft:equipmentslot:chest>
-
isDamageableItem
default boolean isDamageableItem()Returns if the ItemStack is damageable I.E Swords and tools are damageable, sticks are not.- Returns:
- true if this ItemStack can take damage.
-
isDamaged
default boolean isDamaged()Returns if the ItemStack is damaged I.E a Swords that is no at full durability is damaged.- Returns:
- true if this ItemStack is damaged.
-
getMaxDamage
default int getMaxDamage()Returns the max damage of the ItemStack This is the max durability of the ItemStack.- Returns:
- The ItemStack's max durability.
-
setMaxDamage
default void setMaxDamage(int newMaxDamage) Sets the max damage of the ItemStack. Setting the damage to `0` will make the item unbreakable.- Parameters:
newMaxDamage- The new max damage of the ItemStack- DocParam:
- maxDamage 5
-
getDescriptionId
Returns the unlocalized Name of the Item in the ItemStack- Returns:
- the unlocalized name.
-
withTag
Sets the tag for the ItemStack.- Parameters:
tag- The tag to set.- Returns:
- This itemStack if it is mutable, a new one with the changed property otherwise
- DocParam:
- tag {Display: {lore: ["Hello"]}}
-
withoutTag
Removes the tag from this ItemStack.- Returns:
- This itemStack if it is mutable, a new one with the changed property otherwise
-
hasTag
default boolean hasTag()Returns true if this ItemStack has a Tag- Returns:
- true if tag is present.
-
getTag
Returns the NBT tag attached to this ItemStack.- Returns:
- MapData of the ItemStack NBT Tag, null if it doesn't exist.
-
getOrCreateTag
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.
-
matches
Description copied from interface:IIngredientDoes the given stack match the ingredient?- Specified by:
matchesin interfaceIIngredient- Parameters:
stack- The stack to checkignoreDamage- Should damage be checked?
-
getUseDuration
default int getUseDuration()Gets the use duration of the ItemStack- Returns:
- use duration
-
useOnRelease
default boolean useOnRelease()Returns true if this stack is considered a crossbow item- Returns:
- true if stack is a crossbow
-
getFood
default net.minecraft.world.food.FoodProperties getFood() -
setFood
default void setFood(net.minecraft.world.food.FoodProperties food) -
isEdible
default boolean isEdible() -
getBurnTime
default int getBurnTime() -
isFireResistant
default boolean isFireResistant()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.
-
setFireResistant
default void setFireResistant(boolean fireResistant) Sets if this IItemStack is immune to fire / lava. If true, the item will not burn when thrown into fire or lava.- Parameters:
fireResistant- Should the item be immune to fire.- DocParam:
- immuneToFire true
-
percent
-
asWeightedItemStack
-
getDefinition
default net.minecraft.world.item.Item getDefinition() -
asItemLike
default net.minecraft.world.level.ItemLike asItemLike() -
asMutable
IItemStack asMutable() -
asImmutable
IItemStack asImmutable() -
isImmutable
boolean isImmutable() -
isMutable
default boolean isMutable() -
getDamage
default int getDamage() -
getEnchantments
-
setEnchantments
default IItemStack setEnchantments(Map<net.minecraft.world.item.enchantment.Enchantment, Integer> enchantments) Sets the enchantments on this IItemStack.- Parameters:
enchantments- The new enchantments- Returns:
- This itemStack if it is mutable, a new one with the enchantments otherwise
-
getEnchantmentLevel
default int getEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantment enchantment) Gets the level of the given enchantment on the item. Returns 0 if the item doesn't have the given enchantment. -
withEnchantment
default IItemStack withEnchantment(net.minecraft.world.item.enchantment.Enchantment enchantment, int level) Enchants this IItemStack with the given Enchantment.- Parameters:
enchantment- The enchantment to add.level- The level of the enchantment- Returns:
- This itemStack if it is mutable, a new one with the enchantment added otherwise
- DocParam:
- enchantment <enchantment:minecraft:riptide>, level 2
-
removeEnchantment
Removes the given enchantment from this IItemStack.- Parameters:
enchantment- The enchantment to remove.- Returns:
- This itemStack if it is mutable, a new one with the enchantment removed otherwise
- DocParam:
- enchantment <enchantment:minecraft:riptide>
-
getInternal
net.minecraft.world.item.ItemStack getInternal()Gets the internalItemStackfor this IItemStack.- Returns:
- internal ItemStack
-
asVanillaIngredient
default net.minecraft.world.item.crafting.Ingredient asVanillaIngredient()Description copied from interface:IIngredientCreate a Vanilla ingredient matching this one.- Specified by:
asVanillaIngredientin interfaceIIngredient
-
asIData
- Specified by:
asIDatain interfaceIIngredient- Specified by:
asIDatain interfaceIIngredientWithAmount
-
getImmutableInternal
default net.minecraft.world.item.ItemStack getImmutableInternal() -
asIIngredientWithAmount
Description copied from interface:IIngredientUsed implicitly when a machine can accept more than one item but you only provide one.- Specified by:
asIIngredientWithAmountin interfaceIIngredient
-
getIngredient
Description copied from interface:IIngredientWithAmountThe backing ingredient- Specified by:
getIngredientin interfaceIIngredientWithAmount
-
modify
-