Class Item
- All Implemented Interfaces:
ItemConvertible,ToggleableFeature
- Direct Known Subclasses:
AirBlockItem,ArmorStandItem,ArrowItem,AxeItem,BlockItem,BoatItem,BoneMealItem,BrushItem,BucketItem,BundleItem,CompassItem,DebugStickItem,DecorationItem,DiscFragmentItem,DyeItem,EggItem,EmptyMapItem,EndCrystalItem,EnderEyeItem,EnderPearlItem,ExperienceBottleItem,FilledMapItem,FireChargeItem,FireworkRocketItem,FishingRodItem,FlintAndSteelItem,GlassBottleItem,GlowInkSacItem,GoatHornItem,HoeItem,HoneycombItem,InkSacItem,KnowledgeBookItem,LeadItem,MaceItem,MinecartItem,NameTagItem,OnAStickItem,PotionItem,RangedWeaponItem,ShearsItem,ShieldItem,ShovelItem,SmithingTemplateItem,SnowballItem,SpawnEggItem,SpyglassItem,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/Itemintermediary net/minecraft/class_1792official dag
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classItem settings configure behaviors common to all items, such as the stack's max count.static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Identifierstatic final Identifierprivate final ComponentMapprotected static final intstatic final intstatic final com.mojang.serialization.Codec<RegistryEntry<Item>> static final PacketCodec<RegistryByteBuf, RegistryEntry<Item>> static final intprivate static final Loggerstatic final intprivate final RegistryEntry.Reference<Item> private final FeatureSetprotected final StringFields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
FEATURE_ENABLED_REGISTRY_KEYS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplayComponent displayComponent, Consumer<Text> textConsumer, TooltipType type) Deprecated.asItem()Gets this object in its item form.static ItembyRawId(int id) Returns the item from its raw ID.booleanbooleancanMine(ItemStack stack, BlockState state, World world, BlockPos pos, LivingEntity user) Returns whether a player can break a block while holding the item.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.floatgetBonusAttackDamage(Entity target, float baseAttackDamage, DamageSource damageSource) getDamageSource(LivingEntity user) Returns the default stack for this 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, LivingEntity user) Returns the maximum use (right-click) time of this item, in ticks.floatgetMiningSpeed(ItemStack stack, BlockState state) final TextgetName()static intReturns the raw ID ofitem, or 0 if passednull.final ItemStackGets the remainder item that should be left behind when this item is used as a crafting ingredient.Deprecated.getTooltipData(ItemStack stack) final StringGets the translation key of this item.getUseAction(ItemStack stack) Returns the use action the item should perform.booleanChecks if the glint effect should be applied when the item is rendered.voidinventoryTick(ItemStack stack, ServerWorld world, Entity entity, @Nullable EquipmentSlot slot) Called on both the client and the server every tick if the item is in a player or other entity's inventory.booleanisCorrectForDrops(ItemStack stack, BlockState state) booleanisItemBarVisible(ItemStack stack) Returns whether to show the item bar forstack.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, PlayerEntity playerEntity) 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.booleanonStoppedUsing(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.voidpostDamageEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) voidpostHit(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) booleanshouldShowOperatorBlockWarnings(ItemStack stack, @Nullable PlayerEntity player) 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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
isEnabled
-
Field Details
-
ENTRY_CODEC
- Mappings:
Namespace Name Mixin selector named ENTRY_CODECLnet/minecraft/item/Item;ENTRY_CODEC:Lcom/mojang/serialization/Codec;intermediary field_54952Lnet/minecraft/class_1792;field_54952:Lcom/mojang/serialization/Codec;official eLdag;e:Lcom/mojang/serialization/Codec;
-
ENTRY_PACKET_CODEC
- Mappings:
Namespace Name Mixin selector named ENTRY_PACKET_CODECLnet/minecraft/item/Item;ENTRY_PACKET_CODEC:Lnet/minecraft/network/codec/PacketCodec;intermediary field_55708Lnet/minecraft/class_1792;field_55708:Lnet/minecraft/class_9139;official fLdag;f:Lze;
-
LOGGER
- Mappings:
Namespace Name Mixin selector named LOGGERLnet/minecraft/item/Item;LOGGER:Lorg/slf4j/Logger;intermediary field_27017Lnet/minecraft/class_1792;field_27017:Lorg/slf4j/Logger;official aLdag;a:Lorg/slf4j/Logger;
-
BLOCK_ITEMS
- Mappings:
Namespace Name Mixin selector named BLOCK_ITEMSLnet/minecraft/item/Item;BLOCK_ITEMS:Ljava/util/Map;intermediary field_8003Lnet/minecraft/class_1792;field_8003:Ljava/util/Map;official gLdag;g:Ljava/util/Map;
-
BASE_ATTACK_DAMAGE_MODIFIER_ID
- Mappings:
Namespace Name Mixin selector named BASE_ATTACK_DAMAGE_MODIFIER_IDLnet/minecraft/item/Item;BASE_ATTACK_DAMAGE_MODIFIER_ID:Lnet/minecraft/util/Identifier;intermediary field_8006Lnet/minecraft/class_1792;field_8006:Lnet/minecraft/class_2960;official hLdag;h:Lalr;
-
BASE_ATTACK_SPEED_MODIFIER_ID
- Mappings:
Namespace Name Mixin selector named BASE_ATTACK_SPEED_MODIFIER_IDLnet/minecraft/item/Item;BASE_ATTACK_SPEED_MODIFIER_ID:Lnet/minecraft/util/Identifier;intermediary field_8001Lnet/minecraft/class_1792;field_8001:Lnet/minecraft/class_2960;official iLdag;i:Lalr;
-
DEFAULT_MAX_COUNT
public static final int DEFAULT_MAX_COUNT- See Also:
- Mappings:
Namespace Name Mixin selector named DEFAULT_MAX_COUNTLnet/minecraft/item/Item;DEFAULT_MAX_COUNT:Iintermediary field_30887Lnet/minecraft/class_1792;field_30887:Iofficial jLdag;j:I
-
MAX_MAX_COUNT
public static final int MAX_MAX_COUNT- See Also:
- Mappings:
Namespace Name Mixin selector named MAX_MAX_COUNTLnet/minecraft/item/Item;MAX_MAX_COUNT:Iintermediary field_49998Lnet/minecraft/class_1792;field_49998:Iofficial kLdag;k:I
-
ITEM_BAR_STEPS
public static final int ITEM_BAR_STEPS- See Also:
- Mappings:
Namespace Name Mixin selector named ITEM_BAR_STEPSLnet/minecraft/item/Item;ITEM_BAR_STEPS:Iintermediary field_30889Lnet/minecraft/class_1792;field_30889:Iofficial lLdag;l:I
-
DEFAULT_BLOCKS_ATTACKS_MAX_USE_TIME
protected static final int DEFAULT_BLOCKS_ATTACKS_MAX_USE_TIME- See Also:
- Mappings:
Namespace Name Mixin selector named DEFAULT_BLOCKS_ATTACKS_MAX_USE_TIMELnet/minecraft/item/Item;DEFAULT_BLOCKS_ATTACKS_MAX_USE_TIME:Iintermediary field_56296Lnet/minecraft/class_1792;field_56296:Iofficial mLdag;m:I
-
registryEntry
- Mappings:
Namespace Name Mixin selector named registryEntryLnet/minecraft/item/Item;registryEntry:Lnet/minecraft/registry/entry/RegistryEntry$Reference;intermediary field_36401Lnet/minecraft/class_1792;field_36401:Lnet/minecraft/class_6880$class_6883;official bLdag;b:Ljg$c;
-
components
- Mappings:
Namespace Name Mixin selector named componentsLnet/minecraft/item/Item;components:Lnet/minecraft/component/ComponentMap;intermediary field_49263Lnet/minecraft/class_1792;field_49263:Lnet/minecraft/class_9323;official cLdag;c:Lki;
-
recipeRemainder
- Mappings:
Namespace Name Mixin selector named recipeRemainderLnet/minecraft/item/Item;recipeRemainder:Lnet/minecraft/item/Item;intermediary field_8008Lnet/minecraft/class_1792;field_8008:Lnet/minecraft/class_1792;official dLdag;d:Ldag;
-
translationKey
- Mappings:
Namespace Name Mixin selector named translationKeyLnet/minecraft/item/Item;translationKey:Ljava/lang/String;intermediary field_8014Lnet/minecraft/class_1792;field_8014:Ljava/lang/String;official nLdag;n:Ljava/lang/String;
-
requiredFeatures
- Mappings:
Namespace Name Mixin selector named requiredFeaturesLnet/minecraft/item/Item;requiredFeatures:Lnet/minecraft/resource/featuretoggle/FeatureSet;intermediary field_40209Lnet/minecraft/class_1792;field_40209:Lnet/minecraft/class_7699;official oLdag;o:Lcvs;
-
-
Constructor Details
-
Item
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/Item;<init>(Lnet/minecraft/item/Item$Settings;)Vintermediary <init>Lnet/minecraft/class_1792;<init>(Lnet/minecraft/class_1792$class_1793;)Vofficial <init>Ldag;<init>(Ldag$a;)V
-
-
Method Details
-
getRawId
Returns the raw ID ofitem, or 0 if passednull.- Returns:
- the raw ID of
item, or 0 if passednull - Mappings:
Namespace Name Mixin selector named getRawIdLnet/minecraft/item/Item;getRawId(Lnet/minecraft/item/Item;)Iintermediary method_7880Lnet/minecraft/class_1792;method_7880(Lnet/minecraft/class_1792;)Iofficial aLdag;a(Ldag;)I
-
byRawId
Returns the item from its raw ID.- Returns:
- the item from its raw ID
- Mappings:
Namespace Name Mixin selector named byRawIdLnet/minecraft/item/Item;byRawId(I)Lnet/minecraft/item/Item;intermediary method_7875Lnet/minecraft/class_1792;method_7875(I)Lnet/minecraft/class_1792;official bLdag;b(I)Ldag;
-
fromBlock
Deprecated.Please useBlock.asItem()- Mappings:
Namespace Name Mixin selector named fromBlockLnet/minecraft/item/Item;fromBlock(Lnet/minecraft/block/Block;)Lnet/minecraft/item/Item;intermediary method_7867Lnet/minecraft/class_1792;method_7867(Lnet/minecraft/class_2248;)Lnet/minecraft/class_1792;official aLdag;a(Ldno;)Ldag;
-
getRegistryEntry
Deprecated.- Mappings:
Namespace Name Mixin selector named getRegistryEntryLnet/minecraft/item/Item;getRegistryEntry()Lnet/minecraft/registry/entry/RegistryEntry$Reference;intermediary method_40131Lnet/minecraft/class_1792;method_40131()Lnet/minecraft/class_6880$class_6883;official eLdag;e()Ljg$c;
-
getComponents
- Mappings:
Namespace Name Mixin selector named getComponentsLnet/minecraft/item/Item;getComponents()Lnet/minecraft/component/ComponentMap;intermediary method_57347Lnet/minecraft/class_1792;method_57347()Lnet/minecraft/class_9323;official fLdag;f()Lki;
-
getMaxCount
public 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 getMaxCountLnet/minecraft/item/Item;getMaxCount()Iintermediary method_7882Lnet/minecraft/class_1792;method_7882()Iofficial gLdag;g()I
-
usageTick
Called 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, net.minecraft.entity.LivingEntity)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 usageTickLnet/minecraft/item/Item;usageTick(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;I)Vintermediary method_7852Lnet/minecraft/class_1792;method_7852(Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;Lnet/minecraft/class_1799;I)Vofficial aLdag;a(Ldkj;Lbyf;Ldak;I)V
-
onItemEntityDestroyed
Called 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 onItemEntityDestroyedLnet/minecraft/item/Item;onItemEntityDestroyed(Lnet/minecraft/entity/ItemEntity;)Vintermediary method_33261Lnet/minecraft/class_1792;method_33261(Lnet/minecraft/class_1542;)Vofficial aLdag;a(Lcoo;)V
-
postProcessComponents
Processes 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 postProcessComponentsLnet/minecraft/item/Item;postProcessComponents(Lnet/minecraft/item/ItemStack;)Vintermediary method_7860Lnet/minecraft/class_1792;method_7860(Lnet/minecraft/class_1799;)Vofficial lLdag;l(Ldak;)V
-
canMine
public boolean canMine(ItemStack stack, BlockState state, World world, BlockPos pos, LivingEntity user) 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 named canMineLnet/minecraft/item/Item;canMine(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)Zintermediary method_7885Lnet/minecraft/class_1792;method_7885(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1309;)Zofficial aLdag;a(Ldak;Lebq;Ldkj;Liw;Lbyf;)Z
-
asItem
Gets this object in its item form.- Specified by:
asItemin interfaceItemConvertible- Mappings:
Namespace Name Mixin selector named asItemLnet/minecraft/item/ItemConvertible;asItem()Lnet/minecraft/item/Item;intermediary method_8389Lnet/minecraft/class_1935;method_8389()Lnet/minecraft/class_1792;official hLdki;h()Ldag;
-
useOnBlock
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 named useOnBlockLnet/minecraft/item/Item;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;intermediary method_7884Lnet/minecraft/class_1792;method_7884(Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;official aLdag;a(Ldef;)Lbvc;
-
getMiningSpeed
- Mappings:
Namespace Name Mixin selector named getMiningSpeedLnet/minecraft/item/Item;getMiningSpeed(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)Fintermediary method_58404Lnet/minecraft/class_1792;method_58404(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)Fofficial aLdag;a(Ldak;Lebq;)F
-
use
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 inuser- the player who used the itemhand- 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 useLnet/minecraft/item/Item;use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;intermediary method_7836Lnet/minecraft/class_1792;method_7836(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1269;official aLdag;a(Ldkj;Lcsi;Lbvb;)Lbvc;
-
finishUsing
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.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 finishUsingLnet/minecraft/item/Item;finishUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;)Lnet/minecraft/item/ItemStack;intermediary method_7861Lnet/minecraft/class_1792;method_7861(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;)Lnet/minecraft/class_1799;official aLdag;a(Ldak;Ldkj;Lbyf;)Ldak;
-
isItemBarVisible
Returns 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 isItemBarVisibleLnet/minecraft/item/Item;isItemBarVisible(Lnet/minecraft/item/ItemStack;)Zintermediary method_31567Lnet/minecraft/class_1792;method_31567(Lnet/minecraft/class_1799;)Zofficial dLdag;d(Ldak;)Z
-
getItemBarStep
Returns 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 getItemBarStepLnet/minecraft/item/Item;getItemBarStep(Lnet/minecraft/item/ItemStack;)Iintermediary method_31569Lnet/minecraft/class_1792;method_31569(Lnet/minecraft/class_1799;)Iofficial eLdag;e(Ldak;)I
-
getItemBarColor
Returns 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 getItemBarColorLnet/minecraft/item/Item;getItemBarColor(Lnet/minecraft/item/ItemStack;)Iintermediary method_31571Lnet/minecraft/class_1792;method_31571(Lnet/minecraft/class_1799;)Iofficial fLdag;f(Ldak;)I
-
onStackClicked
Called 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 holdsslot- the clicked slot- Returns:
- whether the action was successful
- Mappings:
Namespace Name Mixin selector named onStackClickedLnet/minecraft/item/Item;onStackClicked(Lnet/minecraft/item/ItemStack;Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/util/ClickType;Lnet/minecraft/entity/player/PlayerEntity;)Zintermediary method_31565Lnet/minecraft/class_1792;method_31565(Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;)Zofficial aLdag;a(Ldak;Lcxz;Lcwl;Lcsi;)Z
-
onClicked
public 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 stackotherStack- the stack the cursor holdsslot- the clicked slot- Returns:
- whether the action was successful
- Mappings:
Namespace Name Mixin selector named onClickedLnet/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;)Zintermediary method_31566Lnet/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;)Zofficial aLdag;a(Ldak;Ldak;Lcxz;Lcwl;Lcsi;Lbyw;)Z
-
getBonusAttackDamage
- Mappings:
Namespace Name Mixin selector named getBonusAttackDamageLnet/minecraft/item/Item;getBonusAttackDamage(Lnet/minecraft/entity/Entity;FLnet/minecraft/entity/damage/DamageSource;)Fintermediary method_58403Lnet/minecraft/class_1792;method_58403(Lnet/minecraft/class_1297;FLnet/minecraft/class_1282;)Fofficial aLdag;a(Lbxe;FLbvt;)F
-
getDamageSource
- Mappings:
Namespace Name Mixin selector named getDamageSourceLnet/minecraft/item/Item;getDamageSource(Lnet/minecraft/entity/LivingEntity;)Lnet/minecraft/entity/damage/DamageSource;intermediary method_64193Lnet/minecraft/class_1792;method_64193(Lnet/minecraft/class_1309;)Lnet/minecraft/class_1282;official aLdag;a(Lbyf;)Lbvt;
-
postHit
Called on the server when the item is used to hit an entity.Tools and melee weapons should override this to damage the stack.
- See Also:
- Mappings:
Namespace Name Mixin selector named postHitLnet/minecraft/item/Item;postHit(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;)Vintermediary method_7873Lnet/minecraft/class_1792;method_7873(Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;Lnet/minecraft/class_1309;)Vofficial aLdag;a(Ldak;Lbyf;Lbyf;)V
-
postDamageEntity
- Mappings:
Namespace Name Mixin selector named postDamageEntityLnet/minecraft/item/Item;postDamageEntity(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;)Vintermediary method_59978Lnet/minecraft/class_1792;method_59978(Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;Lnet/minecraft/class_1309;)Vofficial bLdag;b(Ldak;Lbyf;Lbyf;)V
-
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 named postMineLnet/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;)Zintermediary method_7879Lnet/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;)Zofficial aLdag;a(Ldak;Ldkj;Lebq;Liw;Lbyf;)Z
-
isCorrectForDrops
- Mappings:
Namespace Name Mixin selector named isCorrectForDropsLnet/minecraft/item/Item;isCorrectForDrops(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)Zintermediary method_58405Lnet/minecraft/class_1792;method_58405(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)Zofficial bLdag;b(Ldak;Lebq;)Z
-
useOnEntity
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 named useOnEntityLnet/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_7847Lnet/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 aLdag;a(Ldak;Lcsi;Lbyf;Lbvb;)Lbvc;
-
toString
-
getRecipeRemainder
Gets the remainder item that should be left behind when this item is used as a crafting ingredient.- Mappings:
Namespace Name Mixin selector named getRecipeRemainderLnet/minecraft/item/Item;getRecipeRemainder()Lnet/minecraft/item/ItemStack;intermediary method_7858Lnet/minecraft/class_1792;method_7858()Lnet/minecraft/class_1799;official iLdag;i()Ldak;
-
inventoryTick
public void inventoryTick(ItemStack stack, ServerWorld world, Entity entity, @Nullable @Nullable EquipmentSlot slot) Called on both the client and the server every tick if the item is in a player or other entity'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- Mappings:
Namespace Name Mixin selector named inventoryTickLnet/minecraft/item/Item;inventoryTick(Lnet/minecraft/item/ItemStack;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EquipmentSlot;)Vintermediary method_7888Lnet/minecraft/class_1792;method_7888(Lnet/minecraft/class_1799;Lnet/minecraft/class_3218;Lnet/minecraft/class_1297;Lnet/minecraft/class_1304;)Vofficial aLdag;a(Ldak;Lasb;Lbxe;Lbxo;)V
-
onCraftByPlayer
Called 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 onCraftByPlayerLnet/minecraft/item/Item;onCraftByPlayer(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_54465Lnet/minecraft/class_1792;method_54465(Lnet/minecraft/class_1799;Lnet/minecraft/class_1657;)Vofficial cLdag;c(Ldak;Lcsi;)V
-
onCraft
Called when the item is made by crafting, smelting, smithing, etc.- Mappings:
Namespace Name Mixin selector named onCraftLnet/minecraft/item/Item;onCraft(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;)Vintermediary method_7843Lnet/minecraft/class_1792;method_7843(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;)Vofficial aLdag;a(Ldak;Ldkj;)V
-
getUseAction
Returns the use action the item should perform.- Returns:
- the use action the item should perform
- Mappings:
Namespace Name Mixin selector named getUseActionLnet/minecraft/item/Item;getUseAction(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/consume/UseAction;intermediary method_7853Lnet/minecraft/class_1792;method_7853(Lnet/minecraft/class_1799;)Lnet/minecraft/class_1839;official bLdag;b(Ldak;)Ldam;
-
getMaxUseTime
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, 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 getMaxUseTimeLnet/minecraft/item/Item;getMaxUseTime(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;)Iintermediary method_7881Lnet/minecraft/class_1792;method_7881(Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;)Iofficial aLdag;a(Ldak;Lbyf;)I
-
onStoppedUsing
public boolean 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.usermight not be a player in some cases. For example, this occurs when an entity uses a crossbow.- Mappings:
Namespace Name Mixin selector named onStoppedUsingLnet/minecraft/item/Item;onStoppedUsing(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Zintermediary method_7840Lnet/minecraft/class_1792;method_7840(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)Zofficial aLdag;a(Ldak;Ldkj;Lbyf;I)Z
-
appendTooltip
@Deprecated public void appendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplayComponent displayComponent, Consumer<Text> textConsumer, TooltipType type) Deprecated.- Mappings:
Namespace Name Mixin selector named appendTooltipLnet/minecraft/item/Item;appendTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/Item$TooltipContext;Lnet/minecraft/component/type/TooltipDisplayComponent;Ljava/util/function/Consumer;Lnet/minecraft/item/tooltip/TooltipType;)Vintermediary method_67187Lnet/minecraft/class_1792;method_67187(Lnet/minecraft/class_1799;Lnet/minecraft/class_1792$class_9635;Lnet/minecraft/class_10712;Ljava/util/function/Consumer;Lnet/minecraft/class_1836;)Vofficial aLdag;a(Ldak;Ldag$b;Lddo;Ljava/util/function/Consumer;Ldbz;)V
-
getTooltipData
- Mappings:
Namespace Name Mixin selector named getTooltipDataLnet/minecraft/item/Item;getTooltipData(Lnet/minecraft/item/ItemStack;)Ljava/util/Optional;intermediary method_32346Lnet/minecraft/class_1792;method_32346(Lnet/minecraft/class_1799;)Ljava/util/Optional;official kLdag;k(Ldak;)Ljava/util/Optional;
-
getTranslationKey
Gets the translation key of this item.- Mappings:
Namespace Name Mixin selector named getTranslationKeyLnet/minecraft/item/Item;getTranslationKey()Ljava/lang/String;intermediary method_7876Lnet/minecraft/class_1792;method_7876()Ljava/lang/String;official jLdag;j()Ljava/lang/String;
-
getName
- Mappings:
Namespace Name Mixin selector named getNameLnet/minecraft/item/Item;getName()Lnet/minecraft/text/Text;intermediary method_63680Lnet/minecraft/class_1792;method_63680()Lnet/minecraft/class_2561;official lLdag;l()Lxg;
-
getName
- Mappings:
Namespace Name Mixin selector named getNameLnet/minecraft/item/Item;getName(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/text/Text;intermediary method_7864Lnet/minecraft/class_1792;method_7864(Lnet/minecraft/class_1799;)Lnet/minecraft/class_2561;official aLdag;a(Ldak;)Lxg;
-
hasGlint
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 named hasGlintLnet/minecraft/item/Item;hasGlint(Lnet/minecraft/item/ItemStack;)Zintermediary method_7886Lnet/minecraft/class_1792;method_7886(Lnet/minecraft/class_1799;)Zofficial d_Ldag;d_(Ldak;)Z
-
raycast
protected static BlockHitResult raycast(World world, PlayerEntity player, RaycastContext.FluidHandling fluidHandling) - Mappings:
Namespace Name Mixin selector named raycastLnet/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_7872Lnet/minecraft/class_1792;method_7872(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_3959$class_242;)Lnet/minecraft/class_3965;official aLdag;a(Ldkj;Lcsi;Ldjq$b;)Lffy;
-
isUsedOnRelease
- Mappings:
Namespace Name Mixin selector named isUsedOnReleaseLnet/minecraft/item/Item;isUsedOnRelease(Lnet/minecraft/item/ItemStack;)Zintermediary method_7838Lnet/minecraft/class_1792;method_7838(Lnet/minecraft/class_1799;)Zofficial e_Ldag;e_(Ldak;)Z
-
getDefaultStack
Returns 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 getDefaultStackLnet/minecraft/item/Item;getDefaultStack()Lnet/minecraft/item/ItemStack;intermediary method_7854Lnet/minecraft/class_1792;method_7854()Lnet/minecraft/class_1799;official mLdag;m()Ldak;
-
canBeNested
public boolean canBeNested()- Returns:
- true if the item can be placed inside of shulker boxes or bundles.
- Mappings:
Namespace Name Mixin selector named canBeNestedLnet/minecraft/item/Item;canBeNested()Zintermediary method_31568Lnet/minecraft/class_1792;method_31568()Zofficial dLdag;d()Z
-
getRequiredFeatures
- Specified by:
getRequiredFeaturesin interfaceToggleableFeature- Mappings:
Namespace Name Mixin selector named getRequiredFeaturesLnet/minecraft/resource/featuretoggle/ToggleableFeature;getRequiredFeatures()Lnet/minecraft/resource/featuretoggle/FeatureSet;intermediary method_45322Lnet/minecraft/class_7695;method_45322()Lnet/minecraft/class_7699;official kLcvp;k()Lcvs;
-
shouldShowOperatorBlockWarnings
public boolean shouldShowOperatorBlockWarnings(ItemStack stack, @Nullable @Nullable PlayerEntity player) - Mappings:
Namespace Name Mixin selector named shouldShowOperatorBlockWarningsLnet/minecraft/item/Item;shouldShowOperatorBlockWarnings(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/PlayerEntity;)Zintermediary method_65353Lnet/minecraft/class_1792;method_65353(Lnet/minecraft/class_1799;Lnet/minecraft/class_1657;)Zofficial aLdag;a(Ldak;Lcsi;)Z
-
Block.asItem()