Interface IItemStack

All Superinterfaces:
CommandStringDisplayable, ComponentAccess<IItemStack>, net.minecraft.core.component.DataComponentHolder, IIngredient, IIngredientWithAmount

@ZenRegister public interface IItemStack extends IIngredient, IIngredientWithAmount, net.minecraft.core.component.DataComponentHolder, ComponentAccess<IItemStack>
  • Field Details

    • INGREDIENT_ID

      static final net.minecraft.resources.ResourceLocation INGREDIENT_ID
    • CODEC

      static final com.mojang.serialization.Codec<IItemStack> CODEC
    • STREAM_CODEC

      static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,IItemStack> STREAM_CODEC
    • CRAFTTWEAKER_DATA_KEY

      static final String CRAFTTWEAKER_DATA_KEY
      See Also:
    • BASE_ATTACK_DAMAGE_ID

      static final net.minecraft.resources.ResourceLocation BASE_ATTACK_DAMAGE_ID
    • BASE_ATTACK_SPEED_ID

      static final net.minecraft.resources.ResourceLocation BASE_ATTACK_SPEED_ID
  • Method Details

    • empty

      static IItemStack empty()
    • of

      static IItemStack of(net.minecraft.world.level.ItemLike item)
    • of

      static IItemStack of(net.minecraft.world.item.ItemStack stack)
    • of

      static IItemStack of(net.minecraft.world.item.ItemStack stack, IngredientConditions conditions, IngredientTransformers transformers)
    • of

      static IItemStack of(net.minecraft.world.item.ItemStack stack, boolean mutable)
    • ofMutable

      static IItemStack ofMutable(net.minecraft.world.item.ItemStack stack)
    • ofMutable

      static IItemStack ofMutable(net.minecraft.world.item.ItemStack stack, IngredientConditions conditions, IngredientTransformers transformers)
    • of

      static IItemStack of(net.minecraft.world.item.ItemStack stack, boolean mutable, IngredientConditions conditions, IngredientTransformers transformers)
    • 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

      default String 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:
      isEmpty in interface IIngredient
      Returns:
      true if empty, false if not
    • getPrototype

      default net.minecraft.core.component.DataComponentMap getPrototype()
    • getComponentsPatch

      default net.minecraft.core.component.DataComponentPatch getComponentsPatch()
    • with

      default <T> IItemStack with(net.minecraft.core.component.DataComponentType<T> type, T value)
    • without

      default <T> IItemStack without(net.minecraft.core.component.DataComponentType<T> type)
    • withoutComponents

      default IItemStack withoutComponents()
    • withJsonComponent

      default IItemStack withJsonComponent(net.minecraft.core.component.DataComponentType type, IData value)
    • withJsonComponents

      default IItemStack withJsonComponents(IData value)
    • update

      default <T, U> IItemStack update(net.minecraft.core.component.DataComponentType<T> type, T defaultValue, U data, BiFunction<T,U,T> operator)
    • update

      default <T> IItemStack update(net.minecraft.core.component.DataComponentType<T> type, T defaultValue, UnaryOperator<T> operator)
    • remove

      default <T> IItemStack remove(net.minecraft.core.component.DataComponentType<T> type)
    • applyComponents

      default IItemStack applyComponents(net.minecraft.core.component.DataComponentMap map)
    • applyComponents

      default IItemStack applyComponents(net.minecraft.core.component.DataComponentPatch patch)
    • applyComponentsAndValidate

      default IItemStack applyComponentsAndValidate(net.minecraft.core.component.DataComponentPatch patch)
    • getDisplayName

      default net.minecraft.network.chat.Component getDisplayName()
      Gets the display name of the ItemStack
      Returns:
      formatted display name of the ItemStack.
    • 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.
    • 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.
    • amount

      default int amount()
      Gets the amount of Items in the ItemStack
      Specified by:
      amount in interface IIngredientWithAmount
      Returns:
      ItemStack's amount
    • withAmount

      default IItemStack withAmount(int amount)
      Sets the amount of the ItemStack
      Parameters:
      amount - new amount
      DocParam:
      amount 3
    • grow

      default IItemStack grow(int amount)
      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

      default IItemStack shrink(int amount)
      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.
    • 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 invalid input: '<'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.
      Specified by:
      getMaxDamage in interface ComponentAccess<IItemStack>
      Returns:
      The ItemStack's max durability.
    • getDescriptionId

      default String getDescriptionId()
      Returns the unlocalized Name of the Item in the ItemStack
      Returns:
      the unlocalized name.
    • matches

      default boolean matches(IItemStack stack)
      Description copied from interface: IIngredient
      Does the given stack match the ingredient?
      Specified by:
      matches in interface IIngredient
      Parameters:
      stack - The stack to check
    • getCommandString

      default String getCommandString()
      Description copied from interface: IIngredient
      Returns the BEP to get this stack
      Specified by:
      getCommandString in interface CommandStringDisplayable
      Specified by:
      getCommandString in interface IIngredient
    • getUseDuration

      default int getUseDuration(net.minecraft.world.entity.LivingEntity entity)
      Gets the use duration of the ItemStack for the given entity
      Returns:
      use duration
      DocParam:
      entity entity
    • useOnRelease

      default boolean useOnRelease()
      Returns true if this stack is considered a crossbow item
      Returns:
      true if stack is a crossbow
    • getBurnTime

      default int getBurnTime()
    • getPotPatternId

      default net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.entity.DecoratedPotPattern> getPotPatternId()
    • getPotPattern

      default net.minecraft.world.level.block.entity.DecoratedPotPattern getPotPattern()
    • percent

      default Percentaged<IItemStack> percent(double percentage)
    • asWeightedItemStack

      default Percentaged<IItemStack> 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()
    • getInternal

      net.minecraft.world.item.ItemStack getInternal()
      Gets the internal ItemStack for this IItemStack.
      Returns:
      internal ItemStack
    • asVanillaIngredient

      default net.minecraft.world.item.crafting.Ingredient asVanillaIngredient()
      Description copied from interface: IIngredient
      Create a Vanilla ingredient matching this one.
      Specified by:
      asVanillaIngredient in interface IIngredient
    • getImmutableInternal

      default net.minecraft.world.item.ItemStack getImmutableInternal()
    • asIIngredientWithAmount

      default IIngredientWithAmount asIIngredientWithAmount()
      Description copied from interface: IIngredient
      Used implicitly when a machine can accept more than one item but you only provide one.
      Specified by:
      asIIngredientWithAmount in interface IIngredient
    • ingredient

      default IItemStack ingredient()
      Description copied from interface: IIngredientWithAmount
      The backing ingredient
      Specified by:
      ingredient in interface IIngredientWithAmount
    • asIData

      default IData asIData()
      Specified by:
      asIData in interface IIngredient
      Specified by:
      asIData in interface IIngredientWithAmount
    • transform

      default IIngredient transform(IIngredientTransformer transformer)
      Specified by:
      transform in interface IIngredient
    • condition

      default IIngredient condition(IIngredientCondition condition)
      Description copied from interface: IIngredient
      Use this if you already have the condition from another ingredient
      Specified by:
      condition in interface IIngredient
    • modify

      IItemStack modify(Consumer<net.minecraft.world.item.ItemStack> stackModifier)
    • modifyThis

      IItemStack modifyThis(Consumer<IItemStack> modifier)
    • getComponents

      @NotNull default @NotNull net.minecraft.core.component.DataComponentMap getComponents()
      Specified by:
      getComponents in interface net.minecraft.core.component.DataComponentHolder
    • get

      default <T> T get(@NotNull @NotNull net.minecraft.core.component.DataComponentType<? extends T> type)
      Specified by:
      get in interface net.minecraft.core.component.DataComponentHolder
    • getOrDefault

      @NotNull default <T> T getOrDefault(@NotNull @NotNull net.minecraft.core.component.DataComponentType<? extends T> type, @NotNull T value)
      Specified by:
      getOrDefault in interface net.minecraft.core.component.DataComponentHolder
    • has

      default boolean has(@NotNull @NotNull net.minecraft.core.component.DataComponentType<?> type)
      Specified by:
      has in interface net.minecraft.core.component.DataComponentHolder
    • _without

      default <U> IItemStack _without(net.minecraft.core.component.DataComponentType<U> componentType)
      Specified by:
      _without in interface ComponentAccess<IItemStack>
    • _with

      default <U> IItemStack _with(net.minecraft.core.component.DataComponentType<U> componentType, @Nullable U value)
      Specified by:
      _with in interface ComponentAccess<IItemStack>
    • _get

      default <U> U _get(net.minecraft.core.component.DataComponentType<? extends U> componentType)
      Specified by:
      _get in interface ComponentAccess<IItemStack>
    • _has

      default <U> boolean _has(net.minecraft.core.component.DataComponentType<U> componentType)
      Specified by:
      _has in interface ComponentAccess<IItemStack>