public final class ItemStack extends java.lang.Object implements ICapabilitySerializable<NBTTagCompound>
Modifier and Type | Field and Description |
---|---|
static java.text.DecimalFormat |
DECIMALFORMAT |
static ItemStack |
EMPTY |
Constructor and Description |
---|
ItemStack(Block blockIn) |
ItemStack(Block blockIn,
int amount) |
ItemStack(Block blockIn,
int amount,
int meta) |
ItemStack(Item itemIn) |
ItemStack(Item itemIn,
int amount) |
ItemStack(Item itemIn,
int amount,
int meta) |
ItemStack(Item itemIn,
int amount,
int meta,
NBTTagCompound capNBT) |
ItemStack(NBTTagCompound compound) |
Modifier and Type | Method and Description |
---|---|
void |
addAttributeModifier(java.lang.String attributeName,
AttributeModifier modifier,
EntityEquipmentSlot equipmentSlot) |
void |
addEnchantment(Enchantment ench,
int level)
Adds an enchantment with a desired level on the ItemStack.
|
boolean |
areCapsCompatible(ItemStack other) |
static boolean |
areItemsEqual(ItemStack stackA,
ItemStack stackB)
Compares Item and damage value of the two stacks
|
static boolean |
areItemsEqualIgnoreDurability(ItemStack stackA,
ItemStack stackB) |
static boolean |
areItemStacksEqual(ItemStack stackA,
ItemStack stackB)
compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equal
|
static boolean |
areItemStacksEqualUsingNBTShareTag(ItemStack stackA,
ItemStack stackB)
Modeled after ItemStack.areItemStacksEqual
Uses Item.getNBTShareTag for comparison instead of NBT and capabilities.
|
static boolean |
areItemStackShareTagsEqual(ItemStack stackA,
ItemStack stackB)
Modeled after ItemStack.areItemStackTagsEqual
Uses Item.getNBTShareTag for comparison instead of NBT and capabilities.
|
static boolean |
areItemStackTagsEqual(ItemStack stackA,
ItemStack stackB) |
boolean |
attemptDamageItem(int amount,
java.util.Random rand)
Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
there is a chance for each point of damage to be negated.
|
boolean |
canDestroy(Block blockIn) |
boolean |
canEditBlocks() |
boolean |
canHarvestBlock(IBlockState blockIn)
Check whether the given Block can be harvested using this ItemStack.
|
boolean |
canPlaceOn(Block blockIn) |
void |
clearCustomName()
Clear any custom name set for this ItemStack
|
ItemStack |
copy()
Returns a new stack with the same properties.
|
void |
damageItem(int amount,
EntityLivingBase entityIn)
Damages the item in the ItemStack
|
void |
deserializeNBT(NBTTagCompound nbt) |
int |
getAnimationsToGo() |
<any> |
getAttributeModifiers(EntityEquipmentSlot equipmentSlot)
Gets the attribute modifiers for this ItemStack.
|
<T> T |
getCapability(Capability<T> capability,
EnumFacing facing)
Retrieves the handler for the capability requested on the specific side.
|
int |
getCount() |
java.lang.String |
getDisplayName()
returns the display name of the itemstack
|
NBTTagList |
getEnchantmentTagList() |
boolean |
getHasSubtypes() |
Item |
getItem()
Returns the object corresponding to the stack.
|
int |
getItemDamage() |
EntityItemFrame |
getItemFrame()
Return the item frame this stack is on.
|
EnumAction |
getItemUseAction() |
int |
getMaxDamage()
Returns the max damage an item in the stack can take.
|
int |
getMaxItemUseDuration() |
int |
getMaxStackSize()
Returns maximum size of the stack.
|
int |
getMetadata() |
NBTTagCompound |
getOrCreateSubCompound(java.lang.String key) |
EnumRarity |
getRarity() |
int |
getRepairCost()
Get this stack's repair cost, or 0 if no repair cost is defined.
|
float |
getStrVsBlock(IBlockState blockIn) |
NBTTagCompound |
getSubCompound(java.lang.String key)
Get an NBTTagCompound from this stack's NBT data.
|
NBTTagCompound |
getTagCompound()
Returns the NBTTagCompound of the ItemStack.
|
ITextComponent |
getTextComponent()
Get a ChatComponent for this Item's display name that shows this Item on hover
|
java.util.List<java.lang.String> |
getTooltip(EntityPlayer playerIn,
boolean advanced)
Return a list of strings containing information about the item
|
java.lang.String |
getUnlocalizedName() |
void |
grow(int quantity) |
boolean |
hasCapability(Capability<?> capability,
EnumFacing facing)
Determines if this object has support for the capability in question on the specific side.
|
boolean |
hasDisplayName()
Returns true if the itemstack has a display name
|
boolean |
hasEffect() |
boolean |
hasTagCompound()
Returns true if the ItemStack has an NBTTagCompound.
|
void |
hitEntity(EntityLivingBase entityIn,
EntityPlayer playerIn)
Calls the delegated method to the Item to damage the incoming Entity, and if necessary, triggers a stats
increase.
|
boolean |
interactWithEntity(EntityPlayer playerIn,
EntityLivingBase entityIn,
EnumHand hand) |
boolean |
isEmpty() |
boolean |
isItemDamaged()
returns true when a damageable item is damaged
|
boolean |
isItemEnchantable()
True if it is a tool and has no enchantments to begin with
|
boolean |
isItemEnchanted()
True if the item has enchantment data
|
boolean |
isItemEqual(ItemStack other)
compares ItemStack argument to the instance ItemStack; returns true if the Items contained in both ItemStacks are
equal
|
boolean |
isItemEqualIgnoreDurability(ItemStack stack) |
boolean |
isItemStackDamageable()
true if this itemStack is damageable
|
boolean |
isOnItemFrame()
Return whether this stack is on an item frame.
|
boolean |
isStackable()
Returns true if the ItemStack can hold 2 or more units of the item.
|
void |
onBlockDestroyed(World worldIn,
IBlockState blockIn,
BlockPos pos,
EntityPlayer playerIn)
Called when a Block is destroyed using this ItemStack
|
void |
onCrafting(World worldIn,
EntityPlayer playerIn,
int amount) |
EnumActionResult |
onItemUse(EntityPlayer playerIn,
World worldIn,
BlockPos pos,
EnumHand hand,
EnumFacing side,
float hitX,
float hitY,
float hitZ)
Called when the player uses this ItemStack on a Block (right-click).
|
ItemStack |
onItemUseFinish(World worldIn,
EntityLivingBase entityLiving)
Called when the item in use count reach 0, e.g.
|
EnumActionResult |
onItemUseFirst(EntityPlayer playerIn,
World worldIn,
BlockPos pos,
EnumHand hand,
EnumFacing side,
float hitX,
float hitY,
float hitZ) |
void |
onPlayerStoppedUsing(World worldIn,
EntityLivingBase entityLiving,
int timeLeft)
Called when the player releases the use item button.
|
static void |
registerFixes(DataFixer fixer) |
void |
removeSubCompound(java.lang.String key) |
NBTTagCompound |
serializeNBT() |
void |
setAnimationsToGo(int animations) |
void |
setCount(int size) |
void |
setItemDamage(int meta) |
void |
setItemFrame(EntityItemFrame frame)
Set the item frame this stack is on.
|
void |
setRepairCost(int cost)
Set this stack's repair cost.
|
ItemStack |
setStackDisplayName(java.lang.String displayName) |
void |
setTagCompound(NBTTagCompound nbt)
Assigns a NBTTagCompound to the ItemStack, minecraft validates that only non-stackable items can have it.
|
void |
setTagInfo(java.lang.String key,
NBTBase value) |
ItemStack |
setTranslatableName(java.lang.String p_190924_1_) |
void |
shrink(int quantity) |
ItemStack |
splitStack(int amount)
Splits off a stack of the given amount of this stack and reduces this stack by the amount.
|
java.lang.String |
toString() |
void |
updateAnimation(World worldIn,
Entity entityIn,
int inventorySlot,
boolean isCurrentItem)
Called each tick as long the ItemStack in on player inventory.
|
ActionResult<ItemStack> |
useItemRightClick(World worldIn,
EntityPlayer playerIn,
EnumHand hand)
Called whenr the item stack is equipped and right clicked.
|
NBTTagCompound |
writeToNBT(NBTTagCompound nbt)
Write the stack fields to a NBT object.
|
public static final ItemStack EMPTY
public static final java.text.DecimalFormat DECIMALFORMAT
public ItemStack(Block blockIn)
public ItemStack(Block blockIn, int amount)
public ItemStack(Block blockIn, int amount, int meta)
public ItemStack(Item itemIn)
public ItemStack(Item itemIn, int amount)
public ItemStack(Item itemIn, int amount, int meta)
public ItemStack(Item itemIn, int amount, int meta, NBTTagCompound capNBT)
public ItemStack(NBTTagCompound compound)
public boolean isEmpty()
public static void registerFixes(DataFixer fixer)
public ItemStack splitStack(int amount)
public Item getItem()
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
public float getStrVsBlock(IBlockState blockIn)
public ActionResult<ItemStack> useItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
public ItemStack onItemUseFinish(World worldIn, EntityLivingBase entityLiving)
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
public int getMaxStackSize()
public boolean isStackable()
public boolean isItemStackDamageable()
public boolean getHasSubtypes()
public boolean isItemDamaged()
public int getItemDamage()
public int getMetadata()
public void setItemDamage(int meta)
public int getMaxDamage()
public boolean attemptDamageItem(int amount, java.util.Random rand)
public void damageItem(int amount, EntityLivingBase entityIn)
public void hitEntity(EntityLivingBase entityIn, EntityPlayer playerIn)
public void onBlockDestroyed(World worldIn, IBlockState blockIn, BlockPos pos, EntityPlayer playerIn)
public boolean canHarvestBlock(IBlockState blockIn)
public boolean interactWithEntity(EntityPlayer playerIn, EntityLivingBase entityIn, EnumHand hand)
public ItemStack copy()
public static boolean areItemStackTagsEqual(ItemStack stackA, ItemStack stackB)
public static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB)
public static boolean areItemsEqual(ItemStack stackA, ItemStack stackB)
public static boolean areItemsEqualIgnoreDurability(ItemStack stackA, ItemStack stackB)
public boolean isItemEqual(ItemStack other)
public boolean isItemEqualIgnoreDurability(ItemStack stack)
public java.lang.String getUnlocalizedName()
public java.lang.String toString()
toString
in class java.lang.Object
public void updateAnimation(World worldIn, Entity entityIn, int inventorySlot, boolean isCurrentItem)
public void onCrafting(World worldIn, EntityPlayer playerIn, int amount)
public int getMaxItemUseDuration()
public EnumAction getItemUseAction()
public void onPlayerStoppedUsing(World worldIn, EntityLivingBase entityLiving, int timeLeft)
public boolean hasTagCompound()
public NBTTagCompound getTagCompound()
public NBTTagCompound getOrCreateSubCompound(java.lang.String key)
public NBTTagCompound getSubCompound(java.lang.String key)
public void removeSubCompound(java.lang.String key)
public NBTTagList getEnchantmentTagList()
public void setTagCompound(NBTTagCompound nbt)
public java.lang.String getDisplayName()
public ItemStack setTranslatableName(java.lang.String p_190924_1_)
public ItemStack setStackDisplayName(java.lang.String displayName)
public void clearCustomName()
public boolean hasDisplayName()
public java.util.List<java.lang.String> getTooltip(EntityPlayer playerIn, boolean advanced)
public boolean hasEffect()
public EnumRarity getRarity()
public boolean isItemEnchantable()
public void addEnchantment(Enchantment ench, int level)
public boolean isItemEnchanted()
public void setTagInfo(java.lang.String key, NBTBase value)
public boolean canEditBlocks()
public boolean isOnItemFrame()
public void setItemFrame(EntityItemFrame frame)
public EntityItemFrame getItemFrame()
public int getRepairCost()
public void setRepairCost(int cost)
public <any> getAttributeModifiers(EntityEquipmentSlot equipmentSlot)
public void addAttributeModifier(java.lang.String attributeName, AttributeModifier modifier, EntityEquipmentSlot equipmentSlot)
public ITextComponent getTextComponent()
public boolean canDestroy(Block blockIn)
public boolean canPlaceOn(Block blockIn)
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
ICapabilityProvider
hasCapability
in interface ICapabilityProvider
capability
- The capability to checkfacing
- The Side to check from:
CAN BE NULL. Null is defined to represent 'internal' or 'self'public <T> T getCapability(Capability<T> capability, EnumFacing facing)
ICapabilityProvider
getCapability
in interface ICapabilityProvider
capability
- The capability to checkfacing
- The Side to check from:
CAN BE NULL. Null is defined to represent 'internal' or 'self'ICapabilityProvider.hasCapability(Capability, EnumFacing)
would return false.public void deserializeNBT(NBTTagCompound nbt)
deserializeNBT
in interface INBTSerializable<NBTTagCompound>
public NBTTagCompound serializeNBT()
serializeNBT
in interface INBTSerializable<NBTTagCompound>
public boolean areCapsCompatible(ItemStack other)
public int getAnimationsToGo()
public void setAnimationsToGo(int animations)
public int getCount()
public void setCount(int size)
public void grow(int quantity)
public void shrink(int quantity)
public static boolean areItemStacksEqualUsingNBTShareTag(ItemStack stackA, ItemStack stackB)
public static boolean areItemStackShareTagsEqual(ItemStack stackA, ItemStack stackB)