CLASS net/minecraft/class_1799 net/minecraft/item/ItemStack COMMENT Represents a stack of items. COMMENT COMMENT

NBT operations

COMMENT COMMENT

NBT serialization

COMMENT COMMENT An Item Stack can be serialized with {@link #writeNbt(NbtCompound)}, and deserialized with {@link #fromNbt(NbtCompound)}. COMMENT COMMENT
COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT
Serialized NBT Structure
KeyTypePurpose
{@code id}{@link net.minecraft.nbt.NbtString}The identifier of the item.
{@code Count}{@link net.minecraft.nbt.NbtByte}The count of items in the stack.
{@code tag}{@link NbtCompound}The item stack's custom NBT.
COMMENT
COMMENT COMMENT

Custom NBT

COMMENT COMMENT The item stack's custom NBT may be used to store extra information, COMMENT like the block entity data for shulker boxes, COMMENT or the damage of a damageable item, etc. COMMENT

COMMENT Various methods are available to interact with the custom NBT, some methods might refer to a "sub NBT", COMMENT a sub NBT is a child element of the custom NBT. COMMENT COMMENT

COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT
Custom NBT operations
CategoryMethodSummary
Custom NBT{@link #hasNbt()}Returns whether the item stack has custom NBT.
Custom NBT{@link #getNbt()}Returns the custom NBT of the item stack.
Custom NBT{@link #getOrCreateNbt()}Returns the custom NBT of the item stack, or creates one if absent.
Custom NBT{@link #setNbt(NbtCompound)}Sets the custom NBT of the item stack.
Sub Custom NBT{@link #getSubNbt(String)}Returns the sub NBT compound at the specified key.
Sub Custom NBT{@link #getOrCreateSubNbt(String)}Returns the sub NBT compound at the specified key, or create one if absent.
Sub Custom NBT{@link #removeSubNbt(String)}Removes the sub NBT element at the specified key.
Sub Custom NBT{@link #setSubNbt(String, NbtElement)}Sets the sub NBT element at the specified key.
COMMENT
FIELD field_24092 LORE_STYLE Lnet/minecraft/class_2583; FIELD field_24093 holder Lnet/minecraft/class_1297; FIELD field_24671 CODEC Lcom/mojang/serialization/Codec; FIELD field_30890 ENCHANTMENTS_KEY Ljava/lang/String; COMMENT The key of the enchantments in an item stack's custom NBT, whose value is {@value}. FIELD field_30893 DISPLAY_KEY Ljava/lang/String; COMMENT The key of the display NBT in an item stack's custom NBT, whose value is {@value}. FIELD field_30894 NAME_KEY Ljava/lang/String; COMMENT The key of the item stack's name in the {@linkplain #DISPLAY_KEY display NBT}, whose value is {@value}. FIELD field_30895 LORE_KEY Ljava/lang/String; COMMENT The key of the item stack's lore in the {@linkplain #DISPLAY_KEY display NBT}, whose value is {@value}. FIELD field_30896 DAMAGE_KEY Ljava/lang/String; COMMENT The key of the damage in an item stack's custom NBT, whose value is {@value}. FIELD field_30897 COLOR_KEY Ljava/lang/String; COMMENT The key of the item's color in the {@linkplain #DISPLAY_KEY display NBT}, whose value is {@value}. FIELD field_30898 UNBREAKABLE_KEY Ljava/lang/String; COMMENT The key of the unbreakable boolean in an item stack's custom NBT, whose value is {@value}. FIELD field_30899 REPAIR_COST_KEY Ljava/lang/String; COMMENT The key of the repair cost in an item stack's custom NBT, whose value is {@value}. FIELD field_30900 CAN_DESTROY_KEY Ljava/lang/String; FIELD field_30901 CAN_PLACE_ON_KEY Ljava/lang/String; FIELD field_30902 HIDE_FLAGS_KEY Ljava/lang/String; FIELD field_8029 MODIFIER_FORMAT Ljava/text/DecimalFormat; FIELD field_8030 cooldown I FIELD field_8031 count I FIELD field_8032 lastPlaceOnPos Lnet/minecraft/class_2694; FIELD field_8033 LOGGER Lorg/apache/logging/log4j/Logger; FIELD field_8034 lastPlaceOnResult Z FIELD field_8035 lastDestroyResult Z FIELD field_8036 empty Z FIELD field_8037 EMPTY Lnet/minecraft/class_1799; FIELD field_8038 item Lnet/minecraft/class_1792; FIELD field_8039 lastDestroyPos Lnet/minecraft/class_2694; FIELD field_8040 nbt Lnet/minecraft/class_2487; COMMENT Repesents the item stack's custom NBT. COMMENT

COMMENT Stored at the key {@code tag} in the serialized item stack NBT. COMMENT COMMENT @see Item Stack NBT Operations METHOD (Lnet/minecraft/class_1935;)V ARG 1 item METHOD (Lnet/minecraft/class_1935;I)V ARG 1 item ARG 2 count METHOD (Lnet/minecraft/class_1935;ILjava/util/Optional;)V ARG 1 item ARG 2 count ARG 3 nbt METHOD (Lnet/minecraft/class_2487;)V ARG 1 nbt METHOD method_17869 (Ljava/util/List;Lnet/minecraft/class_2487;Lnet/minecraft/class_1887;)V ARG 2 e METHOD method_17870 appendEnchantments (Ljava/util/List;Lnet/minecraft/class_2499;)V ARG 0 tooltip ARG 1 enchantments METHOD method_19267 isFood ()Z METHOD method_21832 getDrinkSound ()Lnet/minecraft/class_3414; METHOD method_21833 getEatSound ()Lnet/minecraft/class_3414; METHOD method_26963 (Ljava/text/DecimalFormat;)V ARG 0 decimalFormat METHOD method_27319 getHolder ()Lnet/minecraft/class_1297; METHOD method_27320 setHolder (Lnet/minecraft/class_1297;)V ARG 1 holder METHOD method_28376 (Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App; ARG 0 instance METHOD method_28377 (Lnet/minecraft/class_1799;)Ljava/util/Optional; ARG 0 stack METHOD method_28378 (Lnet/minecraft/class_1799;)Ljava/lang/Integer; ARG 0 stack METHOD method_28379 (Lnet/minecraft/class_1799;)Lnet/minecraft/class_1792; ARG 0 stack METHOD method_30266 getHideFlags ()I METHOD method_30267 isSectionVisible (ILnet/minecraft/class_1799$class_5422;)Z COMMENT Determines whether the given tooltip section will be visible according to the given flags. ARG 0 flags ARG 1 tooltipSection METHOD method_30268 addHideFlag (Lnet/minecraft/class_1799$class_5422;)V ARG 1 tooltipSection METHOD method_31572 getEquipSound ()Lnet/minecraft/class_3414; METHOD method_31573 isIn (Lnet/minecraft/class_3494;)Z ARG 1 tag METHOD method_31574 isOf (Lnet/minecraft/class_1792;)Z ARG 1 item METHOD method_31575 onStackClicked (Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;)Z ARG 1 slot ARG 2 clickType ARG 3 player METHOD method_31576 onClicked (Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;Lnet/minecraft/class_5630;)Z ARG 1 stack ARG 2 slot ARG 3 clickType ARG 4 player ARG 5 cursorStackReference METHOD method_31577 canCombine (Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z ARG 0 stack ARG 1 otherStack METHOD method_31578 isItemBarVisible ()Z METHOD method_31579 getItemBarStep ()I METHOD method_31580 getItemBarColor ()I METHOD method_32347 getTooltipData ()Ljava/util/Optional; METHOD method_33262 onItemEntityDestroyed (Lnet/minecraft/class_1542;)V ARG 1 entity METHOD method_7909 getItem ()Lnet/minecraft/class_1792; METHOD method_7910 finishUsing (Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;)Lnet/minecraft/class_1799; ARG 1 world ARG 2 user METHOD method_7911 getOrCreateSubNbt (Ljava/lang/String;)Lnet/minecraft/class_2487; COMMENT {@return the compound NBT at the specified key in this item stack's NBT, or a new compound if absent} COMMENT COMMENT @see Item Stack NBT Operations ARG 1 key METHOD method_7912 setCooldown (I)V ARG 1 cooldown METHOD method_7913 use (Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1271; ARG 1 world ARG 2 user ARG 3 hand METHOD method_7914 getMaxCount ()I METHOD method_7915 fromNbt (Lnet/minecraft/class_2487;)Lnet/minecraft/class_1799; COMMENT Deserializes an item stack from NBT. COMMENT COMMENT @see Item Stack NBT Operations ARG 0 nbt METHOD method_7916 addAttributeModifier (Lnet/minecraft/class_1320;Lnet/minecraft/class_1322;Lnet/minecraft/class_1304;)V ARG 1 attribute ARG 2 modifier ARG 3 slot METHOD method_7917 inventoryTick (Lnet/minecraft/class_1937;Lnet/minecraft/class_1297;IZ)V ARG 1 world ARG 2 entity ARG 3 slot ARG 4 selected METHOD method_7918 areBlocksEqual (Lnet/minecraft/class_2694;Lnet/minecraft/class_2694;)Z ARG 0 first ARG 1 second METHOD method_7919 getDamage ()I METHOD method_7920 useOnEntity (Lnet/minecraft/class_1657;Lnet/minecraft/class_1309;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1269; ARG 1 user ARG 2 entity ARG 3 hand METHOD method_7921 getEnchantments ()Lnet/minecraft/class_2499; METHOD method_7922 getTranslationKey ()Ljava/lang/String; METHOD method_7923 isEnchantable ()Z METHOD method_7924 getMiningSpeedMultiplier (Lnet/minecraft/class_2680;)F ARG 1 state METHOD method_7925 removeCustomName ()V METHOD method_7926 getAttributeModifiers (Lnet/minecraft/class_1304;)Lcom/google/common/collect/Multimap; ARG 1 slot METHOD method_7927 setRepairCost (I)V ARG 1 repairCost METHOD method_7928 getRepairCost ()I METHOD method_7929 isItemEqual (Lnet/minecraft/class_1799;)Z ARG 1 stack METHOD method_7930 onStoppedUsing (Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)V ARG 1 world ARG 2 user ARG 3 remainingUseTicks METHOD method_7932 getRarity ()Lnet/minecraft/class_1814; METHOD method_7933 increment (I)V COMMENT Increments the count of items in this item stack. ARG 1 amount COMMENT the amount to increment METHOD method_7934 decrement (I)V COMMENT Decrements the count of items in this item stack. ARG 1 amount COMMENT the amount to decrement METHOD method_7935 getMaxUseTime ()I METHOD method_7936 getMaxDamage ()I METHOD method_7937 parseBlockTag (Ljava/lang/String;)Ljava/util/Collection; ARG 0 tag METHOD method_7938 hasCustomName ()Z METHOD method_7939 setCount (I)V COMMENT Sets the count of items in this item stack. ARG 1 count COMMENT the count of items METHOD method_7940 canDestroy (Lnet/minecraft/class_5415;Lnet/minecraft/class_2694;)Z ARG 1 tagManager ARG 2 pos METHOD method_7941 getSubNbt (Ljava/lang/String;)Lnet/minecraft/class_2487; COMMENT {@return the NBT compound at the specified key in this item stack's custom NBT, may be {@code null}} COMMENT COMMENT @see Item Stack NBT Operations ARG 1 key METHOD method_7942 hasEnchantments ()Z METHOD method_7944 canPlaceOn (Lnet/minecraft/class_5415;Lnet/minecraft/class_2694;)Z ARG 1 tagManager ARG 2 pos METHOD method_7945 getFrame ()Lnet/minecraft/class_1533; METHOD method_7946 isStackable ()Z METHOD method_7947 getCount ()I COMMENT {@return the count of items in this item stack} METHOD method_7948 getOrCreateNbt ()Lnet/minecraft/class_2487; COMMENT Returns the custom NBT of this item stack, or creates the custom NBT if the item stack did not have a custom NBT previously. COMMENT COMMENT @return the custom NBT of this item stack COMMENT COMMENT @see Item Stack NBT Operations METHOD method_7949 usageTick (Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)V ARG 1 world ARG 2 user ARG 3 remainingUseTicks METHOD method_7950 getTooltip (Lnet/minecraft/class_1657;Lnet/minecraft/class_1836;)Ljava/util/List; ARG 1 player ARG 2 context METHOD method_7951 isSuitableFor (Lnet/minecraft/class_2680;)Z COMMENT Determines whether this item can be used as a suitable tool for mining the specified block. COMMENT

COMMENT Depending on block implementation, when combined together, the correct item and block may achieve a better mining speed and yield COMMENT drops that would not be obtained when mining otherwise. COMMENT COMMENT @return values consistent with calls to {@link Item#isSuitableFor} COMMENT @see Item#isSuitableFor(BlockState) ARG 1 state METHOD method_7952 postMine (Lnet/minecraft/class_1937;Lnet/minecraft/class_2680;Lnet/minecraft/class_2338;Lnet/minecraft/class_1657;)V ARG 1 world ARG 2 state ARG 3 pos ARG 4 miner METHOD method_7953 writeNbt (Lnet/minecraft/class_2487;)Lnet/minecraft/class_2487; COMMENT Writes the serialized item stack into the given {@link NbtCompound}. COMMENT COMMENT @return the written NBT compound COMMENT @see Item Stack NBT Operations ARG 1 nbt COMMENT the NBT compound to write to METHOD method_7954 toHoverableText ()Lnet/minecraft/class_2561; METHOD method_7955 (Lnet/minecraft/class_5250;)Lnet/minecraft/class_5250; ARG 0 text METHOD method_7956 damage (ILnet/minecraft/class_1309;Ljava/util/function/Consumer;)V ARG 1 amount ARG 2 entity ARG 3 breakCallback METHOD method_7957 updateEmptyState ()V METHOD method_7958 hasGlint ()Z METHOD method_7959 setSubNbt (Ljava/lang/String;Lnet/minecraft/class_2520;)V COMMENT Sets the given NBT element in the item stack's custom NBT at the specified key. COMMENT COMMENT @see Item Stack NBT Operations ARG 1 key COMMENT the key where to put the given {@link NbtElement} ARG 2 element COMMENT the NBT element to put METHOD method_7960 isEmpty ()Z COMMENT {@return whether this item stack is empty} METHOD method_7961 isInFrame ()Z METHOD method_7962 isItemEqualIgnoreDamage (Lnet/minecraft/class_1799;)Z ARG 1 stack METHOD method_7963 isDamageable ()Z METHOD method_7964 getName ()Lnet/minecraft/class_2561; METHOD method_7965 getCooldown ()I METHOD method_7966 (Lnet/minecraft/class_2583;)Lnet/minecraft/class_2583; ARG 1 style METHOD method_7967 isUsedOnRelease ()Z METHOD method_7968 isEqual (Lnet/minecraft/class_1799;)Z ARG 1 stack METHOD method_7969 getNbt ()Lnet/minecraft/class_2487; COMMENT {@return the custom NBT of this item stack, may be {@code null}} COMMENT COMMENT @see Item Stack NBT Operations METHOD method_7970 damage (ILjava/util/Random;Lnet/minecraft/class_3222;)Z ARG 1 amount ARG 2 random ARG 3 player METHOD method_7971 split (I)Lnet/minecraft/class_1799; ARG 1 amount METHOD method_7972 copy ()Lnet/minecraft/class_1799; COMMENT Creates and returns a copy of this item stack. METHOD method_7973 areEqual (Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z ARG 0 left ARG 1 right METHOD method_7974 setDamage (I)V ARG 1 damage METHOD method_7975 areNbtEqual (Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z COMMENT {@return whether the given item stacks have equivalent custom NBT} ARG 0 left ARG 1 right METHOD method_7976 getUseAction ()Lnet/minecraft/class_1839; METHOD method_7977 setCustomName (Lnet/minecraft/class_2561;)Lnet/minecraft/class_1799; ARG 1 name METHOD method_7978 addEnchantment (Lnet/minecraft/class_1887;I)V ARG 1 enchantment ARG 2 level METHOD method_7979 postHit (Lnet/minecraft/class_1309;Lnet/minecraft/class_1657;)V ARG 1 target ARG 2 attacker METHOD method_7980 setNbt (Lnet/minecraft/class_2487;)V COMMENT Sets the custom NBT of this item stack. COMMENT COMMENT @see Item Stack NBT Operations ARG 1 nbt COMMENT the custom NBT compound, may be {@code null} to reset METHOD method_7981 useOnBlock (Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269; ARG 1 context METHOD method_7982 onCraft (Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;I)V ARG 1 world ARG 2 player ARG 3 amount METHOD method_7983 removeSubNbt (Ljava/lang/String;)V COMMENT Removes the sub NBT element at the specified key in this item stack's custom NBT. COMMENT COMMENT @see Item Stack NBT Operations ARG 1 key METHOD method_7984 areItemsEqualIgnoreDamage (Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z ARG 0 left ARG 1 right METHOD method_7985 hasNbt ()Z COMMENT {@return whether this item stack has custom NBT} COMMENT COMMENT @see Item Stack NBT Operations METHOD method_7986 isDamaged ()Z METHOD method_7987 areItemsEqual (Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Z ARG 0 left ARG 1 right CLASS class_5422 TooltipSection FIELD field_25775 flag I METHOD method_30269 getFlag ()I