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

NBT

NBT (Named Binary Tag) is a tag based binary format designed to carry large amounts of binary data with smaller amounts of additional data. You can get or set nbt tags of entities, native tile entities (such as chests or beacons) and items. To get more information about these data structures, see page.

Index

Classes

CompoundTag

CompoundTag:

List tags represent NBT map-like data structure (key-value pairs). it's values may be of any type, so check the type before calling the appropriate getter.

constructor

clear

  • clear(): void
  • Removes all the tags from the compound tags.


    Returns void

contains

  • contains(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

    true if specified key exists in compound tag.

containsValueOfType

  • containsValueOfType(key: string, type: number): boolean
  • Parameters

    • key: string

      key to verify for the type

    • type: number

      tag type to verify for, one of the ENbtDataType constants

    Returns boolean

    true if specified key exists in compound tag and it's value is of specified type.

getAllKeys

  • getAllKeys(): Array<string>
  • Returns Array<string>

    Java-array containing all the keys of the compound tag.

getByte

  • getByte(key: string): number
  • Parameters

    • key: string

    Returns number

    NBT tag of byte type by it's key.

getCompoundTag

  • Parameters

    • key: string

    Returns CompoundTag

    NBT tag of compound type by it's key. Note that a copy of existing compound tag is created so you cannot edit it directly. Use setCompoundTag method to apply changes or use getCompoundTagNoClone to edit it directly.

getCompoundTagNoClone

  • Parameters

    • key: string

    Returns CompoundTag

    Directly editable NBT tag of byte type by it's key. Don't save reference for future usage since they get destroyed when the parent object is destroyed.

getDouble

  • getDouble(key: string): number
  • Parameters

    • key: string

    Returns number

    NBT tag of double type by it's key.

getFloat

  • getFloat(key: string): number
  • Parameters

    • key: string

    Returns number

    NBT tag of float type by it's key.

getInt

  • getInt(key: string): number
  • Parameters

    • key: string

    Returns number

    NBT tag of 32-bit integer type by it's key.

getInt64

  • getInt64(key: string): number
  • Parameters

    • key: string

    Returns number

    NBT tag of 64-bit integer type by it's key.

getListTag

  • Parameters

    • key: string

    Returns ListTag

    NBT tag of list type by it's key. Note that a copy of existing list tag is created so you cannot edit it directly. Use setCompoundTag method to apply changes or use getListTagNoClone to edit it directly.

getListTagNoClone

  • getListTagNoClone(key: string): ListTag
  • Parameters

    • key: string

    Returns ListTag

    Directly editable NBT tag of byte type by it's key. Don't save reference for future usage since they get destroyed when the parent object is destroyed.

getShort

  • getShort(key: string): number
  • Parameters

    • key: string

    Returns number

    NBT tag of short type by it's key.

getString

  • getString(key: string): string
  • Parameters

    • key: string

    Returns string

    NBT tag of string type by it's key.

getValueType

  • getValueType(key: string): number
  • Parameters

    • key: string

    Returns number

    Value type for the specified key. One of the ENbtDataType constants.

putByte

  • putByte(key: string, value: number): void
  • Puts value of byte type into compound tag.


    Parameters

    • key: string
    • value: number

    Returns void

putCompoundTag

  • Puts value of compound type into compound tag.


    Parameters

    Returns void

putDouble

  • putDouble(key: string, value: number): void
  • Puts value of double type into compound tag.


    Parameters

    • key: string
    • value: number

    Returns void

putFloat

  • putFloat(key: string, value: number): void
  • Puts value of float type into compound tag.


    Parameters

    • key: string
    • value: number

    Returns void

putInt

  • putInt(key: string, value: number): void
  • Puts value of 32-bit integer type into compound tag.


    Parameters

    • key: string
    • value: number

    Returns void

putInt64

  • putInt64(key: string, value: number): void
  • Puts value of 64-bit integer type into compound tag.


    Parameters

    • key: string
    • value: number

    Returns void

putListTag

  • putListTag(key: string, value: ListTag): void
  • Puts value of list type into compound tag.


    Parameters

    Returns void

putShort

  • putShort(key: string, value: number): void
  • Puts value of short type into compound tag.


    Parameters

    • key: string
    • value: number

    Returns void

putString

  • putString(key: string, value: string): void
  • Puts value of string type into compound tag.


    Parameters

    • key: string
    • value: string

    Returns void

remove

  • remove(key: string): void
  • Removes tag by it's key.


    Parameters

    • key: string

    Returns void

toScriptable

  • Converts compound tag to JavaScript object for easier reading.


    Returns Scriptable

    Valid JavaScript representation of compound tag.

ListTag

ListTag:

List tags represent NBT array-like indexed data structure. it's values may be of any type, so check the type before calling the appropriate getter.

constructor

  • Creates a new list tag.


    Returns ListTag

clear

  • clear(): void
  • Removes all the tags from the compound tags.


    Returns void

getByte

  • getByte(index: number): number
  • Parameters

    • index: number

    Returns number

    NBT tag of byte type by it's index.

getCompoundTag

  • Parameters

    • index: number

    Returns CompoundTag

    NBT tag of compound type by it's index. Note that a copy of existing compound tag is created so you cannot edit it directly. Use setCompoundTag method to apply changes or use getCompoundTagNoClone to edit it directly.

getCompoundTagNoClone

  • Parameters

    • index: number

    Returns CompoundTag

    Directly editable NBT tag of byte type by it's index. Don't save reference for future usage since they get destroyed when the parent object is destroyed.

getDouble

  • getDouble(index: number): number
  • Parameters

    • index: number

    Returns number

    NBT tag of double type by it's index.

getFloat

  • getFloat(index: number): number
  • Parameters

    • index: number

    Returns number

    NBT tag of float type by it's index.

getInt

  • getInt(index: number): number
  • Parameters

    • index: number

    Returns number

    NBT tag of 32-bit integer type by it's index.

getInt64

  • getInt64(index: number): number
  • Parameters

    • index: number

    Returns number

    NBT tag of 64-bit integer type by it's index.

getListTag

  • Parameters

    • index: number

    Returns ListTag

    NBT tag of list type by it's index. Note that a copy of existing list tag is created so you cannot edit it directly. Use setCompoundTag method to apply changes or use getListTagNoClone to edit it directly.

getListTagNoClone

  • getListTagNoClone(index: number): ListTag
  • Parameters

    • index: number

    Returns ListTag

    Directly editable NBT tag of byte type by it's index. Don't save reference for future usage since they get destroyed when the parent object is destroyed.

getShort

  • getShort(index: number): number
  • Parameters

    • index: number

    Returns number

    NBT tag of short type by it's index.

getString

  • getString(index: number): string
  • Parameters

    • index: number

    Returns string

    NBT tag of string type by it's index.

getValueType

  • getValueType(index: number): number
  • Parameters

    • index: number

    Returns number

    Value type for the specified index. One of the ENbtDataType constants.

length

  • length(): number
  • Returns number

    Count of the tags in the list tag.

putByte

  • putByte(index: number, value: number): void
  • Puts value of byte type into list tag.


    Parameters

    • index: number
    • value: number

    Returns void

putCompoundTag

  • putCompoundTag(index: number, value: CompoundTag): void
  • Puts value of compound type into list tag.


    Parameters

    Returns void

putDouble

  • putDouble(index: number, value: number): void
  • Puts value of double type into list tag.


    Parameters

    • index: number
    • value: number

    Returns void

putFloat

  • putFloat(index: number, value: number): void
  • Puts value of float type into list tag.


    Parameters

    • index: number
    • value: number

    Returns void

putInt

  • putInt(index: number, value: number): void
  • Puts value of 32-bit integer type into list tag.


    Parameters

    • index: number
    • value: number

    Returns void

putInt64

  • putInt64(index: number, value: number): void
  • Puts value of 64-bit integer type into list tag.


    Parameters

    • index: number
    • value: number

    Returns void

putListTag

  • putListTag(index: number, value: ListTag): void
  • Puts value of list type into list tag.


    Parameters

    Returns void

putShort

  • putShort(index: number, value: number): void
  • Puts value of short type into list tag.


    Parameters

    • index: number
    • value: number

    Returns void

putString

  • putString(index: number, value: string): void
  • Puts value of string type into list tag.


    Parameters

    • index: number
    • value: string

    Returns void

toScriptable

  • toScriptable(): any[]
  • since: 2.0.5b45

    Converts list tag to JavaScript object for easier reading.


    Returns any[]

    Valid JavaScript representation of list tag.