Package net.minecraft.world.item
Class ItemStack
java.lang.Object
net.minecraft.world.item.ItemStack
- All Implemented Interfaces:
DataComponentHolder,IForgeItemStack
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ItemStack> (package private) final PatchedDataComponentMapprivate intprivate static final Componentstatic final ItemStackprivate Entityprivate final ItemDeprecated.static final StreamCodec<RegistryFriendlyByteBuf, List<ItemStack>> private static final org.slf4j.Loggerstatic final com.mojang.serialization.Codec<ItemStack> static final StreamCodec<RegistryFriendlyByteBuf, List<ItemStack>> static final StreamCodec<RegistryFriendlyByteBuf, ItemStack> private intstatic final com.mojang.serialization.Codec<ItemStack> static final com.mojang.serialization.Codec<ItemStack> static final StreamCodec<RegistryFriendlyByteBuf, ItemStack> static final com.mojang.serialization.Codec<ItemStack> static final com.mojang.serialization.Codec<ItemStack> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateItemStack(Holder<Item> p_310702_, int p_41605_, DataComponentPatch p_328221_) privateItemStack(ItemLike p_331826_, int p_332766_, PatchedDataComponentMap p_333722_) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAttributeTooltips(Consumer<Component> p_333346_, Player p_332769_) private voidaddModifierTooltip(Consumer<Component> p_332944_, Player p_328442_, Holder<Attribute> p_336373_, AttributeModifier p_332746_) private <T extends TooltipProvider>
voidaddToTooltip(DataComponentType<T> p_331934_, Item.TooltipContext p_333562_, Consumer<Component> p_334534_, TooltipFlag p_333715_) voidapplyComponents(DataComponentMap p_335208_) voidapplyComponents(DataComponentPatch p_328534_) voidapplyComponentsAndValidate(DataComponentPatch p_336111_) booleancanBeHurtBy(DamageSource p_334859_) booleancanBreakBlockInAdventureMode(BlockInWorld p_333133_) booleancanPlaceOnBlockInAdventureMode(BlockInWorld p_331134_) voidconsume(int p_329683_, LivingEntity p_334302_) copy()copyWithCount(int p_256354_) voidenchant(Enchantment p_41664_, int p_41665_) finishUsingItem(Level p_41672_, LivingEntity p_41673_) voidforEachModifier(EquipmentSlot p_331036_, BiConsumer<Holder<Attribute>, AttributeModifier> p_334430_) intintintgetCount()intfloatgetDestroySpeed(BlockState p_41692_) getFrame()getItem()intintintgetTags()getTooltipLines(Item.TooltipContext p_331329_, Player p_41652_, TooltipFlag p_41653_) intvoidgrow(int p_41770_) booleanhasFoil()static inthashItemAndComponents(ItemStack p_334004_) static inthashStackList(List<ItemStack> p_333449_) Deprecated.voidhurtAndBreak(int p_220158_, RandomSource p_220159_, ServerPlayer p_220160_, Runnable p_331215_) voidhurtAndBreak(int p_41623_, LivingEntity p_41624_, EquipmentSlot p_335324_) voidhurtEnemy(LivingEntity p_41641_, Player p_41642_) interactLivingEntity(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) voidinventoryTick(Level p_41667_, Entity p_41668_, int p_41669_, boolean p_41670_) booleanbooleanbooleanbooleanbooleanbooleanbooleanisCorrectToolForDrops(BlockState p_41736_) booleanbooleanbooleanisEmpty()booleanbooleanbooleanisFramed()booleanisItemEnabled(FeatureFlagSet p_250869_) static booleanisSameItem(ItemStack p_287761_, ItemStack p_287676_) static booleanisSameItemSameComponents(ItemStack p_334397_, ItemStack p_331609_) booleanstatic com.mojang.serialization.MapCodec<ItemStack> lenientOptionalFieldOf(String p_336149_) voidlimitSize(int p_328100_) static booleanlistMatches(List<ItemStack> p_335471_, List<ItemStack> p_334624_) Deprecated.static booleanvoidmineBlock(Level p_41687_, BlockState p_41688_, BlockPos p_41689_, Player p_41690_) voidonCraftedBy(Level p_41679_, Player p_41680_, int p_41681_) voidonCraftedBySystem(Level p_311164_) voidonDestroyed(ItemEntity p_150925_) Deprecated.Forge: Use damage source sensitive versionprivate InteractionResultonItemUse(UseOnContext p_41662_, Function<UseOnContext, InteractionResult> callback) onItemUseFirst(UseOnContext p_41662_) voidonUseTick(Level p_41732_, LivingEntity p_41733_, int p_41734_) booleanoverrideOtherStackedOnMe(ItemStack p_150933_, Slot p_150934_, ClickAction p_150935_, Player p_150936_, SlotAccess p_150937_) booleanoverrideStackedOnOther(Slot p_150927_, ClickAction p_150928_, Player p_150929_) parse(HolderLookup.Provider p_332204_, Tag p_336056_) static ItemStackparseOptional(HolderLookup.Provider p_333870_, CompoundTag p_328391_) voidreleaseUsing(Level p_41675_, LivingEntity p_41676_, int p_41677_) <T> Tremove(DataComponentType<? extends T> p_333259_) save(HolderLookup.Provider p_328490_) save(HolderLookup.Provider p_330500_, Tag p_332574_) saveOptional(HolderLookup.Provider p_335413_) <T> Tset(DataComponentType<? super T> p_332666_, T p_335655_) voidsetCount(int p_41765_) voidsetDamageValue(int p_41722_) voidsetEntityRepresentation(Entity p_41637_) voidsetPopTime(int p_41755_) voidshrink(int p_41775_) split(int p_41621_) toString()transmuteCopy(ItemLike p_334328_, int p_334821_) transmuteCopyIgnoreEmpty(ItemLike p_332114_, int p_333334_) <T> Tupdate(DataComponentType<T> p_329905_, T p_329705_, UnaryOperator<T> p_335114_) <T,U> T update(DataComponentType<T> p_331418_, T p_327708_, U p_332086_, BiFunction<T, U, T> p_329834_) use(Level p_41683_, Player p_41684_, InteractionHand p_41685_) useOn(UseOnContext p_41662_) booleanstatic com.mojang.serialization.DataResult<Unit> validateComponents(DataComponentMap p_336343_) private static com.mojang.serialization.DataResult<ItemStack> validateStrict(ItemStack p_332181_) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.core.component.DataComponentHolder
get, getOrDefault, hasMethods inherited from interface net.minecraftforge.common.extensions.IForgeItemStack
canApplyAtEnchantingTable, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, doesSneakBypassUse, elytraFlightTick, getBurnTime, getCraftingRemainingItem, getEnchantmentLevel, getEnchantmentValue, getEntityLifespan, getEquipmentSlot, getHighlightTip, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, isBookEnchantable, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onBlockStartBreak, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onInventoryTick, onStopUsing, shouldCauseBlockBreakReset
-
Field Details
-
ITEM_NON_AIR_CODEC
-
CODEC
-
SINGLE_ITEM_CODEC
-
STRICT_CODEC
-
STRICT_SINGLE_ITEM_CODEC
-
OPTIONAL_CODEC
-
SIMPLE_ITEM_CODEC
-
OPTIONAL_STREAM_CODEC
-
STREAM_CODEC
-
OPTIONAL_LIST_STREAM_CODEC
-
LIST_STREAM_CODEC
-
LOGGER
private static final org.slf4j.Logger LOGGER -
EMPTY
-
DISABLED_ITEM_TOOLTIP
-
count
private int count -
popTime
private int popTime -
item
Deprecated. -
components
-
entityRepresentation
-
-
Constructor Details
-
ItemStack
-
ItemStack
-
ItemStack
-
ItemStack
-
ItemStack
-
ItemStack
-
ItemStack
-
-
Method Details
-
validateStrict
-
validatedStreamCodec
public static StreamCodec<RegistryFriendlyByteBuf,ItemStack> validatedStreamCodec(StreamCodec<RegistryFriendlyByteBuf, ItemStack> p_332790_) -
getTooltipImage
-
getComponents
- Specified by:
getComponentsin interfaceDataComponentHolder
-
getPrototype
-
getComponentsPatch
-
validateComponents
public static com.mojang.serialization.DataResult<Unit> validateComponents(DataComponentMap p_336343_) -
parse
-
parseOptional
-
isEmpty
public boolean isEmpty() -
isItemEnabled
-
split
-
copyAndClear
-
getItem
-
getItemHolder
-
is
-
is
-
is
-
is
-
is
-
getTags
-
useOn
-
onItemUseFirst
- Specified by:
onItemUseFirstin interfaceIForgeItemStack
-
onItemUse
private InteractionResult onItemUse(UseOnContext p_41662_, Function<UseOnContext, InteractionResult> callback) -
getDestroySpeed
-
use
public InteractionResultHolder<ItemStack> use(Level p_41683_, Player p_41684_, InteractionHand p_41685_) -
finishUsingItem
-
save
-
save
-
saveOptional
-
getMaxStackSize
public int getMaxStackSize() -
isStackable
public boolean isStackable() -
isDamageableItem
public boolean isDamageableItem() -
isDamaged
public boolean isDamaged() -
getDamageValue
public int getDamageValue() -
setDamageValue
public void setDamageValue(int p_41722_) -
getMaxDamage
public int getMaxDamage() -
hurtAndBreak
public void hurtAndBreak(int p_220158_, RandomSource p_220159_, @Nullable ServerPlayer p_220160_, Runnable p_331215_) -
hurtAndBreak
-
isBarVisible
public boolean isBarVisible() -
getBarWidth
public int getBarWidth() -
getBarColor
public int getBarColor() -
overrideStackedOnOther
-
overrideOtherStackedOnMe
public boolean overrideOtherStackedOnMe(ItemStack p_150933_, Slot p_150934_, ClickAction p_150935_, Player p_150936_, SlotAccess p_150937_) -
hurtEnemy
-
mineBlock
-
isCorrectToolForDrops
-
interactLivingEntity
public InteractionResult interactLivingEntity(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) -
copy
-
copyWithCount
-
transmuteCopy
-
transmuteCopyIgnoreEmpty
-
matches
-
listMatches
Deprecated. -
isSameItem
-
isSameItemSameComponents
-
lenientOptionalFieldOf
-
hashItemAndComponents
-
hashStackList
Deprecated. -
getDescriptionId
-
toString
-
inventoryTick
-
onCraftedBy
-
onCraftedBySystem
-
getUseDuration
public int getUseDuration() -
getUseAnimation
-
releaseUsing
-
useOnRelease
public boolean useOnRelease() -
set
-
update
@Nullable public <T,U> T update(DataComponentType<T> p_331418_, T p_327708_, U p_332086_, BiFunction<T, U, T> p_329834_) -
update
@Nullable public <T> T update(DataComponentType<T> p_329905_, T p_329705_, UnaryOperator<T> p_335114_) -
remove
-
applyComponentsAndValidate
-
applyComponents
-
applyComponents
-
getHoverName
-
addToTooltip
private <T extends TooltipProvider> void addToTooltip(DataComponentType<T> p_331934_, Item.TooltipContext p_333562_, Consumer<Component> p_334534_, TooltipFlag p_333715_) -
getTooltipLines
public List<Component> getTooltipLines(Item.TooltipContext p_331329_, @Nullable Player p_41652_, TooltipFlag p_41653_) -
addAttributeTooltips
-
addModifierTooltip
-
hasFoil
public boolean hasFoil() -
getRarity
-
isEnchantable
public boolean isEnchantable() -
enchant
-
isEnchanted
public boolean isEnchanted() -
getEnchantments
-
isFramed
public boolean isFramed() -
setEntityRepresentation
-
getFrame
-
getEntityRepresentation
-
forEachModifier
public void forEachModifier(EquipmentSlot p_331036_, BiConsumer<Holder<Attribute>, AttributeModifier> p_334430_) -
getDisplayName
-
canPlaceOnBlockInAdventureMode
-
canBreakBlockInAdventureMode
-
getPopTime
public int getPopTime() -
setPopTime
public void setPopTime(int p_41755_) -
getCount
public int getCount() -
setCount
public void setCount(int p_41765_) -
limitSize
public void limitSize(int p_328100_) -
grow
public void grow(int p_41770_) -
shrink
public void shrink(int p_41775_) -
consume
-
onUseTick
-
onDestroyed
Deprecated.Forge: Use damage source sensitive version -
getDrinkingSound
-
getEatingSound
-
getBreakingSound
-
canBeHurtBy
-