Class ItemStack

  • All Implemented Interfaces:
    org.teavm.jso.JSObject

    public final class ItemStack
    extends PluginData
    • Field Detail

      • DECIMALFORMAT

        public static final java.text.DecimalFormat DECIMALFORMAT
      • stackSize

        public int stackSize
      • animationsToGo

        public int animationsToGo
    • Constructor Detail

      • ItemStack

        public ItemStack​(Block blockIn)
      • ItemStack

        public ItemStack​(Block blockIn,
                         int amount)
      • ItemStack

        public ItemStack​(Block blockIn,
                         int amount,
                         int meta)
      • ItemStack

        public ItemStack​(Item itemIn)
      • ItemStack

        public ItemStack​(Item itemIn,
                         int amount)
      • ItemStack

        public ItemStack​(Item itemIn,
                         int amount,
                         int meta)
    • Method Detail

      • loadPluginData

        public void loadPluginData​(BaseData data)
      • makePluginData

        public PluginData makePluginData()
      • splitStack

        public ItemStack splitStack​(int amount)
        + Splits off a stack of the given amount of this stack and reduces this stack by the amount.
      • getItem

        public Item getItem()
        + Returns the object corresponding to the stack.
      • onItemUse

        public 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). Places blocks, etc. (Legacy name: tryPlaceItemIntoWorld)
      • getStrVsBlock

        public float getStrVsBlock​(Block blockIn)
      • useItemRightClick

        public ItemStack useItemRightClick​(World worldIn,
                                           EntityPlayer playerIn)
        + Called whenever this item stack is equipped and right clicked. Returns the new item stack to put in the position where this item is. Args: world, player
      • onItemUseFinish

        public ItemStack onItemUseFinish​(World worldIn,
                                         EntityPlayer playerIn)
        + Called when the item in use count reach 0, e.g. item food eaten. Return the new ItemStack. Args : world, entity
      • writeToNBT

        public NBTTagCompound writeToNBT​(NBTTagCompound nbt)
        + Write the stack fields to a NBT object. Return the new NBT object.
      • toNBT

        public java.lang.String toNBT()
      • fromNBT

        public void fromNBT​(java.lang.String nbt)
      • readFromNBT

        public void readFromNBT​(NBTTagCompound nbt)
        + Read the stack fields from a NBT object.
      • getMaxStackSize

        public int getMaxStackSize()
        + Returns maximum size of the stack.
      • isStackable

        public boolean isStackable()
        + Returns true if the ItemStack can hold 2 or more units of the item.
      • isItemStackDamageable

        public boolean isItemStackDamageable()
        + true if this itemStack is damageable
      • getHasSubtypes

        public boolean getHasSubtypes()
      • isItemDamaged

        public boolean isItemDamaged()
        + returns true when a damageable item is damaged
      • getItemDamage

        public int getItemDamage()
      • getMetadata

        public int getMetadata()
      • setItemDamage

        public void setItemDamage​(int meta)
      • getMaxDamage

        public int getMaxDamage()
        + Returns the max damage an item in the stack can take.
      • attemptDamageItem

        public boolean attemptDamageItem​(int amount,
                                         EaglercraftRandom 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. Returns true if it takes more damage than getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are negated.
      • damageItem

        public void damageItem​(int amount,
                               EntityLivingBase entityIn)
        + Damages the item in the ItemStack
      • onBlockDestroyed

        public void onBlockDestroyed​(World worldIn,
                                     Block blockIn,
                                     BlockPos pos,
                                     EntityPlayer playerIn)
        + Called when a Block is destroyed using this ItemStack
      • canHarvestBlock

        public boolean canHarvestBlock​(Block blockIn)
        + Check whether the given Block can be harvested using this ItemStack.
      • copy

        public ItemStack copy()
        + Returns a new stack with the same properties.
      • areItemStackTagsEqual

        public static boolean areItemStackTagsEqual​(ItemStack stackA,
                                                    ItemStack stackB)
      • areItemStacksEqual

        public static boolean areItemStacksEqual​(ItemStack stackA,
                                                 ItemStack stackB)
        + compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equal
      • areItemsEqual

        public static boolean areItemsEqual​(ItemStack stackA,
                                            ItemStack stackB)
        + Compares Item and damage value of the two stacks
      • isItemEqual

        public boolean isItemEqual​(ItemStack other)
        + compares ItemStack argument to the instance ItemStack; returns true if the Items contained in both ItemStacks are equal
      • getUnlocalizedName

        public java.lang.String getUnlocalizedName()
      • copyItemStack

        public static ItemStack copyItemStack​(ItemStack stack)
        + Creates a copy of a ItemStack, a null parameters will return a null.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • updateAnimation

        public void updateAnimation​(World worldIn,
                                    Entity entityIn,
                                    int inventorySlot,
                                    boolean isCurrentItem)
        + Called each tick as long the ItemStack in on player inventory. Used to progress the pickup animation and update maps.
      • onCrafting

        public void onCrafting​(World worldIn,
                               EntityPlayer playerIn,
                               int amount)
      • getIsItemStackEqual

        public boolean getIsItemStackEqual​(ItemStack parItemStack)
      • getMaxItemUseDuration

        public int getMaxItemUseDuration()
      • getItemUseAction

        public EnumAction getItemUseAction()
      • onPlayerStoppedUsing

        public void onPlayerStoppedUsing​(World worldIn,
                                         EntityPlayer playerIn,
                                         int timeLeft)
        + Called when the player releases the use item button. Args: world, entityplayer, itemInUseCount
      • hasTagCompound

        public boolean hasTagCompound()
        + Returns true if the ItemStack has an NBTTagCompound. Currently used to store enchantments.
      • getTagCompound

        public NBTTagCompound getTagCompound()
        + Returns the NBTTagCompound of the ItemStack.
      • getSubCompound

        public NBTTagCompound getSubCompound​(java.lang.String key,
                                             boolean create)
        + Get an NBTTagCompound from this stack's NBT data.
      • getEnchantmentTagList

        public NBTTagList getEnchantmentTagList()
      • setTagCompound

        public void setTagCompound​(NBTTagCompound nbt)
        + Assigns a NBTTagCompound to the ItemStack, minecraft validates that only non-stackable items can have it.
      • getDisplayName

        public java.lang.String getDisplayName()
        + returns the display name of the itemstack
      • setStackDisplayName

        public ItemStack setStackDisplayName​(java.lang.String displayName)
      • setLore

        public void setLore​(java.lang.String[] loreIn)
      • getLore

        public java.lang.String[] getLore()
      • clearCustomName

        public void clearCustomName()
        + Clear any custom name set for this ItemStack
      • hasDisplayName

        public boolean hasDisplayName()
        + Returns true if the itemstack has a display name
      • getTooltip

        public java.util.List<java.lang.String> getTooltip​(EntityPlayer playerIn,
                                                           boolean advanced)
        + Return a list of strings containing information about the item
      • hasEffect

        public boolean hasEffect()
      • isItemEnchantable

        public boolean isItemEnchantable()
        + True if it is a tool and has no enchantments to begin with
      • addEnchantment

        public void addEnchantment​(Enchantment ench,
                                   int level)
        + Adds an enchantment with a desired level on the ItemStack.
      • isItemEnchanted

        public boolean isItemEnchanted()
        + True if the item has enchantment data
      • setTagInfo

        public void setTagInfo​(java.lang.String key,
                               NBTBase value)
      • canEditBlocks

        public boolean canEditBlocks()
      • isOnItemFrame

        public boolean isOnItemFrame()
        + Return whether this stack is on an item frame.
      • setItemFrame

        public void setItemFrame​(EntityItemFrame frame)
        + Set the item frame this stack is on.
      • getItemFrame

        public EntityItemFrame getItemFrame()
        + Return the item frame this stack is on. Returns null if not on an item frame.
      • getRepairCost

        public int getRepairCost()
        + Get this stack's repair cost, or 0 if no repair cost is defined.
      • setRepairCost

        public void setRepairCost​(int cost)
        + Set this stack's repair cost.
      • setItem

        public void setItem​(Item newItem)
      • getChatComponent

        public IChatComponent getChatComponent()
        + Get a ChatComponent for this Item's display name that shows this Item on hover
      • canDestroy

        public boolean canDestroy​(Block blockIn)
      • canPlaceOn

        public boolean canPlaceOn​(Block blockIn)