Class: Reader

nbt.Reader()

new Reader()

In addition to the named writing methods documented below, the same methods are indexed by the NBT type number as well, as shown in the example below.
Source:
See:
Example
var reader = new nbt.Reader(buf);
int x = reader.int();
int y = reader[3]();
int z = reader[nbt.tagTypes.int]();

Members

offset :number

The current location in the buffer. Can be freely changed within the bounds of the buffer.
Type:
  • number
Source:

Methods

byte() → {number}

Source:
Returns:
the read byte
Type
number

byte() → {number}

Source:
Returns:
the read unsigned byte
Type
number

byteArray() → {Array.<number>}

Source:
Returns:
the read array
Type
Array.<number>

compound() → {Object.<string, {type: string, value}>}

Source:
Returns:
Type
Object.<string, {type: string, value}>
Example
reader.compound();
// -> { foo: { type: int, value: 42 },
//      bar: { type: string, value: 'Hello! }}

double() → {number}

Source:
Returns:
the read signed 64-bit float
Type
number

float() → {number}

Source:
Returns:
the read signed 32-bit float
Type
number

int() → {number}

Source:
Returns:
the read signed 32-bit integer
Type
number

intArray() → {Array.<number>}

Source:
Returns:
the read array of 32-bit ints
Type
Array.<number>

list() → {Object}

Source:
Returns:
Type
Object
Example
reader.list();
// -> { type: 'string', values: ['foo', 'bar'] }

long() → {Array.<number>}

As JavaScript does not not natively support 64-bit integers, the value is returned as an array of two 32-bit integers, the upper and the lower.
Source:
Returns:
[upper, lower]
Type
Array.<number>

longArray() → {Array.<number>}

As JavaScript does not not natively support 64-bit integers, the value is returned as an array of arrays of two 32-bit integers, the upper and the lower.
Source:
Returns:
the read array of 64-bit ints split into [upper, lower]
Type
Array.<number>

short() → {number}

Source:
Returns:
the read signed 16-bit short
Type
number

string() → {string}

Source:
Returns:
the read string
Type
string