public final class ItemStack
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
animationsToGo
Number of animation frames to go when receiving an item (by walking into it, for example).
|
private Block |
canDestroyCacheBlock |
private boolean |
canDestroyCacheResult |
private Block |
canPlaceOnCacheBlock |
private boolean |
canPlaceOnCacheResult |
static java.text.DecimalFormat |
DECIMALFORMAT |
private Item |
item |
private int |
itemDamage |
private EntityItemFrame |
itemFrame
Item frame this stack is on, or null if not on an item frame.
|
int |
stackSize
Size of the stack.
|
private NBTTagCompound |
stackTagCompound
A NBTTagMap containing data about an ItemStack.
|
Modifier | Constructor and Description |
---|---|
private |
ItemStack() |
|
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) |
Modifier and Type | Method and Description |
---|---|
void |
addEnchantment(Enchantment ench,
int level)
Adds an enchantment with a desired level on the ItemStack.
|
static boolean |
areItemsEqual(ItemStack stackA,
ItemStack stackB)
Compares Item and damage value of the two stacks
|
static boolean |
areItemStacksEqual(ItemStack stackA,
ItemStack stackB)
compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equal
|
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(Block 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.
|
static ItemStack |
copyItemStack(ItemStack stack)
Creates a copy of a ItemStack, a null parameters will return a null.
|
void |
damageItem(int amount,
EntityLivingBase entityIn)
Damages the item in the ItemStack
|
com.google.common.collect.Multimap<java.lang.String,AttributeModifier> |
getAttributeModifiers() |
IChatComponent |
getChatComponent()
Get a ChatComponent for this Item's display name that shows this Item on hover
|
java.lang.String |
getDisplayName()
returns the display name of the itemstack
|
NBTTagList |
getEnchantmentTagList() |
boolean |
getHasSubtypes() |
boolean |
getIsItemStackEqual(ItemStack p_179549_1_) |
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() |
EnumRarity |
getRarity() |
int |
getRepairCost()
Get this stack's repair cost, or 0 if no repair cost is defined.
|
float |
getStrVsBlock(Block blockIn) |
NBTTagCompound |
getSubCompound(java.lang.String key,
boolean create)
Get an NBTTagCompound from this stack's NBT data.
|
NBTTagCompound |
getTagCompound()
Returns the NBTTagCompound of the ItemStack.
|
java.util.List<java.lang.String> |
getTooltip(EntityPlayer playerIn,
boolean advanced) |
java.lang.String |
getUnlocalizedName() |
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 corresponding fct in di
|
boolean |
interactWithEntity(EntityPlayer playerIn,
EntityLivingBase entityIn) |
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 |
isItemStackDamageable()
true if this itemStack is damageable
|
private boolean |
isItemStackEqual(ItemStack other)
compares ItemStack argument to the instance ItemStack; returns true if both ItemStacks are equal
|
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.
|
static ItemStack |
loadItemStackFromNBT(NBTTagCompound nbt) |
void |
onBlockDestroyed(World worldIn,
Block blockIn,
BlockPos pos,
EntityPlayer playerIn)
Called when a Block is destroyed using this ItemStack
|
void |
onCrafting(World worldIn,
EntityPlayer playerIn,
int amount) |
boolean |
onItemUse(EntityPlayer playerIn,
World worldIn,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ)
Called when the player uses this ItemStack on a Block (right-click).
|
ItemStack |
onItemUseFinish(World worldIn,
EntityPlayer playerIn)
Called when the item in use count reach 0, e.g.
|
void |
onPlayerStoppedUsing(World worldIn,
EntityPlayer playerIn,
int timeLeft)
Called when the player releases the use item button.
|
void |
readFromNBT(NBTTagCompound nbt)
Read the stack fields from a NBT object.
|
void |
setItem(Item newItem) |
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 |
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.
|
ItemStack |
useItemRightClick(World worldIn,
EntityPlayer playerIn)
Called whenever this item stack is equipped and right clicked.
|
NBTTagCompound |
writeToNBT(NBTTagCompound nbt)
Write the stack fields to a NBT object.
|
public static final java.text.DecimalFormat DECIMALFORMAT
public int stackSize
public int animationsToGo
private Item item
private NBTTagCompound stackTagCompound
private int itemDamage
private EntityItemFrame itemFrame
private Block canDestroyCacheBlock
private boolean canDestroyCacheResult
private Block canPlaceOnCacheBlock
private boolean canPlaceOnCacheResult
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)
private ItemStack()
public static ItemStack loadItemStackFromNBT(NBTTagCompound nbt)
public ItemStack splitStack(int amount)
public Item getItem()
public boolean onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
public float getStrVsBlock(Block blockIn)
public ItemStack useItemRightClick(World worldIn, EntityPlayer playerIn)
public ItemStack onItemUseFinish(World worldIn, EntityPlayer playerIn)
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
public void readFromNBT(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, Block blockIn, BlockPos pos, EntityPlayer playerIn)
public boolean canHarvestBlock(Block blockIn)
public boolean interactWithEntity(EntityPlayer playerIn, EntityLivingBase entityIn)
public ItemStack copy()
public static boolean areItemStackTagsEqual(ItemStack stackA, ItemStack stackB)
public static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB)
private boolean isItemStackEqual(ItemStack other)
public static boolean areItemsEqual(ItemStack stackA, ItemStack stackB)
public boolean isItemEqual(ItemStack other)
public java.lang.String getUnlocalizedName()
public static ItemStack copyItemStack(ItemStack stack)
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 boolean getIsItemStackEqual(ItemStack p_179549_1_)
public int getMaxItemUseDuration()
public EnumAction getItemUseAction()
public void onPlayerStoppedUsing(World worldIn, EntityPlayer playerIn, int timeLeft)
public boolean hasTagCompound()
public NBTTagCompound getTagCompound()
public NBTTagCompound getSubCompound(java.lang.String key, boolean create)
public NBTTagList getEnchantmentTagList()
public void setTagCompound(NBTTagCompound nbt)
public java.lang.String getDisplayName()
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 com.google.common.collect.Multimap<java.lang.String,AttributeModifier> getAttributeModifiers()
public void setItem(Item newItem)
public IChatComponent getChatComponent()
public boolean canDestroy(Block blockIn)
public boolean canPlaceOn(Block blockIn)