Package net.minecraft.item
Class ItemStack
- java.lang.Object
-
- net.minecraftforge.common.capabilities.CapabilityProvider<ItemStack>
-
- net.minecraft.item.ItemStack
-
- All Implemented Interfaces:
ICapabilityProvider
,ICapabilitySerializable<CompoundNBT>
,IForgeItemStack
,INBTSerializable<CompoundNBT>
public final class ItemStack extends CapabilityProvider<ItemStack> implements IForgeItemStack
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ItemStack.TooltipDisplayFlags
-
Field Summary
Fields Modifier and Type Field Description static java.text.DecimalFormat
ATTRIBUTE_MODIFIER_FORMAT
private CachedBlockInfo
cachedBreakBlock
private boolean
cachedBreakBlockResult
private CachedBlockInfo
cachedPlaceBlock
private boolean
cachedPlaceBlockResult
private CompoundNBT
capNBT
static com.mojang.serialization.Codec<ItemStack>
CODEC
private int
count
private IRegistryDelegate<Item>
delegate
static ItemStack
EMPTY
private boolean
emptyCacheFlag
private Entity
entityRepresentation
private Item
item
Deprecated.private static org.apache.logging.log4j.Logger
LOGGER
private static Style
LORE_STYLE
private int
popTime
private CompoundNBT
tag
-
Constructor Summary
Constructors Modifier Constructor Description private
ItemStack(CompoundNBT p_i47263_1_)
ItemStack(IItemProvider p_i48203_1_)
ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_)
private
ItemStack(IItemProvider p_i231596_1_, int p_i231596_2_, java.util.Optional<CompoundNBT> p_i231596_3_)
ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_, CompoundNBT capNBT)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeModifier(Attribute p_185129_1_, AttributeModifier p_185129_2_, EquipmentSlotType p_185129_3_)
void
addTagElement(java.lang.String p_77983_1_, INBT p_77983_2_)
static void
appendEnchantmentNames(java.util.List<ITextComponent> p_222120_0_, ListNBT p_222120_1_)
private static boolean
areSameBlocks(CachedBlockInfo p_206846_0_, CachedBlockInfo p_206846_1_)
ItemStack
copy()
void
deserializeNBT(CompoundNBT nbt)
void
enchant(Enchantment p_77966_1_, int p_77966_2_)
private static java.util.Collection<ITextComponent>
expandBlockState(java.lang.String p_206845_0_)
ItemStack
finishUsingItem(World p_77950_1_, LivingEntity p_77950_2_)
private void
forgeInit()
Set up forge's ItemStack additions.com.google.common.collect.Multimap<Attribute,AttributeModifier>
getAttributeModifiers(EquipmentSlotType p_111283_1_)
int
getBaseRepairCost()
int
getCount()
int
getDamageValue()
java.lang.String
getDescriptionId()
float
getDestroySpeed(BlockState p_150997_1_)
ITextComponent
getDisplayName()
SoundEvent
getDrinkingSound()
SoundEvent
getEatingSound()
ListNBT
getEnchantmentTags()
Entity
getEntityRepresentation()
ItemFrameEntity
getFrame()
private int
getHideFlags()
ITextComponent
getHoverName()
Item
getItem()
int
getMaxDamage()
int
getMaxStackSize()
CompoundNBT
getOrCreateTag()
CompoundNBT
getOrCreateTagElement(java.lang.String p_190925_1_)
int
getPopTime()
Rarity
getRarity()
CompoundNBT
getTag()
CompoundNBT
getTagElement(java.lang.String p_179543_1_)
java.util.List<ITextComponent>
getTooltipLines(PlayerEntity p_82840_1_, ITooltipFlag p_82840_2_)
UseAction
getUseAnimation()
int
getUseDuration()
void
grow(int p_190917_1_)
boolean
hasAdventureModeBreakTagForBlock(ITagCollectionSupplier p_206848_1_, CachedBlockInfo p_206848_2_)
boolean
hasAdventureModePlaceTagForBlock(ITagCollectionSupplier p_206847_1_, CachedBlockInfo p_206847_2_)
boolean
hasCustomHoverName()
boolean
hasFoil()
boolean
hasTag()
void
hideTooltipPart(ItemStack.TooltipDisplayFlags p_242395_1_)
boolean
hurt(int p_96631_1_, java.util.Random p_96631_2_, ServerPlayerEntity p_96631_3_)
<T extends LivingEntity>
voidhurtAndBreak(int p_222118_1_, T p_222118_2_, java.util.function.Consumer<T> p_222118_3_)
void
hurtEnemy(LivingEntity p_77961_1_, PlayerEntity p_77961_2_)
ActionResultType
interactLivingEntity(PlayerEntity p_111282_1_, LivingEntity p_111282_2_, Hand p_111282_3_)
void
inventoryTick(World p_77945_1_, Entity p_77945_2_, int p_77945_3_, boolean p_77945_4_)
boolean
isCorrectToolForDrops(BlockState p_150998_1_)
boolean
isDamageableItem()
boolean
isDamaged()
boolean
isEdible()
boolean
isEmpty()
boolean
isEnchantable()
boolean
isEnchanted()
boolean
isFramed()
static boolean
isSame(ItemStack p_179545_0_, ItemStack p_179545_1_)
static boolean
isSameIgnoreDurability(ItemStack p_185132_0_, ItemStack p_185132_1_)
boolean
isStackable()
private boolean
matches(ItemStack p_77959_1_)
static boolean
matches(ItemStack p_77989_0_, ItemStack p_77989_1_)
void
mineBlock(World p_179548_1_, BlockState p_179548_2_, BlockPos p_179548_3_, PlayerEntity p_179548_4_)
static ItemStack
of(CompoundNBT p_199557_0_)
void
onCraftedBy(World p_77980_1_, PlayerEntity p_77980_2_, int p_77980_3_)
private ActionResultType
onItemUse(ItemUseContext p_196084_1_, java.util.function.Function<ItemUseContext,ActionResultType> callback)
ActionResultType
onItemUseFirst(ItemUseContext p_196084_1_)
void
onUseTick(World p_222121_1_, LivingEntity p_222121_2_, int p_222121_3_)
void
releaseUsing(World p_77974_1_, LivingEntity p_77974_2_, int p_77974_3_)
void
removeTagKey(java.lang.String p_196083_1_)
void
resetHoverName()
boolean
sameItem(ItemStack p_77969_1_)
boolean
sameItemStackIgnoreDurability(ItemStack p_185136_1_)
CompoundNBT
save(CompoundNBT p_77955_1_)
void
setCount(int p_190920_1_)
void
setDamageValue(int p_196085_1_)
void
setEntityRepresentation(Entity p_234695_1_)
ItemStack
setHoverName(ITextComponent p_200302_1_)
void
setPopTime(int p_190915_1_)
void
setRepairCost(int p_82841_1_)
void
setTag(CompoundNBT p_77982_1_)
private static boolean
shouldShowInTooltip(int p_242394_0_, ItemStack.TooltipDisplayFlags p_242394_1_)
void
shrink(int p_190918_1_)
ItemStack
split(int p_77979_1_)
static boolean
tagMatches(ItemStack p_77970_0_, ItemStack p_77970_1_)
java.lang.String
toString()
private void
updateEmptyCacheFlag()
ActionResult<ItemStack>
use(World p_77957_1_, PlayerEntity p_77957_2_, Hand p_77957_3_)
ActionResultType
useOn(ItemUseContext p_196084_1_)
boolean
useOnRelease()
-
Methods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, getCapability, invalidateCaps, reviveCaps, serializeCaps
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability, getCapability
-
Methods inherited from interface net.minecraftforge.common.extensions.IForgeItemStack
areShareTagsEqual, canApplyAtEnchantingTable, canDisableShield, canElytraFly, canEquip, doesSneakBypassUse, elytraFlightTick, equals, getBurnTime, getBurnTime, getContainerItem, getEntityLifespan, getEquipmentSlot, getHarvestLevel, getHighlightTip, getItemEnchantability, getShareTag, getStack, getToolTypes, getXpRepairRatio, hasContainerItem, isBookEnchantable, isEnderMask, isPiglinCurrency, isRepairable, isShield, makesPiglinsNeutral, onArmorTick, onBlockStartBreak, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onUsingTick, readShareTag, serializeNBT, shouldCauseBlockBreakReset
-
-
-
-
Field Detail
-
CODEC
public static final com.mojang.serialization.Codec<ItemStack> CODEC
-
delegate
private final IRegistryDelegate<Item> delegate
-
capNBT
private CompoundNBT capNBT
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER
-
EMPTY
public static final ItemStack EMPTY
-
ATTRIBUTE_MODIFIER_FORMAT
public static final java.text.DecimalFormat ATTRIBUTE_MODIFIER_FORMAT
-
LORE_STYLE
private static final Style LORE_STYLE
-
count
private int count
-
popTime
private int popTime
-
item
@Deprecated private final Item item
Deprecated.
-
tag
private CompoundNBT tag
-
emptyCacheFlag
private boolean emptyCacheFlag
-
entityRepresentation
private Entity entityRepresentation
-
cachedBreakBlock
private CachedBlockInfo cachedBreakBlock
-
cachedBreakBlockResult
private boolean cachedBreakBlockResult
-
cachedPlaceBlock
private CachedBlockInfo cachedPlaceBlock
-
cachedPlaceBlockResult
private boolean cachedPlaceBlockResult
-
-
Constructor Detail
-
ItemStack
public ItemStack(IItemProvider p_i48203_1_)
-
ItemStack
private ItemStack(IItemProvider p_i231596_1_, int p_i231596_2_, java.util.Optional<CompoundNBT> p_i231596_3_)
-
ItemStack
public ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_)
-
ItemStack
public ItemStack(IItemProvider p_i48204_1_, int p_i48204_2_, @Nullable CompoundNBT capNBT)
-
ItemStack
private ItemStack(CompoundNBT p_i47263_1_)
-
-
Method Detail
-
updateEmptyCacheFlag
private void updateEmptyCacheFlag()
-
of
public static ItemStack of(CompoundNBT p_199557_0_)
-
isEmpty
public boolean isEmpty()
-
split
public ItemStack split(int p_77979_1_)
-
getItem
public Item getItem()
-
useOn
public ActionResultType useOn(ItemUseContext p_196084_1_)
-
onItemUseFirst
public ActionResultType onItemUseFirst(ItemUseContext p_196084_1_)
- Specified by:
onItemUseFirst
in interfaceIForgeItemStack
-
onItemUse
private ActionResultType onItemUse(ItemUseContext p_196084_1_, java.util.function.Function<ItemUseContext,ActionResultType> callback)
-
getDestroySpeed
public float getDestroySpeed(BlockState p_150997_1_)
-
use
public ActionResult<ItemStack> use(World p_77957_1_, PlayerEntity p_77957_2_, Hand p_77957_3_)
-
finishUsingItem
public ItemStack finishUsingItem(World p_77950_1_, LivingEntity p_77950_2_)
-
save
public CompoundNBT save(CompoundNBT p_77955_1_)
-
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_196085_1_)
-
getMaxDamage
public int getMaxDamage()
-
hurt
public boolean hurt(int p_96631_1_, java.util.Random p_96631_2_, @Nullable ServerPlayerEntity p_96631_3_)
-
hurtAndBreak
public <T extends LivingEntity> void hurtAndBreak(int p_222118_1_, T p_222118_2_, java.util.function.Consumer<T> p_222118_3_)
-
hurtEnemy
public void hurtEnemy(LivingEntity p_77961_1_, PlayerEntity p_77961_2_)
-
mineBlock
public void mineBlock(World p_179548_1_, BlockState p_179548_2_, BlockPos p_179548_3_, PlayerEntity p_179548_4_)
-
isCorrectToolForDrops
public boolean isCorrectToolForDrops(BlockState p_150998_1_)
-
interactLivingEntity
public ActionResultType interactLivingEntity(PlayerEntity p_111282_1_, LivingEntity p_111282_2_, Hand p_111282_3_)
-
copy
public ItemStack copy()
-
matches
private boolean matches(ItemStack p_77959_1_)
-
isSameIgnoreDurability
public static boolean isSameIgnoreDurability(ItemStack p_185132_0_, ItemStack p_185132_1_)
-
sameItem
public boolean sameItem(ItemStack p_77969_1_)
-
sameItemStackIgnoreDurability
public boolean sameItemStackIgnoreDurability(ItemStack p_185136_1_)
-
getDescriptionId
public java.lang.String getDescriptionId()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
inventoryTick
public void inventoryTick(World p_77945_1_, Entity p_77945_2_, int p_77945_3_, boolean p_77945_4_)
-
onCraftedBy
public void onCraftedBy(World p_77980_1_, PlayerEntity p_77980_2_, int p_77980_3_)
-
getUseDuration
public int getUseDuration()
-
getUseAnimation
public UseAction getUseAnimation()
-
releaseUsing
public void releaseUsing(World p_77974_1_, LivingEntity p_77974_2_, int p_77974_3_)
-
useOnRelease
public boolean useOnRelease()
-
hasTag
public boolean hasTag()
-
getTag
@Nullable public CompoundNBT getTag()
-
getOrCreateTag
public CompoundNBT getOrCreateTag()
-
getOrCreateTagElement
public CompoundNBT getOrCreateTagElement(java.lang.String p_190925_1_)
-
getTagElement
@Nullable public CompoundNBT getTagElement(java.lang.String p_179543_1_)
-
removeTagKey
public void removeTagKey(java.lang.String p_196083_1_)
-
getEnchantmentTags
public ListNBT getEnchantmentTags()
-
setTag
public void setTag(@Nullable CompoundNBT p_77982_1_)
-
getHoverName
public ITextComponent getHoverName()
-
setHoverName
public ItemStack setHoverName(@Nullable ITextComponent p_200302_1_)
-
resetHoverName
public void resetHoverName()
-
hasCustomHoverName
public boolean hasCustomHoverName()
-
getTooltipLines
public java.util.List<ITextComponent> getTooltipLines(@Nullable PlayerEntity p_82840_1_, ITooltipFlag p_82840_2_)
-
shouldShowInTooltip
private static boolean shouldShowInTooltip(int p_242394_0_, ItemStack.TooltipDisplayFlags p_242394_1_)
-
getHideFlags
private int getHideFlags()
-
hideTooltipPart
public void hideTooltipPart(ItemStack.TooltipDisplayFlags p_242395_1_)
-
appendEnchantmentNames
public static void appendEnchantmentNames(java.util.List<ITextComponent> p_222120_0_, ListNBT p_222120_1_)
-
expandBlockState
private static java.util.Collection<ITextComponent> expandBlockState(java.lang.String p_206845_0_)
-
hasFoil
public boolean hasFoil()
-
getRarity
public Rarity getRarity()
-
isEnchantable
public boolean isEnchantable()
-
enchant
public void enchant(Enchantment p_77966_1_, int p_77966_2_)
-
isEnchanted
public boolean isEnchanted()
-
addTagElement
public void addTagElement(java.lang.String p_77983_1_, INBT p_77983_2_)
-
isFramed
public boolean isFramed()
-
setEntityRepresentation
public void setEntityRepresentation(@Nullable Entity p_234695_1_)
-
getFrame
@Nullable public ItemFrameEntity getFrame()
-
getEntityRepresentation
@Nullable public Entity getEntityRepresentation()
-
getBaseRepairCost
public int getBaseRepairCost()
-
setRepairCost
public void setRepairCost(int p_82841_1_)
-
getAttributeModifiers
public com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers(EquipmentSlotType p_111283_1_)
-
addAttributeModifier
public void addAttributeModifier(Attribute p_185129_1_, AttributeModifier p_185129_2_, @Nullable EquipmentSlotType p_185129_3_)
-
getDisplayName
public ITextComponent getDisplayName()
-
areSameBlocks
private static boolean areSameBlocks(CachedBlockInfo p_206846_0_, @Nullable CachedBlockInfo p_206846_1_)
-
hasAdventureModeBreakTagForBlock
public boolean hasAdventureModeBreakTagForBlock(ITagCollectionSupplier p_206848_1_, CachedBlockInfo p_206848_2_)
-
hasAdventureModePlaceTagForBlock
public boolean hasAdventureModePlaceTagForBlock(ITagCollectionSupplier p_206847_1_, CachedBlockInfo p_206847_2_)
-
getPopTime
public int getPopTime()
-
setPopTime
public void setPopTime(int p_190915_1_)
-
getCount
public int getCount()
-
setCount
public void setCount(int p_190920_1_)
-
grow
public void grow(int p_190917_1_)
-
shrink
public void shrink(int p_190918_1_)
-
onUseTick
public void onUseTick(World p_222121_1_, LivingEntity p_222121_2_, int p_222121_3_)
-
isEdible
public boolean isEdible()
-
deserializeNBT
public void deserializeNBT(CompoundNBT nbt)
- Specified by:
deserializeNBT
in interfaceINBTSerializable<CompoundNBT>
-
forgeInit
private void forgeInit()
Set up forge's ItemStack additions.
-
getDrinkingSound
public SoundEvent getDrinkingSound()
-
getEatingSound
public SoundEvent getEatingSound()
-
-