Interface IItemExtension

All Known Implementing Classes:
net.minecraft.world.item.BlockItem, CustomFluidContainerTest.CustomFluidContainer, CustomItemDisplayContextTest.ItemHangerItem, CustomShieldTest.CustomShieldItem, CustomTooltipTest.CustomItemWithTooltip, net.minecraft.world.item.Item, ItemUseAnimationTest.ThingItem, MayFlyAttributeTest.InvertedTelescope, StopUsingItemTest.InvertedTelescope

public interface IItemExtension
  • Method Summary

    Modifier and Type
    Method
    Description
    default net.minecraft.world.item.ItemStack
    applyEnchantments(net.minecraft.world.item.ItemStack stack, List<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantments)
    Handles enchanting an item (i.e. in the enchanting table), potentially transforming it to a new item in the process.
    default boolean
    canBeHurtBy(net.minecraft.world.item.ItemStack stack, net.minecraft.world.damagesource.DamageSource source)
    Returns false to make item entity immune to the damage..
    default boolean
    canContinueUsing(net.minecraft.world.item.ItemStack oldStack, net.minecraft.world.item.ItemStack newStack)
    Called while an item is in 'active' use to determine if usage should continue.
    default boolean
    canEquip(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot armorType, net.minecraft.world.entity.LivingEntity entity)
    Determines if the specific ItemStack can be placed in the specified armor slot, for the entity.
    default boolean
    canGrindstoneRepair(net.minecraft.world.item.ItemStack stack)
    Returns true if the given ItemStack can be put into a grindstone to be repaired and/or stripped of its enchantments.
    default boolean
    canPerformAction(net.minecraft.world.item.ItemStack stack, ItemAbility itemAbility)
    Queries if an item can perform the given action.
    default boolean
    canWalkOnPowderedSnow(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity wearer)
    Called by the powdered snow block to check if a living entity wearing this can walk on the snow, granting the same behavior as leather boots.
    default @Nullable net.minecraft.world.entity.Entity
    createEntity(net.minecraft.world.level.Level level, net.minecraft.world.entity.Entity location, net.minecraft.world.item.ItemStack stack)
    This function should return a new entity to replace the dropped item.
    default <T extends net.minecraft.world.entity.LivingEntity>
    int
    damageItem(net.minecraft.world.item.ItemStack stack, int amount, T entity, Consumer<net.minecraft.world.item.Item> onBroken)
    Reduce the durability of this item by the amount given.
    default boolean
    doesSneakBypassUse(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
    Should this item, when held, allow sneak-clicks to pass through to the underlying block?
    default net.minecraft.world.item.enchantment.ItemEnchantments
    getAllEnchantments(net.minecraft.world.item.ItemStack stack, net.minecraft.core.HolderLookup.RegistryLookup<net.minecraft.world.item.enchantment.Enchantment> lookup)
    Gets a map of all enchantments present on the stack.
    default int
    getBurnTime(net.minecraft.world.item.ItemStack itemStack, @Nullable net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.level.block.entity.FuelValues fuelValues)
     
    default net.minecraft.world.item.ItemStack
    getCraftingRemainder(net.minecraft.world.item.ItemStack itemStack)
    ItemStack sensitive version of Item.getCraftingRemainder() ()}.
    default @Nullable String
    getCreatorModId(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.world.item.ItemStack itemStack)
    Called to get the Mod ID of the mod that *created* the ItemStack, instead of the real Mod ID that *registered* it.
    default int
    getDamage(net.minecraft.world.item.ItemStack stack)
    Return the itemDamage represented by this ItemStack.
    default net.minecraft.world.item.component.ItemAttributeModifiers
    getDefaultAttributeModifiers(net.minecraft.world.item.ItemStack stack)
    ItemStack sensitive version of getDefaultAttributeModifiers.
    default int
    getEnchantmentLevel(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    Gets the level of the enchantment currently present on the stack.
    default int
    getEntityLifespan(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level level)
    Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.
    default @Nullable net.minecraft.world.entity.EquipmentSlot
    getEquipmentSlot(net.minecraft.world.item.ItemStack stack)
    Override this to set a non-default armor slot for an ItemStack, but do not use this to get the armor slot of said stack; for that, use LivingEntity.getEquipmentSlotForItem(ItemStack)..
    default net.minecraft.network.chat.Component
    getHighlightTip(net.minecraft.world.item.ItemStack item, net.minecraft.network.chat.Component displayName)
    Allow the item one last chance to modify its name used for the tool highlight useful for adding something extra that can't be removed by a user in the displayed name, such as a mode of operation.
    default int
    getMaxDamage(net.minecraft.world.item.ItemStack stack)
    Return the maxDamage for this ItemStack.
    default int
    getMaxStackSize(net.minecraft.world.item.ItemStack stack)
    Gets the maximum number of items that this stack should be able to hold.
    default net.minecraft.world.phys.AABB
    getSweepHitBox(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target)
    Get a bounding box (AABB) of a sweep attack.
    default float
    getXpRepairRatio(net.minecraft.world.item.ItemStack stack)
    Determines the amount of durability the mending enchantment will repair, on average, per 0.5 points of experience.
    default boolean
    hasCustomEntity(net.minecraft.world.item.ItemStack stack)
    Determines if this Item has a special entity for when they are in the world.
    default boolean
    isBookEnchantable(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemStack book)
    Allow or forbid the specific book/item combination as an anvil enchant
    boolean
    isCombineRepairable(net.minecraft.world.item.ItemStack stack)
    Determines if an item is repairable by combining, used by Repair recipes and Grindstone.
    default boolean
    isDamageable(net.minecraft.world.item.ItemStack stack)
    Used to test if this item can be damaged, but with the ItemStack in question.
    default boolean
    isDamaged(net.minecraft.world.item.ItemStack stack)
    Return if this itemstack is damaged.
    default boolean
    isGazeDisguise(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, @Nullable net.minecraft.world.entity.LivingEntity entity)
    Whether this Item can be used to hide player's gaze from Endermen and Creakings.
    default boolean
    isNotReplaceableByPickAction(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, int inventorySlot)
    Whether the given ItemStack should be excluded (if possible) when selecting the target hotbar slot of a "pick" action.
    default boolean
    isPiglinCurrency(net.minecraft.world.item.ItemStack stack)
    Called by Piglins when checking to see if they will give an item or something in exchange for this item.
    default boolean
    isPrimaryItemFor(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    Checks if an item should be treated as a primary item for a given enchantment.
    default boolean
    makesPiglinsNeutral(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity wearer)
    Called by Piglins to check if a given item prevents hostility on sight.
    default void
    onAnimalArmorTick(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, net.minecraft.world.entity.Mob horse)
    Called every tick when this item is equipped as an armor item by an animal.
    default void
    onDestroyed(net.minecraft.world.entity.item.ItemEntity itemEntity, net.minecraft.world.damagesource.DamageSource damageSource)
    Called when an item entity for this stack is destroyed.
    default boolean
    onDroppedByPlayer(net.minecraft.world.item.ItemStack item, net.minecraft.world.entity.player.Player player)
    Called when a player drops the item into the world, returning false from this will prevent the item from being removed from the players inventory and spawning in the world
    default boolean
    onEntityItemUpdate(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.item.ItemEntity entity)
    Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner control over the update of the item without having to write a subclass.
    default boolean
    onEntitySwing(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.InteractionHand hand)
    Called when a entity tries to play the 'swing' animation.
    default net.minecraft.world.InteractionResult
    onItemUseFirst(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.context.UseOnContext context)
    This is called when the item is used, before the block is activated.
    default boolean
    onLeftClickEntity(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity)
    Called when the player Left Clicks (attacks) an entity.
    default void
    onStopUsing(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int count)
    Called when an entity stops using an item for any reason, notably when selecting another item without releasing or finishing.
    private net.minecraft.world.item.Item
     
    default void
    setDamage(net.minecraft.world.item.ItemStack stack, int damage)
    Set the damage for this itemstack.
    default boolean
    shouldCauseBlockBreakReset(net.minecraft.world.item.ItemStack oldStack, net.minecraft.world.item.ItemStack newStack)
    Called when the player is mining a block and the item in his hand changes.
    default boolean
    shouldCauseReequipAnimation(net.minecraft.world.item.ItemStack oldStack, net.minecraft.world.item.ItemStack newStack, boolean slotChanged)
    Determine if the player switching between these two item stacks
    default boolean
    supportsEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    Checks if the provided enchantment is applicable to the passed item stack.
  • Method Details

    • self

      private net.minecraft.world.item.Item self()
    • getDefaultAttributeModifiers

      default net.minecraft.world.item.component.ItemAttributeModifiers getDefaultAttributeModifiers(net.minecraft.world.item.ItemStack stack)
      ItemStack sensitive version of getDefaultAttributeModifiers. Used when a stack has no DataComponents.ATTRIBUTE_MODIFIERS component.
      See Also:
    • onDroppedByPlayer

      default boolean onDroppedByPlayer(net.minecraft.world.item.ItemStack item, net.minecraft.world.entity.player.Player player)
      Called when a player drops the item into the world, returning false from this will prevent the item from being removed from the players inventory and spawning in the world
      Parameters:
      item - The item stack, before the item is removed.
      player - The player that dropped the item
    • getHighlightTip

      default net.minecraft.network.chat.Component getHighlightTip(net.minecraft.world.item.ItemStack item, net.minecraft.network.chat.Component displayName)
      Allow the item one last chance to modify its name used for the tool highlight useful for adding something extra that can't be removed by a user in the displayed name, such as a mode of operation.
      Parameters:
      item - the ItemStack for the item.
      displayName - the name that will be displayed unless it is changed in this method.
    • onItemUseFirst

      default net.minecraft.world.InteractionResult onItemUseFirst(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.context.UseOnContext context)
      This is called when the item is used, before the block is activated.
      Returns:
      Return PASS to allow vanilla handling, any other to skip normal code.
    • isPiglinCurrency

      default boolean isPiglinCurrency(net.minecraft.world.item.ItemStack stack)
      Called by Piglins when checking to see if they will give an item or something in exchange for this item.
      Returns:
      True if this item can be used as "currency" by piglins
    • makesPiglinsNeutral

      default boolean makesPiglinsNeutral(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity wearer)
      Called by Piglins to check if a given item prevents hostility on sight. If this is true the Piglins will be neutral to the entity wearing this item, and will not attack on sight. Note: This does not prevent Piglins from becoming hostile due to other actions, nor does it make Piglins that are already hostile stop being so.
      Parameters:
      wearer - The entity wearing this ItemStack
      Returns:
      True if piglins are neutral to players wearing this item in an armor slot
    • isCombineRepairable

      boolean isCombineRepairable(net.minecraft.world.item.ItemStack stack)
      Determines if an item is repairable by combining, used by Repair recipes and Grindstone.
      Returns:
      True if repairable by combining
    • getXpRepairRatio

      default float getXpRepairRatio(net.minecraft.world.item.ItemStack stack)
      Determines the amount of durability the mending enchantment will repair, on average, per 0.5 points of experience.
    • onStopUsing

      default void onStopUsing(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int count)
      Called when an entity stops using an item for any reason, notably when selecting another item without releasing or finishing. This method is called in addition to any other hooks called when an item is finished using; when another hook is also called it will be called before this method. Note that if you break an item while using it (that is, it becomes empty without swapping the stack instance), this hook may not be called on the serverside as you are technically still using the empty item (thus this hook is called on air instead). It is necessary to call LivingEntity.stopUsingItem() as part of your ItemStack.hurtAndBreak(int, ServerLevel, LivingEntity, Consumer) callback to prevent this issue. For most uses, you likely want one of the following:
      • Item.finishUsingItem(ItemStack, Level, LivingEntity) for when the player releases and enough ticks have passed
      • Item.releaseUsing(ItemStack, Level, LivingEntity, int) (ItemStack, Level, LivingEntity)} for when the player releases but the full timer has not passed
      Parameters:
      stack - The Item being used
      entity - The entity using the item, typically a player
      count - The amount of time in tick the item has been used for continuously
    • onLeftClickEntity

      default boolean onLeftClickEntity(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity)
      Called when the player Left Clicks (attacks) an entity. Processed before damage is done, if return value is true further processing is canceled and the entity is not attacked.
      Parameters:
      stack - The Item being used
      player - The player that is attacking
      entity - The entity being attacked
      Returns:
      True to cancel the rest of the interaction.
    • getCraftingRemainder

      default net.minecraft.world.item.ItemStack getCraftingRemainder(net.minecraft.world.item.ItemStack itemStack)
      ItemStack sensitive version of Item.getCraftingRemainder() ()}. Returns a full ItemStack instance of the result.
      Parameters:
      itemStack - The current ItemStack
      Returns:
      The resulting ItemStack
    • getEntityLifespan

      default int getEntityLifespan(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level level)
      Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem. This is in ticks, standard result is 6000, or 5 mins.
      Parameters:
      itemStack - The current ItemStack
      level - The level the entity is in
      Returns:
      The normal lifespan in ticks.
    • hasCustomEntity

      default boolean hasCustomEntity(net.minecraft.world.item.ItemStack stack)
      Determines if this Item has a special entity for when they are in the world. Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
      Parameters:
      stack - The current item stack
      Returns:
      True of the item has a custom entity, If true, Item#createCustomEntity will be called
    • createEntity

      @Nullable default @Nullable net.minecraft.world.entity.Entity createEntity(net.minecraft.world.level.Level level, net.minecraft.world.entity.Entity location, net.minecraft.world.item.ItemStack stack)
      This function should return a new entity to replace the dropped item. Returning null here will not kill the EntityItem and will leave it to function normally. Called when the item it placed in a level.
      Parameters:
      level - The level object
      location - The EntityItem object, useful for getting the position of the entity
      stack - The current item stack
      Returns:
      A new Entity object to spawn or null
    • onEntityItemUpdate

      default boolean onEntityItemUpdate(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.item.ItemEntity entity)
      Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner control over the update of the item without having to write a subclass.
      Parameters:
      entity - The entity Item
      Returns:
      Return true to skip any further update code.
    • doesSneakBypassUse

      default boolean doesSneakBypassUse(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
      Should this item, when held, allow sneak-clicks to pass through to the underlying block?
      Parameters:
      level - The level
      pos - Block position in level
      player - The Player that is wielding the item
    • canEquip

      default boolean canEquip(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot armorType, net.minecraft.world.entity.LivingEntity entity)
      Determines if the specific ItemStack can be placed in the specified armor slot, for the entity.
      Parameters:
      stack - The ItemStack
      armorType - Armor slot to be verified.
      entity - The entity trying to equip the armor
      Returns:
      True if the given ItemStack can be inserted in the slot
    • getEquipmentSlot

      @Nullable default @Nullable net.minecraft.world.entity.EquipmentSlot getEquipmentSlot(net.minecraft.world.item.ItemStack stack)
      Override this to set a non-default armor slot for an ItemStack, but do not use this to get the armor slot of said stack; for that, use LivingEntity.getEquipmentSlotForItem(ItemStack)..
      Parameters:
      stack - the ItemStack
      Returns:
      the armor slot of the ItemStack, or null to let the default vanilla logic as per LivingEntity.getSlotForItemStack(stack) decide
    • isBookEnchantable

      default boolean isBookEnchantable(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemStack book)
      Allow or forbid the specific book/item combination as an anvil enchant
      Parameters:
      stack - The item
      book - The book
      Returns:
      if the enchantment is allowed
    • onEntitySwing

      default boolean onEntitySwing(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.InteractionHand hand)
      Called when a entity tries to play the 'swing' animation.
      Parameters:
      entity - The entity swinging the item.
      Returns:
      True to cancel any further processing by LivingEntity
    • getDamage

      default int getDamage(net.minecraft.world.item.ItemStack stack)
      Return the itemDamage represented by this ItemStack. Defaults to the Damage entry in the stack NBT, but can be overridden here for other sources.
      Parameters:
      stack - The itemstack that is damaged
      Returns:
      the damage value
    • getMaxDamage

      default int getMaxDamage(net.minecraft.world.item.ItemStack stack)
      Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item, but can be overridden here for other sources such as NBT.
      Parameters:
      stack - The itemstack that is damaged
      Returns:
      the damage value
    • isDamaged

      default boolean isDamaged(net.minecraft.world.item.ItemStack stack)
      Return if this itemstack is damaged. Note only called if ItemStack.isDamageableItem() is true.
      Parameters:
      stack - the stack
      Returns:
      if the stack is damaged
    • setDamage

      default void setDamage(net.minecraft.world.item.ItemStack stack, int damage)
      Set the damage for this itemstack. Note, this method is responsible for zero checking.
      Parameters:
      stack - the stack
      damage - the new damage value
    • canPerformAction

      default boolean canPerformAction(net.minecraft.world.item.ItemStack stack, ItemAbility itemAbility)
      Queries if an item can perform the given action. See ItemAbilities for a description of each stock action
      Parameters:
      stack - The stack being used
      itemAbility - The action being queried
      Returns:
      True if the stack can perform the action
    • getMaxStackSize

      default int getMaxStackSize(net.minecraft.world.item.ItemStack stack)
      Gets the maximum number of items that this stack should be able to hold.
      Parameters:
      stack - The ItemStack
      Returns:
      The maximum size this item can be stacked to
    • isPrimaryItemFor

      @OverrideOnly default boolean isPrimaryItemFor(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      Checks if an item should be treated as a primary item for a given enchantment.

      Primary items are those that are able to receive the enchantment during enchanting, either from the enchantment table or other random enchantment mechanisms. As a special case, books are primary items for every enchantment.

      Other application mechanisms, such as the anvil, check supportsEnchantment(ItemStack, Holder) instead. If you want those mechanisms to be able to apply an enchantment, you will need to add your item to the relevant tag or override that method.

      Parameters:
      stack - the item stack to be enchanted
      enchantment - the enchantment to be applied
      Returns:
      true if this item should be treated as a primary item for the enchantment
      See Also:
    • supportsEnchantment

      @OverrideOnly default boolean supportsEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      Checks if the provided enchantment is applicable to the passed item stack.

      By default, this checks if the Enchantment.EnchantmentDefinition.supportedItems() contains this item, special casing enchanted books as they may receive any enchantment.

      Overriding this method allows for dynamic logic that would not be possible using the tag system.

      Parameters:
      stack - the item stack to be enchanted
      enchantment - the enchantment to be applied
      Returns:
      true if this item can accept the enchantment
      See Also:
    • getEnchantmentLevel

      @OverrideOnly default int getEnchantmentLevel(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      Gets the level of the enchantment currently present on the stack. By default, returns the enchantment level present in NBT. Most enchantment implementations rely upon this method. The returned value must be the same as getting the enchantment from getAllEnchantments(net.minecraft.world.item.ItemStack, net.minecraft.core.HolderLookup.RegistryLookup<net.minecraft.world.item.enchantment.Enchantment>)
      Parameters:
      stack - The item stack being checked
      enchantment - The enchantment being checked for
      Returns:
      Level of the enchantment, or 0 if not present
      See Also:
    • getAllEnchantments

      @OverrideOnly default net.minecraft.world.item.enchantment.ItemEnchantments getAllEnchantments(net.minecraft.world.item.ItemStack stack, net.minecraft.core.HolderLookup.RegistryLookup<net.minecraft.world.item.enchantment.Enchantment> lookup)
      Gets a map of all enchantments present on the stack. By default, returns the enchantments present in NBT. Used in several places in code including armor enchantment hooks. The returned value(s) must have the same level as getEnchantmentLevel(net.minecraft.world.item.ItemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>).
      Parameters:
      stack - The item stack being checked
      lookup - A registry lookup, used to resolve enchantment Holders.
      Returns:
      Map of all enchantments on the stack, empty if no enchantments are present
      See Also:
    • shouldCauseReequipAnimation

      default boolean shouldCauseReequipAnimation(net.minecraft.world.item.ItemStack oldStack, net.minecraft.world.item.ItemStack newStack, boolean slotChanged)
      Determine if the player switching between these two item stacks
      Parameters:
      oldStack - The old stack that was equipped
      newStack - The new stack
      slotChanged - If the current equipped slot was changed, Vanilla does not play the animation if you switch between two slots that hold the exact same item.
      Returns:
      True to play the item change animation
    • shouldCauseBlockBreakReset

      default boolean shouldCauseBlockBreakReset(net.minecraft.world.item.ItemStack oldStack, net.minecraft.world.item.ItemStack newStack)
      Called when the player is mining a block and the item in his hand changes. Allows to not reset blockbreaking if only NBT or similar changes.
      Parameters:
      oldStack - The old stack that was used for mining. Item in players main hand
      newStack - The new stack
      Returns:
      True to reset block break progress
    • canContinueUsing

      default boolean canContinueUsing(net.minecraft.world.item.ItemStack oldStack, net.minecraft.world.item.ItemStack newStack)
      Called while an item is in 'active' use to determine if usage should continue. Allows items to continue being used while sustaining damage, for example.
      Parameters:
      oldStack - the previous 'active' stack
      newStack - the stack currently in the active hand
      Returns:
      true to set the new stack to active and continue using it
    • getCreatorModId

      @Nullable default @Nullable String getCreatorModId(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.world.item.ItemStack itemStack)
      Called to get the Mod ID of the mod that *created* the ItemStack, instead of the real Mod ID that *registered* it. For example the Forge Universal Bucket creates a subitem for each modded fluid, and it returns the modded fluid's Mod ID here. Mods that register subitems for other mods can override this. Informational mods can call it to show the mod that created the item.
      Parameters:
      itemStack - the ItemStack to check
      Returns:
      the Mod ID for the ItemStack, or null when there is no specially associated mod and Registry.getKey(Object) would return null.
    • getBurnTime

      @OverrideOnly default int getBurnTime(net.minecraft.world.item.ItemStack itemStack, @Nullable @Nullable net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.level.block.entity.FuelValues fuelValues)
      Returns:
      the fuel burn time for this item stack in a furnace. Return 0 to make it not act as a fuel.
    • onAnimalArmorTick

      @OverrideOnly default void onAnimalArmorTick(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, net.minecraft.world.entity.Mob horse)
      Called every tick when this item is equipped as an armor item by an animal.
      Parameters:
      stack - The armor stack
      level - The level the horse is in
      horse - The horse wearing this item
    • damageItem

      default <T extends net.minecraft.world.entity.LivingEntity> int damageItem(net.minecraft.world.item.ItemStack stack, int amount, @Nullable T entity, Consumer<net.minecraft.world.item.Item> onBroken)
      Reduce the durability of this item by the amount given. This can be used to e.g. consume power from NBT before durability.
      Parameters:
      stack - The itemstack to damage
      amount - The amount to damage
      entity - The entity damaging the item
      onBroken - The on-broken callback from vanilla
      Returns:
      The amount of damage to pass to the vanilla logic
    • onDestroyed

      default void onDestroyed(net.minecraft.world.entity.item.ItemEntity itemEntity, net.minecraft.world.damagesource.DamageSource damageSource)
      Called when an item entity for this stack is destroyed. Note: The ItemStack can be retrieved from the item entity.
      Parameters:
      itemEntity - The item entity that was destroyed.
      damageSource - Damage source that caused the item entity to "die".
    • isGazeDisguise

      default boolean isGazeDisguise(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, @Nullable @Nullable net.minecraft.world.entity.LivingEntity entity)
      Whether this Item can be used to hide player's gaze from Endermen and Creakings.
      Parameters:
      stack - the ItemStack
      player - The player watching the entity
      entity - The entity the player is looking at, may be null
      Returns:
      true if this Item hides the player's gaze from the given entity
    • canWalkOnPowderedSnow

      default boolean canWalkOnPowderedSnow(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity wearer)
      Called by the powdered snow block to check if a living entity wearing this can walk on the snow, granting the same behavior as leather boots. Only affects items worn in the boots slot.
      Parameters:
      stack - Stack instance
      wearer - The entity wearing this ItemStack
      Returns:
      True if the entity can walk on powdered snow
    • isDamageable

      default boolean isDamageable(net.minecraft.world.item.ItemStack stack)
      Used to test if this item can be damaged, but with the ItemStack in question. Please note that in some cases no ItemStack is available, so the stack-less method will be used.
      Parameters:
      stack - ItemStack in the Chest slot of the entity.
    • getSweepHitBox

      default net.minecraft.world.phys.AABB getSweepHitBox(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target)
      Get a bounding box (AABB) of a sweep attack.
      Parameters:
      stack - the stack held by the player.
      player - the performing the attack the attack.
      target - the entity targeted by the attack.
      Returns:
      the bounding box.
    • isNotReplaceableByPickAction

      default boolean isNotReplaceableByPickAction(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, int inventorySlot)
      Whether the given ItemStack should be excluded (if possible) when selecting the target hotbar slot of a "pick" action. By default, this returns true for enchanted stacks.
      Parameters:
      player - the player performing the picking
      inventorySlot - the inventory slot of the item being up for replacement
      Returns:
      true to leave this stack in the hotbar if possible
      See Also:
      • Inventory.getSuitableHotbarSlot()
    • canGrindstoneRepair

      default boolean canGrindstoneRepair(net.minecraft.world.item.ItemStack stack)
      Returns true if the given ItemStack can be put into a grindstone to be repaired and/or stripped of its enchantments.
      Returns:
      true if the given ItemStack can be put into a grindstone to be repaired and/or stripped of its enchantments
    • canBeHurtBy

      default boolean canBeHurtBy(net.minecraft.world.item.ItemStack stack, net.minecraft.world.damagesource.DamageSource source)
      Returns false to make item entity immune to the damage..
      Returns:
      false to make item entity immune to the damage.
    • applyEnchantments

      default net.minecraft.world.item.ItemStack applyEnchantments(net.minecraft.world.item.ItemStack stack, List<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantments)
      Handles enchanting an item (i.e. in the enchanting table), potentially transforming it to a new item in the process.

      Books use this functionality to transform themselves into enchanted books.

      Parameters:
      stack - The stack being enchanted.
      enchantments - The enchantments being applied.
      Returns:
      The newly-enchanted stack.