Interface IItemStack

  • All Known Subinterfaces:
    IItemCustom, IItemCustomizable, IItemLinked

    public interface IItemStack
    Represents an item stack with extended functionality: enchantments, lore, and additional item data.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addEnchant​(int id, int strength)
      Adds an enchantment to the item.
      boolean compare​(IItemStack item, boolean ignoreNBT)
      Compares this item with another item, with an option to ignore NBT data.
      boolean compare​(IItemStack item, boolean ignoreDamage, boolean ignoreNBT)
      Compares this item with another item, with options to ignore damage and/or NBT data.
      IItemStack copy()
      Creates a deep copy of this item stack.
      double getAttribute​(java.lang.String name)
      Retrieves the attribute value using the default MC attribute system.
      java.lang.String getBookAuthor()  
      java.lang.String[] getBookText()  
      java.lang.String getBookTitle()  
      float getCustomAttribute​(java.lang.String key)
      Returns the custom attribute object associated with the given key.
      java.lang.String[] getCustomAttributeKeys()
      Returns an array of all custom attribute keys stored on the item.
      java.lang.String getDisplayName()  
      int getItemDamage()  
      java.lang.String getItemName()  
      INbt getItemNbt()
      Returns an INbt instance representing the full NBT data of the item.
      java.lang.String[] getLore()  
      float getMagicAttribute​(java.lang.String key, int magicId)
      Returns the magic attribute object (typically a Float value) associated with the given key and magic identifier.
      java.lang.String[] getMagicAttributeKeys​(java.lang.String key)
      Returns an array of all magic attribute keys (as strings) for the specified magic attribute key.
      int getMaxItemDamage()  
      int getMaxStackSize()  
      net.minecraft.item.ItemStack getMCItemStack()
      Returns the underlying Minecraft ItemStack.
      net.minecraft.nbt.NBTTagCompound getMCNbt()
      Returns the underlying Minecraft NBTTagCompound for the item.
      java.lang.String getName()  
      INbt getNbt()
      Returns an INbt instance representing the item's custom NBT data.
      java.lang.Object getRequirement​(java.lang.String reqKey)
      Retrieves the requirement value for the specified key.
      java.lang.String[] getRequirementKeys()
      Returns an array of all requirement keys stored on the item.
      int getStackSize()  
      java.lang.Object getTag​(java.lang.String key)
      Returns the value of the NBT tag with the specified key.
      boolean hasAttribute​(java.lang.String name)
      Checks if the item has an attribute (using the default MC attribute system).
      boolean hasCustomAttribute​(java.lang.String key)
      Checks whether the item has a custom attribute with the specified key.
      boolean hasCustomName()  
      boolean hasEnchant​(int id)
      Checks if the item has the specified enchantment.
      boolean hasLore()  
      boolean hasMagicAttribute​(java.lang.String key, int magicId)
      Checks whether the item has a magic attribute with the given key and magic identifier.
      boolean hasRequirement​(java.lang.String reqKey)
      Checks whether the item has a requirement with the specified key.
      boolean hasTag​(java.lang.String key)
      Checks if the item has an NBT tag with the specified key.
      boolean isBlock()  
      boolean isEnchanted()  
      boolean isWrittenBook()  
      int itemHash()
      Returns a hash value for the item.
      void removeCustomAttribute​(java.lang.String key)
      Removes the custom attribute with the specified key from the item.
      void removeMagicAttribute​(java.lang.String key, int magicId)
      Removes the magic attribute with the specified key and magic identifier from the item.
      void removeRequirement​(java.lang.String reqKey)
      Removes the requirement with the specified key from the item.
      INbt removeTags()
      Removes all custom tags from the item and returns the removed NBT data.
      void setAttribute​(java.lang.String name, double value)
      Sets an attribute on the item using the default MC attribute system.
      void setCustomAttribute​(java.lang.String key, double value)
      Sets the custom attribute value for the given key.
      void setCustomName​(java.lang.String name)
      Sets the custom name for the item.
      void setItemDamage​(int value)
      Sets the item damage value.
      void setLore​(java.lang.String[] lore)
      Sets the lore for the item.
      void setMagicAttribute​(java.lang.String key, int magicId, double value)
      Sets the magic attribute value for the given key and magic identifier.
      void setMCNbt​(net.minecraft.nbt.NBTTagCompound compound)
      Sets the underlying Minecraft NBTTagCompound for the item.
      void setRequirement​(java.lang.String reqKey, java.lang.Object value)
      Sets (or applies) a requirement for the item using the given requirement key and value.
      void setStackSize​(int size)
      Sets the stack size of the item.
      void setTag​(java.lang.String key, java.lang.Object value)
      Sets an NBT tag for this item.
    • Method Detail

      • getName

        java.lang.String getName()
      • getStackSize

        int getStackSize()
        Returns:
        Returns the stack size.
      • hasCustomName

        boolean hasCustomName()
        Returns:
        Returns whether the item has a custom name.
      • setCustomName

        void setCustomName​(java.lang.String name)
        Sets the custom name for the item.
        Parameters:
        name - The custom name.
      • getDisplayName

        java.lang.String getDisplayName()
        Returns:
        Returns the in-game displayed name. This is either the item name or the custom name if set.
      • getItemName

        java.lang.String getItemName()
        Returns:
        Returns the base item name, regardless of any custom name.
      • setStackSize

        void setStackSize​(int size)
        Sets the stack size of the item.
        Parameters:
        size - The new stack size (between 1 and 64).
      • getMaxStackSize

        int getMaxStackSize()
        Returns:
        Returns the maximum stack size for this item.
      • getItemDamage

        int getItemDamage()
        Returns:
        Returns the item damage. For tools, this represents durability.
      • setItemDamage

        void setItemDamage​(int value)
        Sets the item damage value.
        Parameters:
        value - The new damage value.
      • setTag

        void setTag​(java.lang.String key,
                    java.lang.Object value)
        Sets an NBT tag for this item.
        Parameters:
        key - The tag key.
        value - The value to store (Number or String).
      • hasTag

        boolean hasTag​(java.lang.String key)
        Checks if the item has an NBT tag with the specified key.
        Parameters:
        key - The tag key.
        Returns:
        true if present, false otherwise.
      • getTag

        java.lang.Object getTag​(java.lang.String key)
        Returns the value of the NBT tag with the specified key.
        Parameters:
        key - The tag key.
        Returns:
        The tag value, or null if not present.
      • removeTags

        INbt removeTags()
        Removes all custom tags from the item and returns the removed NBT data.
        Returns:
        The removed NBT data.
      • isEnchanted

        boolean isEnchanted()
        Returns:
        Returns whether the item is enchanted.
      • hasEnchant

        boolean hasEnchant​(int id)
        Checks if the item has the specified enchantment.
        Parameters:
        id - The enchantment id.
        Returns:
        true if present, false otherwise.
      • addEnchant

        void addEnchant​(int id,
                        int strength)
        Adds an enchantment to the item.
        Parameters:
        id - The enchantment id.
        strength - The enchantment strength.
      • setAttribute

        void setAttribute​(java.lang.String name,
                          double value)
        Sets an attribute on the item using the default MC attribute system.
        Parameters:
        name - The attribute key.
        value - The attribute value.
      • getAttribute

        double getAttribute​(java.lang.String name)
        Retrieves the attribute value using the default MC attribute system.
        Parameters:
        name - The attribute key.
        Returns:
        The attribute value.
      • hasAttribute

        boolean hasAttribute​(java.lang.String name)
        Checks if the item has an attribute (using the default MC attribute system).
        Parameters:
        name - The attribute key.
        Returns:
        true if present, false otherwise.
      • setCustomAttribute

        void setCustomAttribute​(java.lang.String key,
                                double value)
        Sets the custom attribute value for the given key. The value is stored in the item's custom NBT structure.
        Parameters:
        key - The custom attribute key.
        value - The attribute value.
      • hasCustomAttribute

        boolean hasCustomAttribute​(java.lang.String key)
        Checks whether the item has a custom attribute with the specified key.
        Parameters:
        key - The custom attribute key.
        Returns:
        true if the attribute exists, false otherwise.
      • getCustomAttribute

        float getCustomAttribute​(java.lang.String key)
        Returns the custom attribute object associated with the given key. This may be a raw value or a more complex structure.
        Parameters:
        key - The custom attribute key.
        Returns:
        The attribute object value
      • removeCustomAttribute

        void removeCustomAttribute​(java.lang.String key)
        Removes the custom attribute with the specified key from the item.
        Parameters:
        key - The custom attribute key.
      • setMagicAttribute

        void setMagicAttribute​(java.lang.String key,
                               int magicId,
                               double value)
        Sets the magic attribute value for the given key and magic identifier. The value is stored in the item's custom NBT under "RPGCore" -> "Magic".
        Parameters:
        key - The magic attribute key.
        magicId - The magic identifier.
        value - The attribute value.
      • hasMagicAttribute

        boolean hasMagicAttribute​(java.lang.String key,
                                  int magicId)
        Checks whether the item has a magic attribute with the given key and magic identifier.
        Parameters:
        key - The magic attribute key.
        magicId - The magic identifier.
        Returns:
        true if the attribute exists, false otherwise.
      • getMagicAttribute

        float getMagicAttribute​(java.lang.String key,
                                int magicId)
        Returns the magic attribute object (typically a Float value) associated with the given key and magic identifier.
        Parameters:
        key - The magic attribute key.
        magicId - The magic identifier.
        Returns:
        The attribute object, or null if not present.
      • removeMagicAttribute

        void removeMagicAttribute​(java.lang.String key,
                                  int magicId)
        Removes the magic attribute with the specified key and magic identifier from the item.
        Parameters:
        key - The magic attribute key.
        magicId - The magic identifier.
      • setRequirement

        void setRequirement​(java.lang.String reqKey,
                            java.lang.Object value)
        Sets (or applies) a requirement for the item using the given requirement key and value. The requirement data is stored under "RPGCore" → "Requirements" in the item's NBT.
        Parameters:
        reqKey - The requirement key.
        value - The requirement value (Number or String).
      • hasRequirement

        boolean hasRequirement​(java.lang.String reqKey)
        Checks whether the item has a requirement with the specified key.
        Parameters:
        reqKey - The requirement key.
        Returns:
        true if the requirement exists, false otherwise.
      • getRequirement

        java.lang.Object getRequirement​(java.lang.String reqKey)
        Retrieves the requirement value for the specified key.
        Parameters:
        reqKey - The requirement key.
        Returns:
        The requirement value as an Object (or null if not present).
      • removeRequirement

        void removeRequirement​(java.lang.String reqKey)
        Removes the requirement with the specified key from the item.
        Parameters:
        reqKey - The requirement key.
      • getCustomAttributeKeys

        java.lang.String[] getCustomAttributeKeys()
        Returns an array of all custom attribute keys stored on the item.
        Returns:
        an array of custom attribute keys.
      • getMagicAttributeKeys

        java.lang.String[] getMagicAttributeKeys​(java.lang.String key)
        Returns an array of all magic attribute keys (as strings) for the specified magic attribute key.
        Parameters:
        key - the magic attribute key (e.g. "magic_damage").
        Returns:
        an array of magic identifier keys as strings.
      • getRequirementKeys

        java.lang.String[] getRequirementKeys()
        Returns an array of all requirement keys stored on the item.
        Returns:
        an array of requirement keys.
      • getLore

        java.lang.String[] getLore()
        Returns:
        Returns the lore (descriptive text) for the item.
      • hasLore

        boolean hasLore()
        Returns:
        Returns whether the item has lore.
      • setLore

        void setLore​(java.lang.String[] lore)
        Sets the lore for the item.
        Parameters:
        lore - An array of lore strings.
      • copy

        IItemStack copy()
        Creates a deep copy of this item stack.
        Returns:
        A copy of the item stack.
      • getMaxItemDamage

        int getMaxItemDamage()
        Returns:
        Returns the maximum damage the item can sustain.
      • isWrittenBook

        boolean isWrittenBook()
        Returns:
        Returns whether the item is a written book.
      • getBookTitle

        java.lang.String getBookTitle()
        Returns:
        Returns the book's title.
      • getBookAuthor

        java.lang.String getBookAuthor()
        Returns:
        Returns the book's author.
      • getBookText

        java.lang.String[] getBookText()
        Returns:
        If the item is a book, returns the book pages.
      • isBlock

        boolean isBlock()
        Returns:
        Returns whether the item represents a block.
      • getNbt

        INbt getNbt()
        Returns an INbt instance representing the item's custom NBT data.
        Returns:
        The custom NBT data.
      • getItemNbt

        INbt getItemNbt()
        Returns an INbt instance representing the full NBT data of the item.
        Returns:
        The complete NBT data.
      • getMCItemStack

        net.minecraft.item.ItemStack getMCItemStack()
        Returns the underlying Minecraft ItemStack.

        No support is given for this method. Use with caution.

        Returns:
        The Minecraft ItemStack.
      • itemHash

        int itemHash()
        Returns a hash value for the item.
        Returns:
        The item's hash code.
      • getMCNbt

        net.minecraft.nbt.NBTTagCompound getMCNbt()
        Returns the underlying Minecraft NBTTagCompound for the item.
        Returns:
        The NBTTagCompound.
      • setMCNbt

        void setMCNbt​(net.minecraft.nbt.NBTTagCompound compound)
        Sets the underlying Minecraft NBTTagCompound for the item.
        Parameters:
        compound - The NBTTagCompound to set.
      • compare

        boolean compare​(IItemStack item,
                        boolean ignoreNBT)
        Compares this item with another item, with an option to ignore NBT data.
        Parameters:
        item - The item to compare.
        ignoreNBT - true to ignore NBT data.
        Returns:
        true if the items are considered equal, false otherwise.
      • compare

        boolean compare​(IItemStack item,
                        boolean ignoreDamage,
                        boolean ignoreNBT)
        Compares this item with another item, with options to ignore damage and/or NBT data.
        Parameters:
        item - The item to compare.
        ignoreDamage - true to ignore damage values.
        ignoreNBT - true to ignore NBT data.
        Returns:
        true if the items are considered equal, false otherwise.