Class Item
- All Implemented Interfaces:
- ItemConvertible,- ToggleableFeature
- Direct Known Subclasses:
- AirBlockItem,- ArmorItem,- ArmorStandItem,- ArrowItem,- BannerPatternItem,- BlockItem,- BoatItem,- BoneMealItem,- BookItem,- BrushItem,- BucketItem,- BundleItem,- ChorusFruitItem,- CompassItem,- DebugStickItem,- DecorationItem,- DiscFragmentItem,- DyeItem,- EggItem,- ElytraItem,- EnchantedBookItem,- EndCrystalItem,- EnderEyeItem,- EnderPearlItem,- ExperienceBottleItem,- FireChargeItem,- FireworkRocketItem,- FireworkStarItem,- FishingRodItem,- FlintAndSteelItem,- GlassBottleItem,- GlowInkSacItem,- GoatHornItem,- HoneyBottleItem,- HoneycombItem,- InkSacItem,- KnowledgeBookItem,- LeadItem,- MaceItem,- MilkBucketItem,- MinecartItem,- MusicDiscItem,- NameTagItem,- NetworkSyncedItem,- OminousBottleItem,- OnAStickItem,- PotionItem,- RangedWeaponItem,- SaddleItem,- ShearsItem,- ShieldItem,- SmithingTemplateItem,- SnowballItem,- SpawnEggItem,- SpyglassItem,- StewItem,- SuspiciousStewItem,- ToolItem,- TridentItem,- WindChargeItem,- WritableBookItem,- WrittenBookItem
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 - named - net/minecraft/item/Item- intermediary - net/minecraft/class_1792- official - cum
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classItem settings configure behaviors common to all items, such as the stack's max count.static interface
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final UUIDstatic final UUIDprivate final ComponentMapstatic final intstatic final intprivate static final Loggerstatic final intprivate final RegistryEntry.Reference<Item> private final FeatureSetFields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeatureFEATURE_ENABLED_REGISTRY_KEYS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidappendTooltip(ItemStack stack, Item.TooltipContext context, List<Text> tooltip, TooltipType type) Called by the client to append tooltips to an item.asItem()Gets this object in its item form.static ItembyRawId(int id) Returns the item from its raw ID.booleanbooleancanMine(BlockState state, World world, BlockPos pos, PlayerEntity miner) Returns whether a player can break a block while holding the item.booleanReturns whetherstackcan be repaired usingingredient.finishUsing(ItemStack stack, World world, LivingEntity user) Called when an entity finishes using the item, such as eating food or drinking a potion.static ItemDeprecated.Deprecated.floatgetBonusAttackDamage(PlayerEntity player, float baseAttackDamage) Returns the default stack for this item.Returns the sound for drinking the item.Returns the sound for eating the item.intGets the enchantability of an item.intgetItemBarColor(ItemStack stack) Returns the RGB color of the item bar, usually used for durability display.intgetItemBarStep(ItemStack stack) Returns the step, or the length of the colored area of the item bar, forstack.intReturns the maximum stack count of any ItemStack with this item.intgetMaxUseTime(ItemStack stack) Returns the maximum use (right-click) time of this item, in ticks.floatgetMiningSpeed(ItemStack stack, BlockState state) getName()protected Stringstatic intReturns the raw ID ofitem, or 0 if passednull.Gets the remainder item that should be left behind when this item is used as a crafting ingredient.Deprecated.getTooltipData(ItemStack stack) Gets the translation key of this item.getTranslationKey(ItemStack stack) Gets the translation key of this item using the provided item stack for context.getUseAction(ItemStack stack) Returns the use action the item should perform.booleanChecks if the glint effect should be applied when the item is rendered.booleanChecks if this item has a remainder item that is left behind when used as a crafting ingredient.voidinventoryTick(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.booleanisCorrectForDrops(ItemStack stack, BlockState state) booleanisEnchantable(ItemStack stack) Returns whether the givenItemStackis enchantable.booleanisItemBarVisible(ItemStack stack) Returns whether to show the item bar forstack.booleanReturns whether the item needs to sync additional data to clients.booleanisUsedOnRelease(ItemStack stack) booleanonClicked(ItemStack stack, ItemStack otherStack, Slot slot, ClickType clickType, PlayerEntity player, StackReference cursorStackReference) Called when the item atslotgets clicked by the cursor holdingotherStack.voidCalled when the item is made by crafting, smelting, smithing, etc.voidonCraftByPlayer(ItemStack stack, World world, PlayerEntity player) Called when a player acquires the item by crafting, smelting, smithing, etc.voidonItemEntityDestroyed(ItemEntity entity) Called on the server when anItemEntityholding this item gets destroyed.booleanonStackClicked(ItemStack stack, Slot slot, ClickType clickType, PlayerEntity player) Called when the item at the cursor is clicked atslot.voidonStoppedUsing(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.booleanpostHit(ItemStack stack, LivingEntity target, LivingEntity attacker) Called on the server when the item is used to hit an entity.booleanpostMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) Called on the server when the item is used to break a block.voidpostProcessComponents(ItemStack stack) Processes the components applied to an item stack of this item.protected static BlockHitResultraycast(World world, PlayerEntity player, RaycastContext.FluidHandling fluidHandling) toString()voidusageTick(World world, LivingEntity user, ItemStack stack, int remainingUseTicks) Called on both the server and the client every tick while an entity uses the item.use(World world, PlayerEntity user, Hand hand) Called when the player uses (or starts using) the item.useOnBlock(ItemUsageContext context) Called when an item is used on a block.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.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeatureisEnabled
- 
Field Details- 
LOGGER- Mappings:
- Namespace - Name - Mixin selector - named - LOGGER- Lnet/minecraft/item/Item;LOGGER:Lorg/slf4j/Logger;- intermediary - field_27017- Lnet/minecraft/class_1792;field_27017:Lorg/slf4j/Logger;- official - a- Lcum;a:Lorg/slf4j/Logger;
 
- 
BLOCK_ITEMS- Mappings:
- Namespace - Name - Mixin selector - named - BLOCK_ITEMS- Lnet/minecraft/item/Item;BLOCK_ITEMS:Ljava/util/Map;- intermediary - field_8003- Lnet/minecraft/class_1792;field_8003:Ljava/util/Map;- official - d- Lcum;d:Ljava/util/Map;
 
- 
ATTACK_DAMAGE_MODIFIER_ID- Mappings:
- Namespace - Name - Mixin selector - named - ATTACK_DAMAGE_MODIFIER_ID- Lnet/minecraft/item/Item;ATTACK_DAMAGE_MODIFIER_ID:Ljava/util/UUID;- intermediary - field_8006- Lnet/minecraft/class_1792;field_8006:Ljava/util/UUID;- official - e- Lcum;e:Ljava/util/UUID;
 
- 
ATTACK_SPEED_MODIFIER_ID- Mappings:
- Namespace - Name - Mixin selector - named - ATTACK_SPEED_MODIFIER_ID- Lnet/minecraft/item/Item;ATTACK_SPEED_MODIFIER_ID:Ljava/util/UUID;- intermediary - field_8001- Lnet/minecraft/class_1792;field_8001:Ljava/util/UUID;- official - f- Lcum;f:Ljava/util/UUID;
 
- 
DEFAULT_MAX_COUNTpublic static final int DEFAULT_MAX_COUNT- See Also:
- Mappings:
- Namespace - Name - Mixin selector - named - DEFAULT_MAX_COUNT- Lnet/minecraft/item/Item;DEFAULT_MAX_COUNT:I- intermediary - field_30887- Lnet/minecraft/class_1792;field_30887:I- official - g- Lcum;g:I
 
- 
MAX_MAX_COUNTpublic static final int MAX_MAX_COUNT- See Also:
- Mappings:
- Namespace - Name - Mixin selector - named - MAX_MAX_COUNT- Lnet/minecraft/item/Item;MAX_MAX_COUNT:I- intermediary - field_49998- Lnet/minecraft/class_1792;field_49998:I- official - h- Lcum;h:I
 
- 
ITEM_BAR_STEPSpublic static final int ITEM_BAR_STEPS- See Also:
- Mappings:
- Namespace - Name - Mixin selector - named - ITEM_BAR_STEPS- Lnet/minecraft/item/Item;ITEM_BAR_STEPS:I- intermediary - field_30889- Lnet/minecraft/class_1792;field_30889:I- official - i- Lcum;i:I
 
- 
registryEntry- Mappings:
- Namespace - Name - Mixin selector - named - registryEntry- Lnet/minecraft/item/Item;registryEntry:Lnet/minecraft/registry/entry/RegistryEntry$Reference;- intermediary - field_36401- Lnet/minecraft/class_1792;field_36401:Lnet/minecraft/class_6880$class_6883;- official - b- Lcum;b:Lji$c;
 
- 
components- Mappings:
- Namespace - Name - Mixin selector - named - components- Lnet/minecraft/item/Item;components:Lnet/minecraft/component/ComponentMap;- intermediary - field_49263- Lnet/minecraft/class_1792;field_49263:Lnet/minecraft/class_9323;- official - c- Lcum;c:Lki;
 
- 
recipeRemainder- Mappings:
- Namespace - Name - Mixin selector - named - recipeRemainder- Lnet/minecraft/item/Item;recipeRemainder:Lnet/minecraft/item/Item;- intermediary - field_8008- Lnet/minecraft/class_1792;field_8008:Lnet/minecraft/class_1792;- official - j- Lcum;j:Lcum;
 
- 
translationKey- Mappings:
- Namespace - Name - Mixin selector - named - translationKey- Lnet/minecraft/item/Item;translationKey:Ljava/lang/String;- intermediary - field_8014- Lnet/minecraft/class_1792;field_8014:Ljava/lang/String;- official - k- Lcum;k:Ljava/lang/String;
 
- 
requiredFeatures- Mappings:
- Namespace - Name - Mixin selector - named - requiredFeatures- Lnet/minecraft/item/Item;requiredFeatures:Lnet/minecraft/resource/featuretoggle/FeatureSet;- intermediary - field_40209- Lnet/minecraft/class_1792;field_40209:Lnet/minecraft/class_7699;- official - l- Lcum;l:Lcpn;
 
 
- 
- 
Constructor Details- 
Item- Mappings:
- Namespace - Name - Mixin selector - named - <init>- Lnet/minecraft/item/Item;<init>(Lnet/minecraft/item/Item$Settings;)V- intermediary - <init>- Lnet/minecraft/class_1792;<init>(Lnet/minecraft/class_1792$class_1793;)V- official - <init>- Lcum;<init>(Lcum$a;)V
 
 
- 
- 
Method Details- 
getRawIdReturns the raw ID ofitem, or 0 if passednull.- Returns:
- the raw ID of item, or 0 if passednull
- Mappings:
- Namespace - Name - Mixin selector - named - getRawId- Lnet/minecraft/item/Item;getRawId(Lnet/minecraft/item/Item;)I- intermediary - method_7880- Lnet/minecraft/class_1792;method_7880(Lnet/minecraft/class_1792;)I- official - a- Lcum;a(Lcum;)I
 
- 
byRawIdReturns the item from its raw ID.- Returns:
- the item from its raw ID
- Mappings:
- Namespace - Name - Mixin selector - named - byRawId- Lnet/minecraft/item/Item;byRawId(I)Lnet/minecraft/item/Item;- intermediary - method_7875- Lnet/minecraft/class_1792;method_7875(I)Lnet/minecraft/class_1792;- official - b- Lcum;b(I)Lcum;
 
- 
fromBlockDeprecated.Please useBlock.asItem()- Mappings:
- Namespace - Name - Mixin selector - named - fromBlock- Lnet/minecraft/item/Item;fromBlock(Lnet/minecraft/block/Block;)Lnet/minecraft/item/Item;- intermediary - method_7867- Lnet/minecraft/class_1792;method_7867(Lnet/minecraft/class_2248;)Lnet/minecraft/class_1792;- official - a- Lcum;a(Ldfb;)Lcum;
 
- 
getRegistryEntryDeprecated.- Mappings:
- Namespace - Name - Mixin selector - named - getRegistryEntry- Lnet/minecraft/item/Item;getRegistryEntry()Lnet/minecraft/registry/entry/RegistryEntry$Reference;- intermediary - method_40131- Lnet/minecraft/class_1792;method_40131()Lnet/minecraft/class_6880$class_6883;- official - o- Lcum;o()Lji$c;
 
- 
getComponents- Mappings:
- Namespace - Name - Mixin selector - named - getComponents- Lnet/minecraft/item/Item;getComponents()Lnet/minecraft/component/ComponentMap;- intermediary - method_57347- Lnet/minecraft/class_1792;method_57347()Lnet/minecraft/class_9323;- official - p- Lcum;p()Lki;
 
- 
getMaxCountpublic int getMaxCount()Returns the maximum stack count of any ItemStack with this item. Can be configured throughsettings.maxCount().- Returns:
- the maximum stack count of any ItemStack with this item
- Mappings:
- Namespace - Name - Mixin selector - named - getMaxCount- Lnet/minecraft/item/Item;getMaxCount()I- intermediary - method_7882- Lnet/minecraft/class_1792;method_7882()I- official - q- Lcum;q()I
 
- 
usageTickCalled on both the server and the client every tick while an entity uses the item. Currently used byCrossbowItemto 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 - named - usageTick- Lnet/minecraft/item/Item;usageTick(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;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- official - a- Lcum;a(Ldca;Lbtr;Lcur;I)V
 
- 
onItemEntityDestroyedCalled on the server when anItemEntityholding 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 - named - onItemEntityDestroyed- Lnet/minecraft/item/Item;onItemEntityDestroyed(Lnet/minecraft/entity/ItemEntity;)V- intermediary - method_33261- Lnet/minecraft/class_1792;method_33261(Lnet/minecraft/class_1542;)V- official - a- Lcum;a(Lcjj;)V
 
- 
postProcessComponentsProcesses the components applied to an item stack of this item.This is only used in vanilla to process player head component data. - Mappings:
- Namespace - Name - Mixin selector - named - postProcessComponents- Lnet/minecraft/item/Item;postProcessComponents(Lnet/minecraft/item/ItemStack;)V- intermediary - method_7860- Lnet/minecraft/class_1792;method_7860(Lnet/minecraft/class_1799;)V- official - n- Lcum;n(Lcur;)V
 
- 
canMineReturns 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 - 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- 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- official - a- Lcum;a(Ldse;Ldca;Liz;Lcmz;)Z
 
- 
asItemGets this object in its item form.- Specified by:
- asItemin interface- ItemConvertible
- Mappings:
- Namespace - Name - Mixin selector - named - asItem- Lnet/minecraft/item/ItemConvertible;asItem()Lnet/minecraft/item/Item;- intermediary - method_8389- Lnet/minecraft/class_1935;method_8389()Lnet/minecraft/class_1792;- official - r- Ldbz;r()Lcum;
 
- 
useOnBlockCalled 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 - named - useOnBlock- Lnet/minecraft/item/Item;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;- intermediary - method_7884- Lnet/minecraft/class_1792;method_7884(Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;- official - a- Lcum;a(Lcye;)Lbqw;
 
- 
getMiningSpeed- Mappings:
- Namespace - Name - Mixin selector - named - getMiningSpeed- Lnet/minecraft/item/Item;getMiningSpeed(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)F- intermediary - method_58404- Lnet/minecraft/class_1792;method_58404(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)F- official - a- Lcum;a(Lcur;Ldse;)F
 
- 
useCalled 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 - named - use- Lnet/minecraft/item/Item;use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/TypedActionResult;- 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;- official - a- Lcum;a(Ldca;Lcmz;Lbqv;)Lbqx;
 
- 
finishUsingCalled 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.usermight 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 - named - finishUsing- Lnet/minecraft/item/Item;finishUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;)Lnet/minecraft/item/ItemStack;- 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;- official - a- Lcum;a(Lcur;Ldca;Lbtr;)Lcur;
 
- 
isItemBarVisibleReturns whether to show the item bar forstack.Item bar is usually used to display durability of the stack. When overriding this, getItemBarStep(net.minecraft.item.ItemStack)andgetItemBarColor(net.minecraft.item.ItemStack)should also be overridden.- Returns:
- whether to show the item bar for stack
- Mappings:
- Namespace - Name - Mixin selector - named - isItemBarVisible- Lnet/minecraft/item/Item;isItemBarVisible(Lnet/minecraft/item/ItemStack;)Z- intermediary - method_31567- Lnet/minecraft/class_1792;method_31567(Lnet/minecraft/class_1799;)Z- official - e- Lcum;e(Lcur;)Z
 
- 
getItemBarStepReturns the step, or the length of the colored area of the item bar, forstack.This is between 0.0fand {code 13.0f}. By default, this isdurability * 13.0f / maxDurability.When overriding this, isItemBarVisible(net.minecraft.item.ItemStack)andgetItemBarColor(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 - named - getItemBarStep- Lnet/minecraft/item/Item;getItemBarStep(Lnet/minecraft/item/ItemStack;)I- intermediary - method_31569- Lnet/minecraft/class_1792;method_31569(Lnet/minecraft/class_1799;)I- official - f- Lcum;f(Lcur;)I
 
- 
getItemBarColorReturns the RGB color of the item bar, usually used for durability display.When overriding this, isItemBarVisible(net.minecraft.item.ItemStack)andgetItemBarStep(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 - named - getItemBarColor- Lnet/minecraft/item/Item;getItemBarColor(Lnet/minecraft/item/ItemStack;)I- intermediary - method_31571- Lnet/minecraft/class_1792;method_31571(Lnet/minecraft/class_1799;)I- official - g- Lcum;g(Lcur;)I
 
- 
onStackClickedCalled when the item at the cursor is clicked atslot.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 BundleItemwhen 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 - 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- 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- official - a- Lcum;a(Lcur;Lcrr;Lcqe;Lcmz;)Z
 
- 
onClickedpublic boolean onClicked(ItemStack stack, ItemStack otherStack, Slot slot, ClickType clickType, PlayerEntity player, StackReference cursorStackReference) Called when the item atslotgets clicked by the cursor holdingotherStack.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 BundleItemwhen 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 - 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- 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- official - a- Lcum;a(Lcur;Lcur;Lcrr;Lcqe;Lcmz;Lbuj;)Z
 
- 
getBonusAttackDamage- Mappings:
- Namespace - Name - Mixin selector - named - getBonusAttackDamage- Lnet/minecraft/item/Item;getBonusAttackDamage(Lnet/minecraft/entity/player/PlayerEntity;F)F- intermediary - method_58403- Lnet/minecraft/class_1792;method_58403(Lnet/minecraft/class_1657;F)F- official - a- Lcum;a(Lcmz;F)F
 
- 
postHitCalled 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 - named - postHit- Lnet/minecraft/item/Item;postHit(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;)Z- intermediary - method_7873- Lnet/minecraft/class_1792;method_7873(Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;Lnet/minecraft/class_1309;)Z- official - a- Lcum;a(Lcur;Lbtr;Lbtr;)Z
 
- 
postMinepublic 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 - 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- 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- official - a- Lcum;a(Lcur;Ldca;Ldse;Liz;Lbtr;)Z
 
- 
isCorrectForDrops- Mappings:
- Namespace - Name - Mixin selector - named - isCorrectForDrops- Lnet/minecraft/item/Item;isCorrectForDrops(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)Z- intermediary - method_58405- Lnet/minecraft/class_1792;method_58405(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)Z- official - b- Lcum;b(Lcur;Ldse;)Z
 
- 
useOnEntityCalled 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 - 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;- 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;- official - a- Lcum;a(Lcur;Lcmz;Lbtr;Lbqv;)Lbqw;
 
- 
getName- Mappings:
- Namespace - Name - Mixin selector - named - getName- Lnet/minecraft/item/Item;getName()Lnet/minecraft/text/Text;- intermediary - method_7848- Lnet/minecraft/class_1792;method_7848()Lnet/minecraft/class_2561;- official - s- Lcum;s()Lxp;
 
- 
toString
- 
getOrCreateTranslationKey- Mappings:
- Namespace - Name - Mixin selector - named - getOrCreateTranslationKey- Lnet/minecraft/item/Item;getOrCreateTranslationKey()Ljava/lang/String;- intermediary - method_7869- Lnet/minecraft/class_1792;method_7869()Ljava/lang/String;- official - t- Lcum;t()Ljava/lang/String;
 
- 
getTranslationKeyGets the translation key of this item.- Mappings:
- Namespace - Name - Mixin selector - named - getTranslationKey- Lnet/minecraft/item/Item;getTranslationKey()Ljava/lang/String;- intermediary - method_7876- Lnet/minecraft/class_1792;method_7876()Ljava/lang/String;- official - a- Lcum;a()Ljava/lang/String;
 
- 
getTranslationKeyGets the translation key of this item using the provided item stack for context.- Mappings:
- Namespace - Name - Mixin selector - named - getTranslationKey- Lnet/minecraft/item/Item;getTranslationKey(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;- intermediary - method_7866- Lnet/minecraft/class_1792;method_7866(Lnet/minecraft/class_1799;)Ljava/lang/String;- official - i- Lcum;i(Lcur;)Ljava/lang/String;
 
- 
getRecipeRemainderGets the remainder item that should be left behind when this item is used as a crafting ingredient.- Mappings:
- Namespace - Name - Mixin selector - named - getRecipeRemainder- Lnet/minecraft/item/Item;getRecipeRemainder()Lnet/minecraft/item/Item;- intermediary - method_7858- Lnet/minecraft/class_1792;method_7858()Lnet/minecraft/class_1792;- official - u- Lcum;u()Lcum;
 
- 
hasRecipeRemainderpublic 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 - named - hasRecipeRemainder- Lnet/minecraft/item/Item;hasRecipeRemainder()Z- intermediary - method_7857- Lnet/minecraft/class_1792;method_7857()Z- official - v- Lcum;v()Z
 
- 
inventoryTickCalled 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 - named - inventoryTick- Lnet/minecraft/item/Item;inventoryTick(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;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- official - a- Lcum;a(Lcur;Ldca;Lbsw;IZ)V
 
- 
onCraftByPlayerCalled when a player acquires the item by crafting, smelting, smithing, etc.Not called when the item is automatically created, such as via a crafter. - Mappings:
- Namespace - Name - Mixin selector - named - onCraftByPlayer- Lnet/minecraft/item/Item;onCraftByPlayer(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;)V- intermediary - method_54465- Lnet/minecraft/class_1792;method_54465(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;)V- official - b- Lcum;b(Lcur;Ldca;Lcmz;)V
 
- 
onCraftCalled when the item is made by crafting, smelting, smithing, etc.- Mappings:
- Namespace - Name - Mixin selector - named - onCraft- Lnet/minecraft/item/Item;onCraft(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;)V- intermediary - method_7843- Lnet/minecraft/class_1792;method_7843(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;)V- official - a- Lcum;a(Lcur;Ldca;)V
 
- 
isNetworkSyncedpublic boolean isNetworkSynced()Returns whether the item needs to sync additional data to clients.Items should ideally store all necessary information in the stack's components. 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 - named - isNetworkSynced- Lnet/minecraft/item/Item;isNetworkSynced()Z- intermediary - method_16698- Lnet/minecraft/class_1792;method_16698()Z- official - aj_- Lcum;aj_()Z
 
- 
getUseActionReturns the use action the item should perform.- Returns:
- the use action the item should perform
- Mappings:
- Namespace - Name - Mixin selector - named - getUseAction- Lnet/minecraft/item/Item;getUseAction(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/UseAction;- intermediary - method_7853- Lnet/minecraft/class_1792;method_7853(Lnet/minecraft/class_1799;)Lnet/minecraft/class_1839;- official - c- Lcum;c(Lcur;)Lcwm;
 
- 
getMaxUseTimeReturns 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, andfinishUsing(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 - named - getMaxUseTime- Lnet/minecraft/item/Item;getMaxUseTime(Lnet/minecraft/item/ItemStack;)I- intermediary - method_7881- Lnet/minecraft/class_1792;method_7881(Lnet/minecraft/class_1799;)I- official - b- Lcum;b(Lcur;)I
 
- 
onStoppedUsingCalled 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.usermight not be a player in some cases. For example, this occurs when an entity uses a crossbow.- Mappings:
- Namespace - Name - Mixin selector - named - onStoppedUsing- Lnet/minecraft/item/Item;onStoppedUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;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- official - a- Lcum;a(Lcur;Ldca;Lbtr;I)V
 
- 
appendTooltippublic void appendTooltip(ItemStack stack, Item.TooltipContext context, List<Text> tooltip, TooltipType type) Called by the client to append tooltips to an item. Subclasses can override this and add custom tooltips totooltiplist.- Parameters:
- tooltip- the list of tooltips to show
- Mappings:
- Namespace - Name - Mixin selector - named - appendTooltip- Lnet/minecraft/item/Item;appendTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/Item$TooltipContext;Ljava/util/List;Lnet/minecraft/client/item/TooltipType;)V- intermediary - method_7851- Lnet/minecraft/class_1792;method_7851(Lnet/minecraft/class_1799;Lnet/minecraft/class_1792$class_9635;Ljava/util/List;Lnet/minecraft/class_1836;)V- official - a- Lcum;a(Lcur;Lcum$b;Ljava/util/List;Lcwk;)V
 
- 
getTooltipData- Mappings:
- Namespace - Name - Mixin selector - named - getTooltipData- Lnet/minecraft/item/Item;getTooltipData(Lnet/minecraft/item/ItemStack;)Ljava/util/Optional;- intermediary - method_32346- Lnet/minecraft/class_1792;method_32346(Lnet/minecraft/class_1799;)Ljava/util/Optional;- official - h- Lcum;h(Lcur;)Ljava/util/Optional;
 
- 
getName- Mappings:
- Namespace - Name - Mixin selector - named - getName- Lnet/minecraft/item/Item;getName(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/text/Text;- intermediary - method_7864- Lnet/minecraft/class_1792;method_7864(Lnet/minecraft/class_1799;)Lnet/minecraft/class_2561;- official - o- Lcum;o(Lcur;)Lxp;
 
- 
hasGlintChecks 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 - named - hasGlint- Lnet/minecraft/item/Item;hasGlint(Lnet/minecraft/item/ItemStack;)Z- intermediary - method_7886- Lnet/minecraft/class_1792;method_7886(Lnet/minecraft/class_1799;)Z- official - d_- Lcum;d_(Lcur;)Z
 
- 
isEnchantableReturns whether the givenItemStackis enchantable.By default, ItemStacks are enchantable if their max stack count is 1 and they can be damaged. - Returns:
- whether the given ItemStackis enchantable
- Mappings:
- Namespace - Name - Mixin selector - named - isEnchantable- Lnet/minecraft/item/Item;isEnchantable(Lnet/minecraft/item/ItemStack;)Z- intermediary - method_7870- Lnet/minecraft/class_1792;method_7870(Lnet/minecraft/class_1799;)Z- official - a- Lcum;a(Lcur;)Z
 
- 
raycastprotected static BlockHitResult raycast(World world, PlayerEntity player, RaycastContext.FluidHandling fluidHandling) - Mappings:
- Namespace - Name - Mixin selector - 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;- 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;- official - a- Lcum;a(Ldca;Lcmz;Ldbj$b;)Levp;
 
- 
getEnchantabilitypublic 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 - named - getEnchantability- Lnet/minecraft/item/Item;getEnchantability()I- intermediary - method_7837- Lnet/minecraft/class_1792;method_7837()I- official - g- Lcum;g()I
 
- 
canRepairReturns whetherstackcan be repaired usingingredient.This only handles repairing using the ingredient such as diamonds, and does not handle combining tools or armor. - Returns:
- whether stackcan be repaired usingingredient
- Mappings:
- Namespace - Name - Mixin selector - named - canRepair- Lnet/minecraft/item/Item;canRepair(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z- intermediary - method_7878- Lnet/minecraft/class_1792;method_7878(Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z- official - a- Lcum;a(Lcur;Lcur;)Z
 
- 
getAttributeModifiersDeprecated.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 - named - getAttributeModifiers- Lnet/minecraft/item/Item;getAttributeModifiers()Lnet/minecraft/component/type/AttributeModifiersComponent;- intermediary - method_7844- Lnet/minecraft/class_1792;method_7844()Lnet/minecraft/class_9285;- official - j- Lcum;j()Lcxm;
 
- 
isUsedOnRelease- Mappings:
- Namespace - Name - Mixin selector - named - isUsedOnRelease- Lnet/minecraft/item/Item;isUsedOnRelease(Lnet/minecraft/item/ItemStack;)Z- intermediary - method_7838- Lnet/minecraft/class_1792;method_7838(Lnet/minecraft/class_1799;)Z- official - m- Lcum;m(Lcur;)Z
 
- 
getDefaultStackReturns the default stack for this item.Items that expect certain components in the item stack should override this method to return the stack with the component data. - Returns:
- the default stack for this item
- Mappings:
- Namespace - Name - Mixin selector - named - getDefaultStack- Lnet/minecraft/item/Item;getDefaultStack()Lnet/minecraft/item/ItemStack;- intermediary - method_7854- Lnet/minecraft/class_1792;method_7854()Lnet/minecraft/class_1799;- official - w- Lcum;w()Lcur;
 
- 
getDrinkSoundReturns the sound for drinking the item.- Returns:
- the sound for drinking the item
- Mappings:
- Namespace - Name - Mixin selector - named - getDrinkSound- Lnet/minecraft/item/Item;getDrinkSound()Lnet/minecraft/sound/SoundEvent;- intermediary - method_21831- Lnet/minecraft/class_1792;method_21831()Lnet/minecraft/class_3414;- official - ak_- Lcum;ak_()Lavz;
 
- 
getEatSoundReturns the sound for eating the item.- Returns:
- the sound for eating the item
- Mappings:
- Namespace - Name - Mixin selector - named - getEatSound- Lnet/minecraft/item/Item;getEatSound()Lnet/minecraft/sound/SoundEvent;- intermediary - method_21830- Lnet/minecraft/class_1792;method_21830()Lnet/minecraft/class_3414;- official - al_- Lcum;al_()Lavz;
 
- 
getBreakSound- Mappings:
- Namespace - Name - Mixin selector - named - getBreakSound- Lnet/minecraft/item/Item;getBreakSound()Lnet/minecraft/sound/SoundEvent;- intermediary - method_57336- Lnet/minecraft/class_1792;method_57336()Lnet/minecraft/class_3414;- official - e- Lcum;e()Lavz;
 
- 
canBeNestedpublic boolean canBeNested()- Returns:
- true if the item can be placed inside of shulker boxes or bundles.
- Mappings:
- Namespace - Name - Mixin selector - named - canBeNested- Lnet/minecraft/item/Item;canBeNested()Z- intermediary - method_31568- Lnet/minecraft/class_1792;method_31568()Z- official - am_- Lcum;am_()Z
 
- 
getRequiredFeatures- Specified by:
- getRequiredFeaturesin interface- ToggleableFeature
- Mappings:
- Namespace - Name - Mixin selector - named - getRequiredFeatures- Lnet/minecraft/resource/featuretoggle/ToggleableFeature;getRequiredFeatures()Lnet/minecraft/resource/featuretoggle/FeatureSet;- intermediary - method_45322- Lnet/minecraft/class_7695;method_45322()Lnet/minecraft/class_7699;- official - i- Lcpk;i()Lcpn;
 
 
- 
Block.asItem()