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

ItemExtraData

Class representing item extra data. Used to store additional information about item other then just item ID and data.

Index

Constructors

constructor

Methods

addEnchant

  • addEnchant(type: number, level: number): void
  • Adds a new enchantment to the item.


    Parameters

    • type: number

      enchantment ID, one of the EEnchantment constants

    • level: number

      enchantment level, generally between 1 and 5

    Returns void

applyTo

asJson

  • asJson(): JSONObject
  • Returns JSONObject

copy

getAllCustomData

  • getAllCustomData(): string
  • Returns string

getAllEnchantNames

  • getAllEnchantNames(): string

  • Returns string

    All enchantments names separated by line breaks.

getBoolean

  • getBoolean(name: string, fallback?: boolean): boolean

  • Parameters

    • name: string

      parameter name

    • optionalfallback: boolean

      default value to be returned if item extra data doesn't contain a parameter with specified name

    Returns boolean

    Custom boolean parameter value if extra data of the item contains one, fallback value otherwise. If fallback was not specified, null is returned.

getCompoundTag

  • @since

    2.0.5b44


    Returns CompoundTag

    Compound tag for the specified item.

getCustomName

  • getCustomName(): string

  • Returns string

    Item's custom name.

getEnchantCount

  • getEnchantCount(): number

  • Returns number

    Amount of enchantments applied to the item.

getEnchantLevel

  • getEnchantLevel(type: number): number

  • Parameters

    • type: number

      enchantment ID, one of the EEnchantment constants

    Returns number

    Level of the specified enchantment.

getEnchantName

  • getEnchantName(id: number, level: number): string
  • @since

    2.2.1b94 (not worked before)


    Parameters

    • id: number

      enchantment ID, one of the EEnchantment constants

    • level: number

      enchantment level, generally between 1 and 5

    Returns string

    Enchantment name by it's ID and level.

getEnchants

  • getEnchants(): {}
  • Returns {}

    • [id number]: number

getFloat

  • getFloat(name: string, fallback?: number): number

  • Parameters

    • name: string

      parameter name

    • optionalfallback: number

      default value to be returned if item extra data doesn't contain a parameter with specified name

    Returns number

    Custom float parameter value if extra data of the item contains one, fallback value otherwise. If fallback was not specified, null is returned.

getInt

  • getInt(name: string, fallback?: number): number

  • Parameters

    • name: string

      parameter name

    • optionalfallback: number

      default value to be returned if item extra data doesn't contain a parameter with specified name

    Returns number

    Custom integer parameter value if extra data of the item contains one, fallback value otherwise. If fallback was not specified, null is returned.

getLong

  • getLong(name: string, fallback?: number): number

  • Parameters

    • name: string

      parameter name

    • optionalfallback: number

      default value to be returned if item extra data doesn't contain a parameter with specified name

    Returns number

    Custom long integer parameter value if extra data of the item contains one, fallback value otherwise. If fallback was not specified, null is returned.

getRawEnchants

  • getRawEnchants(): number[][]
  • Returns number[][]

getSerializable

  • getSerializable(name: string): any
  • Parameters

    • name: string

    Returns any

getString

  • getString(name: string, fallback?: string): string

  • Parameters

    • name: string

      parameter name

    • optionalfallback: string

      default value to be returned if item extra data doesn't contain a parameter with specified name

    Returns string

    Custom string parameter value if extra data of the item contains one, fallback value otherwise. If fallback was not specified, null is returned.

getValue

  • getValue(): number
  • Returns number

isEmpty

  • isEmpty(): boolean

  • Returns boolean

    true, if item extra exists and is not empty.

isEnchanted

  • isEnchanted(): boolean

  • Returns boolean

    true if the item is enchanted, false otherwise.

isFinalizableInstance

  • isFinalizableInstance(): boolean
  • Returns boolean

putBoolean

  • Puts some custom boolean parameter to the extra data of the item.


    Parameters

    • name: string

      parameter name

    • bool: boolean

      parameter value

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

putFloat

  • Puts some custom floating point number parameter to the extra data of the item.


    Parameters

    • name: string

      parameter name

    • float: number

      parameter value

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

putInt

  • Puts some custom integer parameter to the extra data of the item.


    Parameters

    • name: string

      parameter name

    • int: number

      parameter value

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

putLong

  • Puts some custom long integer parameter to the extra data of the item.


    Parameters

    • name: string

      parameter name

    • long: number

      parameter value

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

putObject


  • Parameters

    • name: string
    • value: any

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

putSerializable

  • putSerializable(name: string, serializableObject: any): ItemExtraData

  • Parameters

    • name: string
    • serializableObject: any

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

putString

  • Puts some custom string parameter to the extra data of the item.


    Parameters

    • name: string

      parameter name

    • value: string

      parameter value

    Returns ItemExtraData

    Reference to itself to be used in sequential calls.

removeAllEnchants

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


    Returns void

removeCustomData

  • removeCustomData(): void
  • Removes all custom parameters from item extra data.


    Returns void

removeEnchant

  • removeEnchant(type: number): void
  • Removes enchantments by it's ID.


    Parameters

    • type: number

      enchantment ID, one of the EEnchantment constants

    Returns void

setAllCustomData

  • setAllCustomData(data: string): void
  • Parameters

    • data: string

    Returns void

setCompoundTag

  • Sets compound tag for the specified item.

    @since

    2.0.5b44


    Parameters

    Returns void

setCustomName

  • setCustomName(name: string): void
  • Sets item's custom name.


    Parameters

    • name: string

    Returns void

staticcloneExtra

staticfromJson

staticgetExtraOrNull

staticgetValueOrNullPtr

staticunwrapObject

staticunwrapValue

  • unwrapValue(extra: any): number
  • Parameters

    • extra: any

    Returns number