Package net.minecraft.world.item
Class ItemStack
java.lang.Object
net.minecraft.world.item.ItemStack
- All Implemented Interfaces:
DataComponentHolder
,IForgeItemStack
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec
<ItemStack> (package private) final PatchedDataComponentMap
private int
private static final Component
static final ItemStack
private Entity
private final Item
Deprecated.static final StreamCodec
<RegistryFriendlyByteBuf, List<ItemStack>> private static final org.slf4j.Logger
static final com.mojang.serialization.Codec
<ItemStack> static final StreamCodec
<RegistryFriendlyByteBuf, List<ItemStack>> static final StreamCodec
<RegistryFriendlyByteBuf, ItemStack> private int
static 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
ModifierConstructorDescriptionprivate
ItemStack
(Holder<Item> p_310702_, int p_41605_, DataComponentPatch p_328221_) private
ItemStack
(ItemLike p_331826_, int p_332766_, PatchedDataComponentMap p_333722_) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addAttributeTooltips
(Consumer<Component> p_333346_, Player p_332769_) private void
addModifierTooltip
(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_) void
applyComponents
(DataComponentMap p_335208_) void
applyComponents
(DataComponentPatch p_328534_) void
applyComponentsAndValidate
(DataComponentPatch p_336111_) boolean
canBeHurtBy
(DamageSource p_334859_) boolean
canBreakBlockInAdventureMode
(BlockInWorld p_333133_) boolean
canPlaceOnBlockInAdventureMode
(BlockInWorld p_331134_) void
consume
(int p_329683_, LivingEntity p_334302_) copy()
copyWithCount
(int p_256354_) void
enchant
(Enchantment p_41664_, int p_41665_) finishUsingItem
(Level p_41672_, LivingEntity p_41673_) void
forEachModifier
(EquipmentSlot p_331036_, BiConsumer<Holder<Attribute>, AttributeModifier> p_334430_) int
int
int
getCount()
int
float
getDestroySpeed
(BlockState p_41692_) getFrame()
getItem()
int
int
int
getTags()
getTooltipLines
(Item.TooltipContext p_331329_, Player p_41652_, TooltipFlag p_41653_) int
void
grow
(int p_41770_) boolean
hasFoil()
static int
hashItemAndComponents
(ItemStack p_334004_) static int
hashStackList
(List<ItemStack> p_333449_) Deprecated.void
hurtAndBreak
(int p_220158_, RandomSource p_220159_, ServerPlayer p_220160_, Runnable p_331215_) void
hurtAndBreak
(int p_41623_, LivingEntity p_41624_, EquipmentSlot p_335324_) void
hurtEnemy
(LivingEntity p_41641_, Player p_41642_) interactLivingEntity
(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) void
inventoryTick
(Level p_41667_, Entity p_41668_, int p_41669_, boolean p_41670_) boolean
boolean
boolean
boolean
boolean
boolean
boolean
isCorrectToolForDrops
(BlockState p_41736_) boolean
boolean
boolean
isEmpty()
boolean
boolean
boolean
isFramed()
boolean
isItemEnabled
(FeatureFlagSet p_250869_) static boolean
isSameItem
(ItemStack p_287761_, ItemStack p_287676_) static boolean
isSameItemSameComponents
(ItemStack p_334397_, ItemStack p_331609_) boolean
static com.mojang.serialization.MapCodec
<ItemStack> lenientOptionalFieldOf
(String p_336149_) void
limitSize
(int p_328100_) static boolean
listMatches
(List<ItemStack> p_335471_, List<ItemStack> p_334624_) Deprecated.static boolean
void
mineBlock
(Level p_41687_, BlockState p_41688_, BlockPos p_41689_, Player p_41690_) void
onCraftedBy
(Level p_41679_, Player p_41680_, int p_41681_) void
onCraftedBySystem
(Level p_311164_) void
onDestroyed
(ItemEntity p_150925_) Deprecated.Forge: Use damage source sensitive versionprivate InteractionResult
onItemUse
(UseOnContext p_41662_, Function<UseOnContext, InteractionResult> callback) onItemUseFirst
(UseOnContext p_41662_) void
onUseTick
(Level p_41732_, LivingEntity p_41733_, int p_41734_) boolean
overrideOtherStackedOnMe
(ItemStack p_150933_, Slot p_150934_, ClickAction p_150935_, Player p_150936_, SlotAccess p_150937_) boolean
overrideStackedOnOther
(Slot p_150927_, ClickAction p_150928_, Player p_150929_) parse
(HolderLookup.Provider p_332204_, Tag p_336056_) static ItemStack
parseOptional
(HolderLookup.Provider p_333870_, CompoundTag p_328391_) void
releaseUsing
(Level p_41675_, LivingEntity p_41676_, int p_41677_) <T> T
remove
(DataComponentType<? extends T> p_333259_) save
(HolderLookup.Provider p_328490_) save
(HolderLookup.Provider p_330500_, Tag p_332574_) saveOptional
(HolderLookup.Provider p_335413_) <T> T
set
(DataComponentType<? super T> p_332666_, T p_335655_) void
setCount
(int p_41765_) void
setDamageValue
(int p_41722_) void
setEntityRepresentation
(Entity p_41637_) void
setPopTime
(int p_41755_) void
shrink
(int p_41775_) split
(int p_41621_) toString()
transmuteCopy
(ItemLike p_334328_, int p_334821_) transmuteCopyIgnoreEmpty
(ItemLike p_332114_, int p_333334_) <T> T
update
(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_) boolean
static 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, wait
Methods inherited from interface net.minecraft.core.component.DataComponentHolder
get, getOrDefault, has
Methods 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:
getComponents
in 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:
onItemUseFirst
in 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
-