Class ItemStack

java.lang.Object
net.minecraft.item.ItemStack

public final class ItemStack
extends Object
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<ItemStack> CODEC
    • LOGGER

      private static final Logger LOGGER
    • EMPTY

      public static final ItemStack EMPTY
    • MODIFIER_FORMAT

      public static final DecimalFormat MODIFIER_FORMAT
    • LORE_STYLE

      private static final Style LORE_STYLE
    • count

      private int count
    • cooldown

      private int cooldown
    • item

      @Deprecated private final Item item
      Deprecated.
    • tag

      private CompoundTag tag
    • empty

      private boolean empty
    • holder

      private Entity holder
    • lastDestroyPos

      private CachedBlockPosition lastDestroyPos
    • lastDestroyResult

      private boolean lastDestroyResult
    • lastPlaceOnPos

      private CachedBlockPosition lastPlaceOnPos
    • lastPlaceOnResult

      private boolean lastPlaceOnResult
  • Constructor Details

  • Method Details

    • updateEmptyState

      private void updateEmptyState()
    • fromTag

      public static ItemStack fromTag​(CompoundTag tag)
    • isEmpty

      public boolean isEmpty()
    • split

      public ItemStack split​(int amount)
    • getItem

      public Item getItem()
    • useOnBlock

      public ActionResult useOnBlock​(ItemUsageContext context)
    • getMiningSpeedMultiplier

      public float getMiningSpeedMultiplier​(BlockState state)
    • use

      public TypedActionResult<ItemStack> use​(World world, PlayerEntity user, Hand hand)
    • finishUsing

      public ItemStack finishUsing​(World world, LivingEntity user)
    • toTag

      public CompoundTag toTag​(CompoundTag tag)
    • getMaxCount

      public int getMaxCount()
    • isStackable

      public boolean isStackable()
    • isDamageable

      public boolean isDamageable()
    • isDamaged

      public boolean isDamaged()
    • getDamage

      public int getDamage()
    • setDamage

      public void setDamage​(int damage)
    • getMaxDamage

      public int getMaxDamage()
    • damage

      public boolean damage​(int amount, Random random, @Nullable ServerPlayerEntity player)
    • damage

      public <T extends LivingEntity> void damage​(int amount, T entity, Consumer<T> breakCallback)
    • postHit

      public void postHit​(LivingEntity target, PlayerEntity attacker)
    • postMine

      public void postMine​(World world, BlockState state, BlockPos pos, PlayerEntity miner)
    • isEffectiveOn

      public boolean isEffectiveOn​(BlockState state)
    • useOnEntity

      public ActionResult useOnEntity​(PlayerEntity user, LivingEntity entity, Hand hand)
    • copy

      public ItemStack copy()
    • areTagsEqual

      public static boolean areTagsEqual​(ItemStack left, ItemStack right)
    • areEqual

      public static boolean areEqual​(ItemStack left, ItemStack right)
    • isEqual

      private boolean isEqual​(ItemStack stack)
    • areItemsEqualIgnoreDamage

      public static boolean areItemsEqualIgnoreDamage​(ItemStack left, ItemStack right)
    • areItemsEqual

      public static boolean areItemsEqual​(ItemStack left, ItemStack right)
    • isItemEqualIgnoreDamage

      public boolean isItemEqualIgnoreDamage​(ItemStack stack)
    • isItemEqual

      public boolean isItemEqual​(ItemStack stack)
    • getTranslationKey

      public String getTranslationKey()
    • toString

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

      public void inventoryTick​(World world, Entity entity, int slot, boolean selected)
    • onCraft

      public void onCraft​(World world, PlayerEntity player, int amount)
    • getMaxUseTime

      public int getMaxUseTime()
    • getUseAction

      public UseAction getUseAction()
    • onStoppedUsing

      public void onStoppedUsing​(World world, LivingEntity user, int remainingUseTicks)
    • isUsedOnRelease

      public boolean isUsedOnRelease()
    • hasTag

      public boolean hasTag()
    • getTag

      @Nullable public CompoundTag getTag()
    • getOrCreateTag

      public CompoundTag getOrCreateTag()
    • getOrCreateSubTag

      public CompoundTag getOrCreateSubTag​(String key)
    • getSubTag

      @Nullable public CompoundTag getSubTag​(String key)
    • removeSubTag

      public void removeSubTag​(String key)
    • getEnchantments

      public ListTag getEnchantments()
    • setTag

      public void setTag​(@Nullable CompoundTag tag)
    • getName

      public Text getName()
    • setCustomName

      public ItemStack setCustomName​(@Nullable Text name)
    • removeCustomName

      public void removeCustomName()
    • hasCustomName

      public boolean hasCustomName()
    • getTooltip

      @Environment(CLIENT) public List<Text> getTooltip​(@Nullable PlayerEntity player, TooltipContext context)
    • isSectionHidden

      @Environment(CLIENT) private static boolean isSectionHidden​(int flags, ItemStack.TooltipSection tooltipSection)
    • getHideFlags

      @Environment(CLIENT) private int getHideFlags()
    • addHideFlag

      public void addHideFlag​(ItemStack.TooltipSection tooltipSection)
    • appendEnchantments

      @Environment(CLIENT) public static void appendEnchantments​(List<Text> tooltip, ListTag enchantments)
    • parseBlockTag

      @Environment(CLIENT) private static Collection<Text> parseBlockTag​(String tag)
    • hasGlint

      public boolean hasGlint()
    • getRarity

      public Rarity getRarity()
    • isEnchantable

      public boolean isEnchantable()
    • addEnchantment

      public void addEnchantment​(Enchantment enchantment, int level)
    • hasEnchantments

      public boolean hasEnchantments()
    • putSubTag

      public void putSubTag​(String key, Tag tag)
    • isInFrame

      public boolean isInFrame()
    • setHolder

      public void setHolder​(@Nullable Entity holder)
    • getFrame

      @Nullable public ItemFrameEntity getFrame()
    • getHolder

      @Nullable public Entity getHolder()
    • getRepairCost

      public int getRepairCost()
    • setRepairCost

      public void setRepairCost​(int repairCost)
    • getAttributeModifiers

      public Multimap<EntityAttribute,​EntityAttributeModifier> getAttributeModifiers​(EquipmentSlot equipmentSlot)
    • addAttributeModifier

      public void addAttributeModifier​(EntityAttribute entityAttribute, EntityAttributeModifier modifier, @Nullable EquipmentSlot slot)
    • toHoverableText

      public Text toHoverableText()
    • areBlocksEqual

      private static boolean areBlocksEqual​(CachedBlockPosition first, @Nullable CachedBlockPosition second)
    • canDestroy

      public boolean canDestroy​(TagManager tagManager, CachedBlockPosition pos)
    • canPlaceOn

      public boolean canPlaceOn​(TagManager tagManager, CachedBlockPosition pos)
    • getCooldown

      public int getCooldown()
    • setCooldown

      public void setCooldown​(int cooldown)
    • getCount

      public int getCount()
    • setCount

      public void setCount​(int count)
    • increment

      public void increment​(int amount)
    • decrement

      public void decrement​(int amount)
    • usageTick

      public void usageTick​(World world, LivingEntity user, int remainingUseTicks)
    • isFood

      public boolean isFood()
    • getDrinkSound

      public SoundEvent getDrinkSound()
    • getEatSound

      public SoundEvent getEatSound()