Перейти к основному содержанию

ItemStack

Class representing item stack in the inventory.

Implements

  • ItemInstance

Index

Constructors

constructor

  • new ItemStack(): ItemStack
  • new ItemStack(item: ItemInstance): ItemStack
  • new ItemStack(id: number, count: number, data?: number, extra?: ItemExtraData): ItemStack

Properties

count

count: number

data

data: number

optionalextra

extra?: ItemExtraData

id

id: number

Methods

addEnchant

  • addEnchant(id: number, level: number): void
  • Adds a new enchantment to the item. Creates new ItemExtraData instance if it doesn't exist.


    Parameters

    • id: number

      enchantment id, one of the Native.Enchantment constants

    • level: number

      enchantment level, generally between 1 and 5

    Returns void

applyDamage

  • applyDamage(damage: number): void
  • Applies damage to the item and destroys it if its max damage reached


    Parameters

    • damage: number

      amount to apply

    Returns void

clear

  • clear(): void
  • Sets all stack values to 0.


    Returns void

copy

  • Creates a copy of current ItemStack object


    Returns ItemStack

    a created copy of the ItemStack

decrease

  • decrease(count: number): void
  • Decreases stack count by specified value.


    Parameters

    • count: number

      amount to decrease

    Returns void

getCustomName

  • getCustomName(): string

  • Returns string

    item's custom name

getEnchantLevel

  • getEnchantLevel(id: number): number

  • Parameters

    • id: number

      enchantment id, one of the Native.Enchantment constants

    Returns number

    level of the specified enchantment

getEnchants

  • getEnchants(): {}

  • Returns {}

    all the enchantments of the item in the readable format

    • [key number]: number

getItemInstance


  • Returns Nullable<ItemBase>

    instance of item class if the item was added by BlockEngine, null otherwise.

getMaxDamage

  • getMaxDamage(): number

  • Returns number

    maximum damage value for the item

getMaxStack

  • getMaxStack(): number

  • Returns number

    maximum stack size for the item

isEmpty

  • isEmpty(): boolean

  • Returns boolean

    true if all stack values are empty, false otherwise

isEnchanted

  • isEnchanted(): boolean

  • Returns boolean

    true if the item is enchanted, false otherwise

removeAllEnchants

  • removeAllEnchants(): void
  • Removes all the enchantments of the item


    Returns void

removeEnchant

  • removeEnchant(id: number): void
  • Removes enchantments by its id


    Parameters

    • id: number

      enchantment id, one of the Native.Enchantment constants

    Returns void

setCustomName

  • setCustomName(name: string): void
  • Sets item's custom name. Creates new ItemExtraData instance if it doesn't exist.


    Parameters

    • name: string

    Returns void