Class Item

java.lang.Object
net.minecraft.item.Item
All Implemented Interfaces:
ItemConvertible, ToggleableFeature
Direct Known Subclasses:
AirBlockItem, ArmorItem, ArmorStandItem, ArrowItem, BannerPatternItem, BlockItem, BoatItem, BoneMealItem, BookItem, BucketItem, BundleItem, ChorusFruitItem, CompassItem, DebugStickItem, DecorationItem, DiscFragmentItem, DyeItem, EggItem, ElytraItem, EnchantedBookItem, EnchantedGoldenAppleItem, EndCrystalItem, EnderEyeItem, EnderPearlItem, ExperienceBottleItem, FireChargeItem, FireworkRocketItem, FireworkStarItem, FishingRodItem, FlintAndSteelItem, GlassBottleItem, GoatHornItem, HoneyBottleItem, HoneycombItem, HorseArmorItem, KnowledgeBookItem, LeadItem, MilkBucketItem, MinecartItem, MusicDiscItem, NameTagItem, NetherStarItem, NetworkSyncedItem, OnAStickItem, PotionItem, RangedWeaponItem, SaddleItem, ShearsItem, ShieldItem, SnowballItem, SpawnEggItem, SpyglassItem, StewItem, SuspiciousStewItem, ToolItem, TridentItem, WritableBookItem, WrittenBookItem

public class Item extends Object implements ToggleableFeature, ItemConvertible
An item usable by players and other entities.

Like Block, this class handles logics for a type of item, and does not hold any data. Any data about a particular stack of item in a world, such as item count, is held by an ItemStack which represents a stack of specific item. Therefore, there is one - and only one - instance of Item for one item (like apples, oak planks, etc), while there can be infinite amounts of ItemStack instances. This also means that items themselves cannot hold NBT data.

Items with no custom behavior, like diamonds, can call the constructor of Item directly. If a custom behavior is needed, this should be subclassed. Items also have to be registered in the Registries.ITEM registry.

Many methods of this class are called on both the logical client and logical server, so take caution when using those methods. The logical side can be checked using World.isClient. See also the Fabric Wiki article. It is also important that methods that take LivingEntity as an argument can be called by non-players (such as foxes eating food), which causes a crash if the code performs unchecked casting.

See Also:
Mappings:
Namespace Name
official cdp
intermediary net/minecraft/class_1792
named net/minecraft/item/Item
  • Field Details

    • LOGGER

      private static final Logger LOGGER
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a:Lorg/slf4j/Logger;
      intermediary field_27017 Lnet/minecraft/class_1792;field_27017:Lorg/slf4j/Logger;
      named LOGGER Lnet/minecraft/item/Item;LOGGER:Lorg/slf4j/Logger;
    • BLOCK_ITEMS

      public static final Map<Block,Item> BLOCK_ITEMS
      Mappings:
      Namespace Name Mixin selector
      official l Lcdp;l:Ljava/util/Map;
      intermediary field_8003 Lnet/minecraft/class_1792;field_8003:Ljava/util/Map;
      named BLOCK_ITEMS Lnet/minecraft/item/Item;BLOCK_ITEMS:Ljava/util/Map;
    • ATTACK_DAMAGE_MODIFIER_ID

      protected static final UUID ATTACK_DAMAGE_MODIFIER_ID
      Mappings:
      Namespace Name Mixin selector
      official m Lcdp;m:Ljava/util/UUID;
      intermediary field_8006 Lnet/minecraft/class_1792;field_8006:Ljava/util/UUID;
      named ATTACK_DAMAGE_MODIFIER_ID Lnet/minecraft/item/Item;ATTACK_DAMAGE_MODIFIER_ID:Ljava/util/UUID;
    • ATTACK_SPEED_MODIFIER_ID

      protected static final UUID ATTACK_SPEED_MODIFIER_ID
      Mappings:
      Namespace Name Mixin selector
      official n Lcdp;n:Ljava/util/UUID;
      intermediary field_8001 Lnet/minecraft/class_1792;field_8001:Ljava/util/UUID;
      named ATTACK_SPEED_MODIFIER_ID Lnet/minecraft/item/Item;ATTACK_SPEED_MODIFIER_ID:Ljava/util/UUID;
    • DEFAULT_MAX_COUNT

      public static final int DEFAULT_MAX_COUNT
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official o Lcdp;o:I
      intermediary field_30887 Lnet/minecraft/class_1792;field_30887:I
      named DEFAULT_MAX_COUNT Lnet/minecraft/item/Item;DEFAULT_MAX_COUNT:I
    • DEFAULT_MAX_USE_TIME

      public static final int DEFAULT_MAX_USE_TIME
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official p Lcdp;p:I
      intermediary field_30888 Lnet/minecraft/class_1792;field_30888:I
      named DEFAULT_MAX_USE_TIME Lnet/minecraft/item/Item;DEFAULT_MAX_USE_TIME:I
    • ITEM_BAR_STEPS

      public static final int ITEM_BAR_STEPS
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official q Lcdp;q:I
      intermediary field_30889 Lnet/minecraft/class_1792;field_30889:I
      named ITEM_BAR_STEPS Lnet/minecraft/item/Item;ITEM_BAR_STEPS:I
    • registryEntry

      private final RegistryEntry.Reference<Item> registryEntry
      Mappings:
      Namespace Name Mixin selector
      official b Lcdp;b:Lgz$c;
      intermediary field_36401 Lnet/minecraft/class_1792;field_36401:Lnet/minecraft/class_6880$class_6883;
      named registryEntry Lnet/minecraft/item/Item;registryEntry:Lnet/minecraft/registry/entry/RegistryEntry$Reference;
    • rarity

      private final Rarity rarity
      Mappings:
      Namespace Name Mixin selector
      official c Lcdp;c:Lcek;
      intermediary field_8009 Lnet/minecraft/class_1792;field_8009:Lnet/minecraft/class_1814;
      named rarity Lnet/minecraft/item/Item;rarity:Lnet/minecraft/util/Rarity;
    • maxCount

      private final int maxCount
      Mappings:
      Namespace Name Mixin selector
      official d Lcdp;d:I
      intermediary field_8013 Lnet/minecraft/class_1792;field_8013:I
      named maxCount Lnet/minecraft/item/Item;maxCount:I
    • maxDamage

      private final int maxDamage
      Mappings:
      Namespace Name Mixin selector
      official e Lcdp;e:I
      intermediary field_8012 Lnet/minecraft/class_1792;field_8012:I
      named maxDamage Lnet/minecraft/item/Item;maxDamage:I
    • fireproof

      private final boolean fireproof
      Mappings:
      Namespace Name Mixin selector
      official f Lcdp;f:Z
      intermediary field_21979 Lnet/minecraft/class_1792;field_21979:Z
      named fireproof Lnet/minecraft/item/Item;fireproof:Z
    • recipeRemainder

      @Nullable private final @Nullable Item recipeRemainder
      Mappings:
      Namespace Name Mixin selector
      official g Lcdp;g:Lcdp;
      intermediary field_8008 Lnet/minecraft/class_1792;field_8008:Lnet/minecraft/class_1792;
      named recipeRemainder Lnet/minecraft/item/Item;recipeRemainder:Lnet/minecraft/item/Item;
    • translationKey

      @Nullable private @Nullable String translationKey
      Mappings:
      Namespace Name Mixin selector
      official h Lcdp;h:Ljava/lang/String;
      intermediary field_8014 Lnet/minecraft/class_1792;field_8014:Ljava/lang/String;
      named translationKey Lnet/minecraft/item/Item;translationKey:Ljava/lang/String;
    • foodComponent

      @Nullable private final @Nullable FoodComponent foodComponent
      Mappings:
      Namespace Name Mixin selector
      official i Lcdp;i:Lbzd;
      intermediary field_18672 Lnet/minecraft/class_1792;field_18672:Lnet/minecraft/class_4174;
      named foodComponent Lnet/minecraft/item/Item;foodComponent:Lnet/minecraft/item/FoodComponent;
    • requiredFeatures

      private final FeatureSet requiredFeatures
      Mappings:
      Namespace Name Mixin selector
      official j Lcdp;j:Lbyx;
      intermediary field_40209 Lnet/minecraft/class_1792;field_40209:Lnet/minecraft/class_7699;
      named requiredFeatures Lnet/minecraft/item/Item;requiredFeatures:Lnet/minecraft/resource/featuretoggle/FeatureSet;
  • Constructor Details

    • Item

      public Item(Item.Settings settings)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lcdp;<init>(Lcdp$a;)V
      intermediary <init> Lnet/minecraft/class_1792;<init>(Lnet/minecraft/class_1792$class_1793;)V
      named <init> Lnet/minecraft/item/Item;<init>(Lnet/minecraft/item/Item$Settings;)V
  • Method Details

    • getRawId

      public static int getRawId(Item item)
      Returns the raw ID of item, or 0 if passed null.
      Returns:
      the raw ID of item, or 0 if passed null
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdp;)I
      intermediary method_7880 Lnet/minecraft/class_1792;method_7880(Lnet/minecraft/class_1792;)I
      named getRawId Lnet/minecraft/item/Item;getRawId(Lnet/minecraft/item/Item;)I
    • byRawId

      public static Item byRawId(int id)
      Returns the item from its raw ID.
      Returns:
      the item from its raw ID
      Mappings:
      Namespace Name Mixin selector
      official b Lcdp;b(I)Lcdp;
      intermediary method_7875 Lnet/minecraft/class_1792;method_7875(I)Lnet/minecraft/class_1792;
      named byRawId Lnet/minecraft/item/Item;byRawId(I)Lnet/minecraft/item/Item;
    • fromBlock

      @Deprecated public static Item fromBlock(Block block)
      Deprecated.
      Please use Block.asItem()
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcmt;)Lcdp;
      intermediary method_7867 Lnet/minecraft/class_1792;method_7867(Lnet/minecraft/class_2248;)Lnet/minecraft/class_1792;
      named fromBlock Lnet/minecraft/item/Item;fromBlock(Lnet/minecraft/block/Block;)Lnet/minecraft/item/Item;
    • getRegistryEntry

      @Deprecated public RegistryEntry.Reference<Item> getRegistryEntry()
      Deprecated.
      Mappings:
      Namespace Name Mixin selector
      official k Lcdp;k()Lgz$c;
      intermediary method_40131 Lnet/minecraft/class_1792;method_40131()Lnet/minecraft/class_6880$class_6883;
      named getRegistryEntry Lnet/minecraft/item/Item;getRegistryEntry()Lnet/minecraft/registry/entry/RegistryEntry$Reference;
    • usageTick

      public void usageTick(World world, LivingEntity user, ItemStack stack, int remainingUseTicks)
      Called on both the server and the client every tick while an entity uses the item. Currently used by CrossbowItem to charge the crossbow. If this is overridden, getMaxUseTime(net.minecraft.item.ItemStack) should also be overridden to return a positive value.
      Parameters:
      remainingUseTicks - how long it's left until the entity finishes using the item, in ticks
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcjw;Lbeg;Lcdt;I)V
      intermediary method_7852 Lnet/minecraft/class_1792;method_7852(Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;Lnet/minecraft/class_1799;I)V
      named usageTick Lnet/minecraft/item/Item;usageTick(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;I)V
    • onItemEntityDestroyed

      public void onItemEntityDestroyed(ItemEntity entity)
      Called on the server when an ItemEntity holding this item gets destroyed. This can happen due to fire, lava, cactus, explosion, etc. Items that can hold other items should override this to drop its contents.
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lbti;)V
      intermediary method_33261 Lnet/minecraft/class_1792;method_33261(Lnet/minecraft/class_1542;)V
      named onItemEntityDestroyed Lnet/minecraft/item/Item;onItemEntityDestroyed(Lnet/minecraft/entity/ItemEntity;)V
    • postProcessNbt

      public void postProcessNbt(NbtCompound nbt)
      Processes the NBT applied to an item stack of this item.

      This is only used in vanilla to process player head NBT data.

      Mappings:
      Namespace Name Mixin selector
      official b Lcdp;b(Lqp;)V
      intermediary method_7860 Lnet/minecraft/class_1792;method_7860(Lnet/minecraft/class_2487;)V
      named postProcessNbt Lnet/minecraft/item/Item;postProcessNbt(Lnet/minecraft/nbt/NbtCompound;)V
    • canMine

      public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner)
      Returns whether a player can break a block while holding the item.

      This is to check whether the player can start breaking the block in the first place; this does not check if the item is a correct tool to mine the block. Melee weapons should override this to return false, unless it is also intended to be used as a tool.

      Returns:
      whether a player can break a block while holding the item
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcyt;Lcjw;Lgp;Lbwp;)Z
      intermediary method_7885 Lnet/minecraft/class_1792;method_7885(Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1657;)Z
      named canMine Lnet/minecraft/item/Item;canMine(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;)Z
    • asItem

      public Item asItem()
      Gets this object in its item form.
      Specified by:
      asItem in interface ItemConvertible
      Mappings:
      Namespace Name Mixin selector
      official l Lcjv;l()Lcdp;
      intermediary method_8389 Lnet/minecraft/class_1935;method_8389()Lnet/minecraft/class_1792;
      named asItem Lnet/minecraft/item/ItemConvertible;asItem()Lnet/minecraft/item/Item;
    • useOnBlock

      public ActionResult useOnBlock(ItemUsageContext context)
      Called when an item is used on a block.

      This method is called on both the logical client and logical server, so take caution when using this method. The logical side can be checked using context.getWorld().isClient().

      Parameters:
      context - the usage context
      Returns:
      an action result that specifies if using the item on a block was successful.
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcfw;)Lbcm;
      intermediary method_7884 Lnet/minecraft/class_1792;method_7884(Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;
      named useOnBlock Lnet/minecraft/item/Item;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;
    • getMiningSpeedMultiplier

      public float getMiningSpeedMultiplier(ItemStack stack, BlockState state)
      Returns the multiplier applied to the mining speed of stack when mining state.

      The default value is 1.0f. Returning larger integer will cause the block to be mined faster. Enchantments, status effects, and other effects that affect mining speed are instead handled in PlayerEntity.getBlockBreakingSpeed(net.minecraft.block.BlockState).

      Returns:
      the multiplier applied to the mining speed of stack when mining state
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcyt;)F
      intermediary method_7865 Lnet/minecraft/class_1792;method_7865(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)F
      named getMiningSpeedMultiplier Lnet/minecraft/item/Item;getMiningSpeedMultiplier(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)F
    • use

      public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand)
      Called when the player uses (or starts using) the item. The use action, by default, is bound to the right mouse button. This method checks the player's hunger when the item is a food, and will pass in all other cases by default.

      If the item can be used for multiple ticks, then this will only be called when the player starts using it. After that, usageTick(net.minecraft.world.World, net.minecraft.entity.LivingEntity, net.minecraft.item.ItemStack, int) is called every tick until the player finishes using the item.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using world.isClient().

      Parameters:
      world - the world the item was used in
      user - the player who used the item
      hand - the hand used
      Returns:
      a typed action result that specifies whether using the item was successful. The action result contains the new item stack that the player's hand will be set to.
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcjw;Lbwp;Lbcl;)Lbcn;
      intermediary method_7836 Lnet/minecraft/class_1792;method_7836(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1271;
      named use Lnet/minecraft/item/Item;use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/TypedActionResult;
    • finishUsing

      public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user)
      Called when an entity finishes using the item, such as eating food or drinking a potion. This method handles eating food by default.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using World.isClient.

      user might not be a player in some cases. For example, this occurs when a fox eats food or when a wandering trader drinks milk.

      Returns:
      the new item stack after using the item
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcjw;Lbeg;)Lcdt;
      intermediary method_7861 Lnet/minecraft/class_1792;method_7861(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;)Lnet/minecraft/class_1799;
      named finishUsing Lnet/minecraft/item/Item;finishUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;)Lnet/minecraft/item/ItemStack;
    • getMaxCount

      public final int getMaxCount()
      Returns the maximum stack count of any ItemStack with this item. Can be configured through settings.maxCount().
      Returns:
      the maximum stack count of any ItemStack with this item
      Mappings:
      Namespace Name Mixin selector
      official n Lcdp;n()I
      intermediary method_7882 Lnet/minecraft/class_1792;method_7882()I
      named getMaxCount Lnet/minecraft/item/Item;getMaxCount()I
    • getMaxDamage

      public final int getMaxDamage()
      Returns the maximum durability of this item. Can be configured through settings.maxDamage().
      Returns:
      the maximum durability of this item
      Mappings:
      Namespace Name Mixin selector
      official o Lcdp;o()I
      intermediary method_7841 Lnet/minecraft/class_1792;method_7841()I
      named getMaxDamage Lnet/minecraft/item/Item;getMaxDamage()I
    • isDamageable

      public boolean isDamageable()
      Returns whether this item can lose durability.
      Returns:
      whether this item can lose durability
      Mappings:
      Namespace Name Mixin selector
      official p Lcdp;p()Z
      intermediary method_7846 Lnet/minecraft/class_1792;method_7846()Z
      named isDamageable Lnet/minecraft/item/Item;isDamageable()Z
    • isItemBarVisible

      public boolean isItemBarVisible(ItemStack stack)
      Returns whether to show the item bar for stack.

      Item bar is usually used to display durability of the stack.

      When overriding this, getItemBarStep(net.minecraft.item.ItemStack) and getItemBarColor(net.minecraft.item.ItemStack) should also be overridden.

      Returns:
      whether to show the item bar for stack
      Mappings:
      Namespace Name Mixin selector
      official e Lcdp;e(Lcdt;)Z
      intermediary method_31567 Lnet/minecraft/class_1792;method_31567(Lnet/minecraft/class_1799;)Z
      named isItemBarVisible Lnet/minecraft/item/Item;isItemBarVisible(Lnet/minecraft/item/ItemStack;)Z
    • getItemBarStep

      public int getItemBarStep(ItemStack stack)
      Returns the step, or the length of the colored area of the item bar, for stack.

      This is between 0.0f and {code 13.0f}. By default, this is durability * 13.0f / maxDurability.

      When overriding this, isItemBarVisible(net.minecraft.item.ItemStack) and getItemBarColor(net.minecraft.item.ItemStack) should also be overridden.

      Returns:
      the step, or the length of the colored area of the item bar, for stack
      Mappings:
      Namespace Name Mixin selector
      official f Lcdp;f(Lcdt;)I
      intermediary method_31569 Lnet/minecraft/class_1792;method_31569(Lnet/minecraft/class_1799;)I
      named getItemBarStep Lnet/minecraft/item/Item;getItemBarStep(Lnet/minecraft/item/ItemStack;)I
    • getItemBarColor

      public int getItemBarColor(ItemStack stack)
      Returns the RGB color of the item bar, usually used for durability display.

      When overriding this, isItemBarVisible(net.minecraft.item.ItemStack) and getItemBarStep(net.minecraft.item.ItemStack) should also be overridden.

      Returns:
      the RGB color of the item bar, usually used for durability display
      Mappings:
      Namespace Name Mixin selector
      official g Lcdp;g(Lcdt;)I
      intermediary method_31571 Lnet/minecraft/class_1792;method_31571(Lnet/minecraft/class_1799;)I
      named getItemBarColor Lnet/minecraft/item/Item;getItemBarColor(Lnet/minecraft/item/ItemStack;)I
    • onStackClicked

      public boolean onStackClicked(ItemStack stack, Slot slot, ClickType clickType, PlayerEntity player)
      Called when the item at the cursor is clicked at slot.

      While this method is usually called on the logical server, it can also be called on the logical client, so take caution when overriding this method. The logical side can be checked using World.isClient.

      For example, this is called on BundleItem when the cursor holds a bundle and the player clicks on the slot.

      Parameters:
      stack - the stack the cursor holds
      slot - the clicked slot
      Returns:
      whether the action was successful
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcax;Lbzo;Lbwp;)Z
      intermediary method_31565 Lnet/minecraft/class_1792;method_31565(Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;)Z
      named onStackClicked Lnet/minecraft/item/Item;onStackClicked(Lnet/minecraft/item/ItemStack;Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/util/ClickType;Lnet/minecraft/entity/player/PlayerEntity;)Z
    • onClicked

      public boolean onClicked(ItemStack stack, ItemStack otherStack, Slot slot, ClickType clickType, PlayerEntity player, StackReference cursorStackReference)
      Called when the item at slot gets clicked by the cursor holding otherStack.

      While this method is usually called on the logical server, it can also be called on the logical client, so take caution when overriding this method. The logical side can be checked using World.isClient.

      For example, this is called on BundleItem when the cursor holds an item and the player clicks on the slot that has a bundle.

      Parameters:
      stack - the slot's stack
      otherStack - the stack the cursor holds
      slot - the clicked slot
      Returns:
      whether the action was successful
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcdt;Lcax;Lbzo;Lbwp;Lbey;)Z
      intermediary method_31566 Lnet/minecraft/class_1792;method_31566(Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;Lnet/minecraft/class_5630;)Z
      named onClicked Lnet/minecraft/item/Item;onClicked(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/util/ClickType;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/inventory/StackReference;)Z
    • postHit

      public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker)
      Called on the server when the item is used to hit an entity.

      Tools and melee weapons should override this to damage the stack.

      Returns:
      whether the item's use stat should be incremented
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lbeg;Lbeg;)Z
      intermediary method_7873 Lnet/minecraft/class_1792;method_7873(Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;Lnet/minecraft/class_1309;)Z
      named postHit Lnet/minecraft/item/Item;postHit(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;)Z
    • postMine

      public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner)
      Called on the server when the item is used to break a block.

      Tools and melee weapons should override this to damage the stack, after checking if the block's hardness is larger than 0.0f.

      Returns:
      whether the item's use stat should be incremented
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcjw;Lcyt;Lgp;Lbeg;)Z
      intermediary method_7879 Lnet/minecraft/class_1792;method_7879(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_2680;Lnet/minecraft/class_2338;Lnet/minecraft/class_1309;)Z
      named postMine Lnet/minecraft/item/Item;postMine(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)Z
    • isSuitableFor

      public boolean isSuitableFor(BlockState state)
      Determines whether this item can be used as a suitable tool for mining the specified block. Depending on block implementation, when combined together, the correct item and block may achieve a better mining speed and yield drops that would not be obtained when mining otherwise.

      Note that this is not the only way to achieve "effectiveness" when mining. Other items, such as shears on string, may use their own logic and calls to this method might not return a value consistent to this rule for those items.

      Mappings:
      Namespace Name Mixin selector
      official a_ Lcdp;a_(Lcyt;)Z
      intermediary method_7856 Lnet/minecraft/class_1792;method_7856(Lnet/minecraft/class_2680;)Z
      named isSuitableFor Lnet/minecraft/item/Item;isSuitableFor(Lnet/minecraft/block/BlockState;)Z
    • useOnEntity

      public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand)
      Called on both the client and the server when a player uses the item on an entity.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using World.isClient.

      This should be used if the item can be used on multiple types of entities, such as name tags or saddles.

      Returns:
      the action result
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lbwp;Lbeg;Lbcl;)Lbcm;
      intermediary method_7847 Lnet/minecraft/class_1792;method_7847(Lnet/minecraft/class_1799;Lnet/minecraft/class_1657;Lnet/minecraft/class_1309;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1269;
      named useOnEntity Lnet/minecraft/item/Item;useOnEntity(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;
    • getName

      public Text getName()
      Mappings:
      Namespace Name Mixin selector
      official q Lcdp;q()Lss;
      intermediary method_7848 Lnet/minecraft/class_1792;method_7848()Lnet/minecraft/class_2561;
      named getName Lnet/minecraft/item/Item;getName()Lnet/minecraft/text/Text;
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getOrCreateTranslationKey

      protected String getOrCreateTranslationKey()
      Mappings:
      Namespace Name Mixin selector
      official r Lcdp;r()Ljava/lang/String;
      intermediary method_7869 Lnet/minecraft/class_1792;method_7869()Ljava/lang/String;
      named getOrCreateTranslationKey Lnet/minecraft/item/Item;getOrCreateTranslationKey()Ljava/lang/String;
    • getTranslationKey

      public String getTranslationKey()
      Gets the translation key of this item.
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a()Ljava/lang/String;
      intermediary method_7876 Lnet/minecraft/class_1792;method_7876()Ljava/lang/String;
      named getTranslationKey Lnet/minecraft/item/Item;getTranslationKey()Ljava/lang/String;
    • getTranslationKey

      public String getTranslationKey(ItemStack stack)
      Gets the translation key of this item using the provided item stack for context.
      Mappings:
      Namespace Name Mixin selector
      official j Lcdp;j(Lcdt;)Ljava/lang/String;
      intermediary method_7866 Lnet/minecraft/class_1792;method_7866(Lnet/minecraft/class_1799;)Ljava/lang/String;
      named getTranslationKey Lnet/minecraft/item/Item;getTranslationKey(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;
    • isNbtSynced

      public boolean isNbtSynced()
      Checks if an item should have its NBT data stored in ItemStack.nbt sent to the client.

      If an item is damageable, this method is ignored and data is always synced to client.

      Mappings:
      Namespace Name Mixin selector
      official s Lcdp;s()Z
      intermediary method_7887 Lnet/minecraft/class_1792;method_7887()Z
      named isNbtSynced Lnet/minecraft/item/Item;isNbtSynced()Z
    • getRecipeRemainder

      @Nullable public final @Nullable Item getRecipeRemainder()
      Gets the remainder item that should be left behind when this item is used as a crafting ingredient.
      Mappings:
      Namespace Name Mixin selector
      official t Lcdp;t()Lcdp;
      intermediary method_7858 Lnet/minecraft/class_1792;method_7858()Lnet/minecraft/class_1792;
      named getRecipeRemainder Lnet/minecraft/item/Item;getRecipeRemainder()Lnet/minecraft/item/Item;
    • hasRecipeRemainder

      public boolean hasRecipeRemainder()
      Checks if this item has a remainder item that is left behind when used as a crafting ingredient.
      Mappings:
      Namespace Name Mixin selector
      official u Lcdp;u()Z
      intermediary method_7857 Lnet/minecraft/class_1792;method_7857()Z
      named hasRecipeRemainder Lnet/minecraft/item/Item;hasRecipeRemainder()Z
    • inventoryTick

      public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected)
      Called on both the client and the server every tick if the item is in the player's inventory.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using World.isClient.

      Parameters:
      entity - the entity holding the item; usually a player
      selected - whether the item is in the selected hotbar slot
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcjw;Lbdr;IZ)V
      intermediary method_7888 Lnet/minecraft/class_1792;method_7888(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1297;IZ)V
      named inventoryTick Lnet/minecraft/item/Item;inventoryTick(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;IZ)V
    • onCraft

      public void onCraft(ItemStack stack, World world, PlayerEntity player)
      Called when a player acquires the item by crafting, smelting, smithing, etc.
      Mappings:
      Namespace Name Mixin selector
      official b Lcdp;b(Lcdt;Lcjw;Lbwp;)V
      intermediary method_7843 Lnet/minecraft/class_1792;method_7843(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;)V
      named onCraft Lnet/minecraft/item/Item;onCraft(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;)V
    • isNetworkSynced

      public boolean isNetworkSynced()
      Returns whether the item needs to sync additional data to clients.

      Items should ideally store all necessary information on the stack's NBT. However, this is not always possible for things like maps. In those cases, items can send a packet to the player holding it that syncs additional data. Such items must subclass NetworkSyncedItem.

      Returns:
      whether the item needs to sync additional data to clients
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official S_ Lcdp;S_()Z
      intermediary method_16698 Lnet/minecraft/class_1792;method_16698()Z
      named isNetworkSynced Lnet/minecraft/item/Item;isNetworkSynced()Z
    • getUseAction

      public UseAction getUseAction(ItemStack stack)
      Returns the use action the item should perform.
      Returns:
      the use action the item should perform
      Mappings:
      Namespace Name Mixin selector
      official c Lcdp;c(Lcdt;)Lcfk;
      intermediary method_7853 Lnet/minecraft/class_1792;method_7853(Lnet/minecraft/class_1799;)Lnet/minecraft/class_1839;
      named getUseAction Lnet/minecraft/item/Item;getUseAction(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/UseAction;
    • getMaxUseTime

      public int getMaxUseTime(ItemStack stack)
      Returns the maximum use (right-click) time of this item, in ticks. Once a player has used an item for said number of ticks, they stop using it, and finishUsing(net.minecraft.item.ItemStack, net.minecraft.world.World, net.minecraft.entity.LivingEntity) is called.
      Returns:
      the maximum use (right-click) time of this item, in ticks
      Mappings:
      Namespace Name Mixin selector
      official b Lcdp;b(Lcdt;)I
      intermediary method_7881 Lnet/minecraft/class_1792;method_7881(Lnet/minecraft/class_1799;)I
      named getMaxUseTime Lnet/minecraft/item/Item;getMaxUseTime(Lnet/minecraft/item/ItemStack;)I
    • onStoppedUsing

      public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks)
      Called on both the client and the server when an entity stops using an item before reaching the maximum use time. If the time was reached, finishUsing(net.minecraft.item.ItemStack, net.minecraft.world.World, net.minecraft.entity.LivingEntity) is called instead.

      This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using World.isClient.

      user might not be a player in some cases. For example, this occurs when an entity uses a crossbow.

      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcjw;Lbeg;I)V
      intermediary method_7840 Lnet/minecraft/class_1792;method_7840(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)V
      named onStoppedUsing Lnet/minecraft/item/Item;onStoppedUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)V
    • appendTooltip

      public void appendTooltip(ItemStack stack, @Nullable @Nullable World world, List<Text> tooltip, TooltipContext context)
      Called by the client to append tooltips to an item. Subclasses can override this and add custom tooltips to tooltip list.
      Parameters:
      tooltip - the list of tooltips to show
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcjw;Ljava/util/List;Lcfi;)V
      intermediary method_7851 Lnet/minecraft/class_1792;method_7851(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Ljava/util/List;Lnet/minecraft/class_1836;)V
      named appendTooltip Lnet/minecraft/item/Item;appendTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Ljava/util/List;Lnet/minecraft/client/item/TooltipContext;)V
    • getTooltipData

      public Optional<TooltipData> getTooltipData(ItemStack stack)
      Mappings:
      Namespace Name Mixin selector
      official h Lcdp;h(Lcdt;)Ljava/util/Optional;
      intermediary method_32346 Lnet/minecraft/class_1792;method_32346(Lnet/minecraft/class_1799;)Ljava/util/Optional;
      named getTooltipData Lnet/minecraft/item/Item;getTooltipData(Lnet/minecraft/item/ItemStack;)Ljava/util/Optional;
    • getName

      public Text getName(ItemStack stack)
      Mappings:
      Namespace Name Mixin selector
      official m Lcdp;m(Lcdt;)Lss;
      intermediary method_7864 Lnet/minecraft/class_1792;method_7864(Lnet/minecraft/class_1799;)Lnet/minecraft/class_2561;
      named getName Lnet/minecraft/item/Item;getName(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/text/Text;
    • hasGlint

      public boolean hasGlint(ItemStack stack)
      Checks if the glint effect should be applied when the item is rendered.

      By default, returns true if the item has enchantments.

      Mappings:
      Namespace Name Mixin selector
      official i Lcdp;i(Lcdt;)Z
      intermediary method_7886 Lnet/minecraft/class_1792;method_7886(Lnet/minecraft/class_1799;)Z
      named hasGlint Lnet/minecraft/item/Item;hasGlint(Lnet/minecraft/item/ItemStack;)Z
    • getRarity

      public Rarity getRarity(ItemStack stack)
      Returns this item's rarity, which changes the color of its name.

      By default, if an item has an enchantment, its rarity is modified:

      • Common and Uncommon -> Rare
      • Rare -> Epic
      Returns:
      this item's rarity, which changes the color of its name
      Mappings:
      Namespace Name Mixin selector
      official n Lcdp;n(Lcdt;)Lcek;
      intermediary method_7862 Lnet/minecraft/class_1792;method_7862(Lnet/minecraft/class_1799;)Lnet/minecraft/class_1814;
      named getRarity Lnet/minecraft/item/Item;getRarity(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/Rarity;
    • isEnchantable

      public boolean isEnchantable(ItemStack stack)
      Returns whether the given ItemStack is enchantable.

      By default, ItemStacks are enchantable if their max stack count is 1 and they can be damaged.

      Returns:
      whether the given ItemStack is enchantable
      Mappings:
      Namespace Name Mixin selector
      official c_ Lcdp;c_(Lcdt;)Z
      intermediary method_7870 Lnet/minecraft/class_1792;method_7870(Lnet/minecraft/class_1799;)Z
      named isEnchantable Lnet/minecraft/item/Item;isEnchantable(Lnet/minecraft/item/ItemStack;)Z
    • raycast

      protected static BlockHitResult raycast(World world, PlayerEntity player, RaycastContext.FluidHandling fluidHandling)
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcjw;Lbwp;Lcjf$b;)Leaa;
      intermediary method_7872 Lnet/minecraft/class_1792;method_7872(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_3959$class_242;)Lnet/minecraft/class_3965;
      named raycast Lnet/minecraft/item/Item;raycast(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/RaycastContext$FluidHandling;)Lnet/minecraft/util/hit/BlockHitResult;
    • getEnchantability

      public int getEnchantability()
      Gets the enchantability of an item. This specifies the ability of an item to receive enchantments when enchanted using an enchanting table. As the value increases, the amount and level of enchantments applied increase.

      If the value of this method is 0, the item cannot be enchanted using an enchanting table.

      Mappings:
      Namespace Name Mixin selector
      official c Lcdp;c()I
      intermediary method_7837 Lnet/minecraft/class_1792;method_7837()I
      named getEnchantability Lnet/minecraft/item/Item;getEnchantability()I
    • canRepair

      public boolean canRepair(ItemStack stack, ItemStack ingredient)
      Returns whether stack can be repaired using ingredient.

      This only handles repairing using the ingredient such as diamonds, and does not handle combining tools or armor.

      Returns:
      whether stack can be repaired using ingredient
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcdt;)Z
      intermediary method_7878 Lnet/minecraft/class_1792;method_7878(Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z
      named canRepair Lnet/minecraft/item/Item;canRepair(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z
    • getAttributeModifiers

      public Multimap<EntityAttribute,EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot)
      Returns the attribute modifiers the item provides.

      Tools and armor should override this to specify the attack damage or armor points.

      Returns:
      the attribute modifiers the item provides
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lbdw;)Lcom/google/common/collect/Multimap;
      intermediary method_7844 Lnet/minecraft/class_1792;method_7844(Lnet/minecraft/class_1304;)Lcom/google/common/collect/Multimap;
      named getAttributeModifiers Lnet/minecraft/item/Item;getAttributeModifiers(Lnet/minecraft/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;
    • isUsedOnRelease

      public boolean isUsedOnRelease(ItemStack stack)
      Mappings:
      Namespace Name Mixin selector
      official l Lcdp;l(Lcdt;)Z
      intermediary method_7838 Lnet/minecraft/class_1792;method_7838(Lnet/minecraft/class_1799;)Z
      named isUsedOnRelease Lnet/minecraft/item/Item;isUsedOnRelease(Lnet/minecraft/item/ItemStack;)Z
    • getDefaultStack

      public ItemStack getDefaultStack()
      Returns the default stack for this item.

      Items that expect certain NBT data in the item stack should override this method to return the stack with the NBT data.

      Returns:
      the default stack for this item
      Mappings:
      Namespace Name Mixin selector
      official T_ Lcdp;T_()Lcdt;
      intermediary method_7854 Lnet/minecraft/class_1792;method_7854()Lnet/minecraft/class_1799;
      named getDefaultStack Lnet/minecraft/item/Item;getDefaultStack()Lnet/minecraft/item/ItemStack;
    • isFood

      public boolean isFood()
      Checks if this item is food and therefore is edible.
      Mappings:
      Namespace Name Mixin selector
      official v Lcdp;v()Z
      intermediary method_19263 Lnet/minecraft/class_1792;method_19263()Z
      named isFood Lnet/minecraft/item/Item;isFood()Z
    • getFoodComponent

      @Nullable public @Nullable FoodComponent getFoodComponent()
      Returns this item's FoodComponent, or null if none was set.
      Returns:
      this item's FoodComponent, or null if none was set
      Mappings:
      Namespace Name Mixin selector
      official w Lcdp;w()Lbzd;
      intermediary method_19264 Lnet/minecraft/class_1792;method_19264()Lnet/minecraft/class_4174;
      named getFoodComponent Lnet/minecraft/item/Item;getFoodComponent()Lnet/minecraft/item/FoodComponent;
    • getDrinkSound

      public SoundEvent getDrinkSound()
      Returns the sound for drinking the item.
      Returns:
      the sound for drinking the item
      Mappings:
      Namespace Name Mixin selector
      official U_ Lcdp;U_()Laln;
      intermediary method_21831 Lnet/minecraft/class_1792;method_21831()Lnet/minecraft/class_3414;
      named getDrinkSound Lnet/minecraft/item/Item;getDrinkSound()Lnet/minecraft/sound/SoundEvent;
    • getEatSound

      public SoundEvent getEatSound()
      Returns the sound for eating the item.
      Returns:
      the sound for eating the item
      Mappings:
      Namespace Name Mixin selector
      official h Lcdp;h()Laln;
      intermediary method_21830 Lnet/minecraft/class_1792;method_21830()Lnet/minecraft/class_3414;
      named getEatSound Lnet/minecraft/item/Item;getEatSound()Lnet/minecraft/sound/SoundEvent;
    • isFireproof

      public boolean isFireproof()
      Returns whether this item is immune to fire and lava damage.
      Returns:
      whether this item is immune to fire and lava damage
      Mappings:
      Namespace Name Mixin selector
      official x Lcdp;x()Z
      intermediary method_24358 Lnet/minecraft/class_1792;method_24358()Z
      named isFireproof Lnet/minecraft/item/Item;isFireproof()Z
    • damage

      public boolean damage(DamageSource source)
      Returns whether this item can be damaged by the given source.
      Returns:
      whether this item can be damaged by the given source
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lbcz;)Z
      intermediary method_24357 Lnet/minecraft/class_1792;method_24357(Lnet/minecraft/class_1282;)Z
      named damage Lnet/minecraft/item/Item;damage(Lnet/minecraft/entity/damage/DamageSource;)Z
    • getEquipSound

      @Nullable public @Nullable SoundEvent getEquipSound()
      Returns the sound for equipping the item, or null if no sound is played.
      Returns:
      the sound for equipping the item, or null if no sound is played
      Mappings:
      Namespace Name Mixin selector
      official g Lcdp;g()Laln;
      intermediary method_31570 Lnet/minecraft/class_1792;method_31570()Lnet/minecraft/class_3414;
      named getEquipSound Lnet/minecraft/item/Item;getEquipSound()Lnet/minecraft/sound/SoundEvent;
    • canBeNested

      public boolean canBeNested()
      Returns:
      true if the item can be placed inside of shulker boxes or bundles.
      Mappings:
      Namespace Name Mixin selector
      official V_ Lcdp;V_()Z
      intermediary method_31568 Lnet/minecraft/class_1792;method_31568()Z
      named canBeNested Lnet/minecraft/item/Item;canBeNested()Z
    • getRequiredFeatures

      public FeatureSet getRequiredFeatures()
      Specified by:
      getRequiredFeatures in interface ToggleableFeature
      Mappings:
      Namespace Name Mixin selector
      official m Lbyu;m()Lbyx;
      intermediary method_45322 Lnet/minecraft/class_7695;method_45322()Lnet/minecraft/class_7699;
      named getRequiredFeatures Lnet/minecraft/resource/featuretoggle/ToggleableFeature;getRequiredFeatures()Lnet/minecraft/resource/featuretoggle/FeatureSet;