yarn/mappings/net/minecraft/item/Item.mapping

433 lines
23 KiB
Plaintext

CLASS net/minecraft/class_1792 net/minecraft/item/Item
COMMENT An item usable by players and other entities.
COMMENT
COMMENT <p>Like {@link Block}, this class handles logics for a type of item, and does not
COMMENT hold any data. Any data about a particular stack of item in a world, such as item count,
COMMENT is held by an {@link ItemStack} which represents a stack of specific item. Therefore,
COMMENT there is one - and only one - instance of Item for one item (like apples, oak planks, etc),
COMMENT while there can be infinite amounts of {@link ItemStack} instances. This also means that
COMMENT items themselves cannot hold NBT data.
COMMENT
COMMENT <p>Items with no custom behavior, like diamonds, can call the constructor of Item
COMMENT directly. If a custom behavior is needed, this should be subclassed. Items also have
COMMENT to be registered in the {@link net.minecraft.registry.Registries#ITEM} registry.
COMMENT
COMMENT <p>Many methods of this class are called on both the logical client and logical server,
COMMENT so take caution when using those methods. The logical side can be checked using
COMMENT {@link World#isClient}. See also <a href="https://fabricmc.net/wiki/tutorial:side">
COMMENT the Fabric Wiki article</a>. It is also important that methods that take {@link LivingEntity}
COMMENT as an argument can be called by non-players (such as foxes eating food), which causes
COMMENT a crash if the code performs unchecked casting.
COMMENT
COMMENT @see BlockItem
COMMENT @see ItemStack
COMMENT @see net.minecraft.inventory.Inventory
FIELD field_27017 LOGGER Lorg/slf4j/Logger;
FIELD field_30887 DEFAULT_MAX_COUNT I
FIELD field_30889 ITEM_BAR_STEPS I
FIELD field_36401 registryEntry Lnet/minecraft/class_6880$class_6883;
FIELD field_40209 requiredFeatures Lnet/minecraft/class_7699;
FIELD field_49263 components Lnet/minecraft/class_9323;
FIELD field_49998 MAX_MAX_COUNT I
FIELD field_8001 ATTACK_SPEED_MODIFIER_ID Ljava/util/UUID;
FIELD field_8003 BLOCK_ITEMS Ljava/util/Map;
FIELD field_8006 ATTACK_DAMAGE_MODIFIER_ID Ljava/util/UUID;
FIELD field_8008 recipeRemainder Lnet/minecraft/class_1792;
FIELD field_8014 translationKey Ljava/lang/String;
METHOD <init> (Lnet/minecraft/class_1792$class_1793;)V
ARG 1 settings
METHOD method_16698 isNetworkSynced ()Z
COMMENT {@return whether the item needs to sync additional data to clients}
COMMENT
COMMENT <p>Items should ideally store all necessary information in the stack's components.
COMMENT However, this is not always possible for things like maps. In those cases,
COMMENT items can send a packet to the player holding it that syncs additional data.
COMMENT Such items must subclass {@link NetworkSyncedItem}.
COMMENT
COMMENT @see NetworkSyncedItem
METHOD method_21831 getDrinkSound ()Lnet/minecraft/class_3414;
COMMENT {@return the sound for drinking the item}
METHOD method_31565 onStackClicked (Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;)Z
COMMENT Called when the item at the cursor is clicked at {@code slot}.
COMMENT
COMMENT <p>While this method is usually called on the logical server, it can also be called on
COMMENT the logical client, so take caution when overriding this method. The logical side can be
COMMENT checked using {@link World#isClient}.
COMMENT
COMMENT <p>For example, this is called on {@link BundleItem} when the cursor holds
COMMENT a bundle and the player clicks on the slot.
COMMENT
COMMENT @return whether the action was successful
ARG 1 stack
COMMENT the stack the cursor holds
ARG 2 slot
COMMENT the clicked slot
ARG 3 clickType
ARG 4 player
METHOD method_31566 onClicked (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
COMMENT Called when the item at {@code slot} gets clicked by the cursor
COMMENT holding {@code otherStack}.
COMMENT
COMMENT <p>While this method is usually called on the logical server, it can also be called on
COMMENT the logical client, so take caution when overriding this method. The logical side can be
COMMENT checked using {@link World#isClient}.
COMMENT
COMMENT <p>For example, this is called on {@link BundleItem} when the cursor holds
COMMENT an item and the player clicks on the slot that has a bundle.
COMMENT
COMMENT @return whether the action was successful
ARG 1 stack
COMMENT the slot's stack
ARG 2 otherStack
COMMENT the stack the cursor holds
ARG 3 slot
COMMENT the clicked slot
ARG 4 clickType
ARG 5 player
ARG 6 cursorStackReference
METHOD method_31567 isItemBarVisible (Lnet/minecraft/class_1799;)Z
COMMENT {@return whether to show the item bar for {@code stack}}
COMMENT
COMMENT <p>Item bar is usually used to display durability of the stack.
COMMENT
COMMENT <p>When overriding this, {@link #getItemBarStep} and {@link #getItemBarColor} should
COMMENT also be overridden.
ARG 1 stack
METHOD method_31568 canBeNested ()Z
COMMENT @return true if the item can be placed inside of shulker boxes or bundles.
METHOD method_31569 getItemBarStep (Lnet/minecraft/class_1799;)I
COMMENT {@return the step, or the length of the colored area of the item bar, for
COMMENT {@code stack}}
COMMENT
COMMENT <p>This is between {@code 0.0f} and {code 13.0f}. By default, this is
COMMENT {@code durability * 13.0f / maxDurability}.
COMMENT
COMMENT <p>When overriding this, {@link #isItemBarVisible} and {@link #getItemBarColor} should
COMMENT also be overridden.
ARG 1 stack
METHOD method_31571 getItemBarColor (Lnet/minecraft/class_1799;)I
COMMENT {@return the RGB color of the item bar, usually used for durability display}
COMMENT
COMMENT <p>When overriding this, {@link #isItemBarVisible} and {@link #getItemBarStep} should
COMMENT also be overridden.
ARG 1 stack
METHOD method_32346 getTooltipData (Lnet/minecraft/class_1799;)Ljava/util/Optional;
ARG 1 stack
METHOD method_33261 onItemEntityDestroyed (Lnet/minecraft/class_1542;)V
COMMENT Called on the server when an {@link ItemEntity} holding this item gets destroyed.
COMMENT This can happen due to fire, lava, cactus, explosion, etc. Items that can hold
COMMENT other items should override this to drop its contents.
COMMENT
COMMENT @see ItemUsage#spawnItemContents
ARG 1 entity
METHOD method_40131 getRegistryEntry ()Lnet/minecraft/class_6880$class_6883;
METHOD method_54465 onCraftByPlayer (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;)V
COMMENT Called when a player acquires the item by crafting, smelting, smithing, etc.
COMMENT
COMMENT <p>Not called when the item is automatically created, such as via a crafter.
ARG 1 stack
ARG 2 world
ARG 3 player
METHOD method_57336 getBreakSound ()Lnet/minecraft/class_3414;
METHOD method_57347 getComponents ()Lnet/minecraft/class_9323;
METHOD method_58403 getBonusAttackDamage (Lnet/minecraft/class_1657;F)F
ARG 1 player
ARG 2 baseAttackDamage
METHOD method_58404 getMiningSpeed (Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)F
ARG 1 stack
ARG 2 state
METHOD method_58405 isCorrectForDrops (Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)Z
ARG 1 stack
ARG 2 state
METHOD method_59036 onViewInChest (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1263;)V
ARG 1 stack
ARG 2 world
ARG 3 pos
ARG 4 inventory
METHOD method_59037 translationKey (Ljava/lang/String;)Lnet/minecraft/class_1792;
ARG 1 translationKey
METHOD method_7836 use (Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1271;
COMMENT Called when the player uses (or starts using) the item.
COMMENT The use action, by default, is bound to the right mouse button.
COMMENT This method checks the player's hunger when the item is a food, and will
COMMENT {@linkplain TypedActionResult#pass pass} in all other cases by default.
COMMENT
COMMENT <p>If the item {@linkplain #getMaxUseTime can be used for multiple ticks}, then
COMMENT this will only be called when the player starts using it. After that,
COMMENT {@link #usageTick} is called every tick until the player {@linkplain #finishUsing
COMMENT finishes using the item}.
COMMENT
COMMENT <p>This method is called on both the logical client and logical server, so take caution when overriding this method.
COMMENT The logical side can be checked using {@link net.minecraft.world.World#isClient() world.isClient()}.
COMMENT
COMMENT @return a typed action result that specifies whether using the item was successful.
COMMENT The action result contains the new item stack that the player's hand will be set to.
ARG 1 world
COMMENT the world the item was used in
ARG 2 user
COMMENT the player who used the item
ARG 3 hand
COMMENT the hand used
METHOD method_7837 getEnchantability ()I
COMMENT Gets the enchantability of an item.
COMMENT This specifies the ability of an item to receive enchantments when enchanted using an enchanting table.
COMMENT As the value increases, the amount and level of enchantments applied increase.
COMMENT
COMMENT <p>If the value of this method is 0, the item cannot be enchanted using an enchanting table.
METHOD method_7838 isUsedOnRelease (Lnet/minecraft/class_1799;)Z
ARG 1 stack
METHOD method_7840 onStoppedUsing (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)V
COMMENT Called on both the client and the server when an entity stops using an item
COMMENT before reaching the {@linkplain #getMaxUseTime maximum use time}. If the time was
COMMENT reached, {@link #finishUsing} is called instead.
COMMENT
COMMENT <p>This method is called on both the logical client and logical server, so take caution
COMMENT when overriding this method. The logical side can be checked using {@link
COMMENT World#isClient}.
COMMENT
COMMENT <p>{@code user} might not be a player in some cases. For example, this occurs when
COMMENT an entity uses a crossbow.
ARG 1 stack
ARG 2 world
ARG 3 user
ARG 4 remainingUseTicks
METHOD method_7843 onCraft (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;)V
COMMENT Called when the item is made by crafting, smelting, smithing, etc.
ARG 1 stack
ARG 2 world
METHOD method_7844 getAttributeModifiers (Lnet/minecraft/class_1304;)Lcom/google/common/collect/Multimap;
COMMENT {@return the attribute modifiers the item provides}
COMMENT
COMMENT <p>Tools and armor should override this to specify the attack damage or armor points.
ARG 1 slot
METHOD method_7847 useOnEntity (Lnet/minecraft/class_1799;Lnet/minecraft/class_1657;Lnet/minecraft/class_1309;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1269;
COMMENT Called on both the client and the server when a player uses the item on an entity.
COMMENT
COMMENT <p>This method is called on both the logical client and logical server, so take caution
COMMENT when overriding this method. The logical side can be checked using {@link
COMMENT World#isClient}.
COMMENT
COMMENT <p>This should be used if the item can be used on multiple types of entities,
COMMENT such as name tags or saddles.
COMMENT
COMMENT @return the action result
ARG 1 stack
ARG 2 user
ARG 3 entity
ARG 4 hand
METHOD method_7848 getName ()Lnet/minecraft/class_2561;
METHOD method_7851 appendTooltip (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Ljava/util/List;Lnet/minecraft/class_1836;)V
COMMENT Called by the client to append tooltips to an item. Subclasses can override
COMMENT this and add custom tooltips to {@code tooltip} list.
ARG 1 stack
ARG 2 world
ARG 3 tooltip
COMMENT the list of tooltips to show
ARG 4 context
METHOD method_7852 usageTick (Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;Lnet/minecraft/class_1799;I)V
COMMENT Called on both the server and the client every tick while an entity uses
COMMENT the item. Currently used by {@link CrossbowItem} to charge the crossbow.
COMMENT If this is overridden, {@link #getMaxUseTime} should also be overridden to
COMMENT return a positive value.
COMMENT
COMMENT @see #finishUsing
COMMENT @see #use
ARG 1 world
ARG 2 user
ARG 3 stack
ARG 4 remainingUseTicks
COMMENT how long it's left until the entity finishes using the item, in ticks
METHOD method_7853 getUseAction (Lnet/minecraft/class_1799;)Lnet/minecraft/class_1839;
COMMENT {@return the use action the item should perform}
ARG 1 stack
METHOD method_7854 getDefaultStack ()Lnet/minecraft/class_1799;
COMMENT {@return the default stack for this item}
COMMENT
COMMENT <p>Items that expect certain components in the item stack should override
COMMENT this method to return the stack with the component data.
METHOD method_7857 hasRecipeRemainder ()Z
COMMENT Checks if this item has a remainder item that is left behind when used as a crafting ingredient.
METHOD method_7858 getRecipeRemainder ()Lnet/minecraft/class_1792;
COMMENT Gets the remainder item that should be left behind when this item is used as a crafting ingredient.
METHOD method_7860 postProcessComponents (Lnet/minecraft/class_1799;)V
COMMENT Processes the components applied to an item stack of this item.
COMMENT
COMMENT <p>This is only used in vanilla to process player head component data.
ARG 1 stack
METHOD method_7861 finishUsing (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;)Lnet/minecraft/class_1799;
COMMENT Called when an entity finishes using the item, such as eating food or drinking a potion.
COMMENT This method handles eating food by default.
COMMENT
COMMENT <p>This method is called on both the logical client and logical server, so take caution
COMMENT when overriding this method. The logical side can be checked using {@link
COMMENT World#isClient}.
COMMENT
COMMENT <p>{@code user} might not be a player in some cases. For example, this occurs when a fox
COMMENT eats food or when a wandering trader drinks milk.
COMMENT
COMMENT @return the new item stack after using the item
ARG 1 stack
ARG 2 world
ARG 3 user
METHOD method_7864 getName (Lnet/minecraft/class_1799;)Lnet/minecraft/class_2561;
ARG 1 stack
METHOD method_7866 getTranslationKey (Lnet/minecraft/class_1799;)Ljava/lang/String;
COMMENT Gets the translation key of this item using the provided item stack for context.
ARG 1 stack
METHOD method_7867 fromBlock (Lnet/minecraft/class_2248;)Lnet/minecraft/class_1792;
COMMENT @deprecated Please use {@link Block#asItem}
ARG 0 block
METHOD method_7869 getOrCreateTranslationKey ()Ljava/lang/String;
METHOD method_7870 isEnchantable (Lnet/minecraft/class_1799;)Z
COMMENT {@return whether the given {@link ItemStack} is enchantable}
COMMENT
COMMENT <p>By default, ItemStacks are enchantable if their max stack count is 1 and they can be damaged.
ARG 1 stack
METHOD method_7872 raycast (Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_3959$class_242;)Lnet/minecraft/class_3965;
ARG 0 world
ARG 1 player
ARG 2 fluidHandling
METHOD method_7873 postHit (Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;Lnet/minecraft/class_1309;)Z
COMMENT Called on the server when the item is used to hit an entity.
COMMENT
COMMENT <p>Tools and melee weapons should override this to damage the stack.
COMMENT
COMMENT @return whether the item's use stat should be incremented
COMMENT @see ItemStack#damage(int, LivingEntity, EquipmentSlot)
ARG 1 stack
ARG 2 target
ARG 3 attacker
METHOD method_7875 byRawId (I)Lnet/minecraft/class_1792;
COMMENT {@return the item from its raw ID}
ARG 0 id
METHOD method_7876 getTranslationKey ()Ljava/lang/String;
COMMENT Gets the translation key of this item.
METHOD method_7878 canRepair (Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z
COMMENT {@return whether {@code stack} can be repaired using {@code ingredient}}
COMMENT
COMMENT <p>This only handles repairing using the ingredient such as diamonds, and does
COMMENT not handle combining tools or armor.
ARG 1 stack
ARG 2 ingredient
METHOD method_7879 postMine (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_2680;Lnet/minecraft/class_2338;Lnet/minecraft/class_1309;)Z
COMMENT Called on the server when the item is used to break a block.
COMMENT
COMMENT <p>Tools and melee weapons should override this to damage the stack, after
COMMENT checking if the block's hardness is larger than {@code 0.0f}.
COMMENT
COMMENT @return whether the item's use stat should be incremented
COMMENT @see net.minecraft.block.AbstractBlock.AbstractBlockState#getHardness
COMMENT @see ItemStack#damage(int, LivingEntity, EquipmentSlot)
ARG 1 stack
ARG 2 world
ARG 3 state
ARG 4 pos
ARG 5 miner
METHOD method_7880 getRawId (Lnet/minecraft/class_1792;)I
COMMENT {@return the raw ID of {@code item}, or 0 if passed {@code null}}
ARG 0 item
METHOD method_7881 getMaxUseTime (Lnet/minecraft/class_1799;)I
COMMENT {@return the maximum use (right-click) time of this item, in ticks}
COMMENT Once a player has used an item for said number of ticks, they stop using it, and {@link Item#finishUsing} is called.
ARG 1 stack
METHOD method_7882 getMaxCount ()I
COMMENT {@return the maximum stack count of any ItemStack with this item} Can be configured through {@link Item.Settings#maxCount(int) settings.maxCount()}.
METHOD method_7884 useOnBlock (Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;
COMMENT Called when an item is used on a block.
COMMENT
COMMENT <p>This method is called on both the logical client and logical server, so take caution when using this method.
COMMENT The logical side can be checked using {@link net.minecraft.world.World#isClient() context.getWorld().isClient()}.
COMMENT
COMMENT @return an action result that specifies if using the item on a block was successful.
ARG 1 context
COMMENT the usage context
METHOD method_7885 canMine (Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1657;)Z
COMMENT {@return whether a player can break a block while holding the item}
COMMENT
COMMENT <p>This is to check whether the player can start breaking the block in the
COMMENT first place; this does not check if the item is a correct tool to mine the block.
COMMENT Melee weapons should override this to return {@code false}, unless it is also
COMMENT intended to be used as a tool.
ARG 1 state
ARG 2 world
ARG 3 pos
ARG 4 miner
METHOD method_7886 hasGlint (Lnet/minecraft/class_1799;)Z
COMMENT Checks if the glint effect should be applied when the item is rendered.
COMMENT
COMMENT <p>By default, returns true if the item has enchantments.
ARG 1 stack
METHOD method_7888 inventoryTick (Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_1297;IZ)V
COMMENT Called on both the client and the server every tick if the item is in the player's inventory.
COMMENT
COMMENT <p>This method is called on both the logical client and logical server, so take caution
COMMENT when overriding this method. The logical side can be checked using {@link
COMMENT World#isClient}.
ARG 1 stack
ARG 2 world
ARG 3 entity
COMMENT the entity holding the item; usually a player
ARG 4 slot
ARG 5 selected
COMMENT whether the item is in the selected hotbar slot
CLASS class_1793 Settings
COMMENT Item settings configure behaviors common to all items, such as the stack's max
COMMENT count. An instance of this must be passed to the constructor
COMMENT of {@link Item} (or most of its subclasses).
FIELD field_40210 requiredFeatures Lnet/minecraft/class_7699;
FIELD field_49264 COMPONENT_MAP_INTERNER Lcom/google/common/collect/Interner;
FIELD field_49265 components Lnet/minecraft/class_9323$class_9324;
FIELD field_8018 recipeRemainder Lnet/minecraft/class_1792;
METHOD method_19265 food (Lnet/minecraft/class_4174;)Lnet/minecraft/class_1792$class_1793;
COMMENT When set, any item configured with this Settings instance will be edible based on the provided {@link FoodComponent}.
COMMENT
COMMENT @return this instance
ARG 1 foodComponent
COMMENT configured food properties for any item using this Settings instance
METHOD method_24359 fireproof ()Lnet/minecraft/class_1792$class_1793;
COMMENT If called, any item with this Settings instance is immune to fire and lava damage.
COMMENT
COMMENT @return this instance
METHOD method_45434 requires ([Lnet/minecraft/class_7696;)Lnet/minecraft/class_1792$class_1793;
ARG 1 features
METHOD method_57348 attributeModifiers (Lnet/minecraft/class_9285;)Lnet/minecraft/class_1792$class_1793;
ARG 1 attributeModifiersComponent
METHOD method_57349 component (Lnet/minecraft/class_9331;Ljava/lang/Object;)Lnet/minecraft/class_1792$class_1793;
ARG 1 type
ARG 2 value
METHOD method_57350 getComponents ()Lnet/minecraft/class_9323;
METHOD method_58406 getValidatedComponents ()Lnet/minecraft/class_9323;
METHOD method_7889 maxCount (I)Lnet/minecraft/class_1792$class_1793;
COMMENT Sets the maximum stack count of any ItemStack with an Item using this Settings instance.
COMMENT
COMMENT <p>Note that a count over 64 leads to unreliable behavior in GUIs.
COMMENT Damageable items can not have a maximum stack count (they default to 1).
COMMENT An Item.Settings' max count defaults to 64.
COMMENT
COMMENT @throws RuntimeException if this Settings instance also has a max damage value set
COMMENT @return this instance
ARG 1 maxCount
COMMENT maximum stack count of any ItemStack with an item using this Settings instance
METHOD method_7894 rarity (Lnet/minecraft/class_1814;)Lnet/minecraft/class_1792$class_1793;
COMMENT Sets the {@link Rarity} of any item configured with this Settings instance, which changes the color of its name.
COMMENT
COMMENT <p>An item's rarity defaults to {@link Rarity#COMMON}.
COMMENT
COMMENT @return this instance
ARG 1 rarity
COMMENT rarity to apply to items using this Settings instance
METHOD method_7895 maxDamage (I)Lnet/minecraft/class_1792$class_1793;
COMMENT Sets the maximum durability of any item configured with this Settings instance.
COMMENT
COMMENT <p>Note that max stack count is set to 1 when this method is called.
COMMENT
COMMENT @return this instance
ARG 1 maxDamage
COMMENT maximum durability of an ItemStack using an item with this Item.Settings instance
METHOD method_7896 recipeRemainder (Lnet/minecraft/class_1792;)Lnet/minecraft/class_1792$class_1793;
COMMENT Sets the recipe remainder for any item configured with this Settings instance.
COMMENT When an item with a recipe remainder is used in a crafting recipe, the remainder is left in the table or returned to the player.
COMMENT
COMMENT @return this instance
ARG 1 recipeRemainder