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
Methods
byte() → {number}
Returns:
the read byte
- Type
- number
byte() → {number}
Returns:
the read unsigned byte
- Type
- number
byteArray() → {Array.<number>}
Returns:
the read array
- Type
- Array.<number>
compound() → {Object.<string, {type: string, value}>}
Returns:
- Type
- Object.<string, {type: string, value}>
Example
reader.compound();
// -> { foo: { type: int, value: 42 },
// bar: { type: string, value: 'Hello! }}
double() → {number}
Returns:
the read signed 64-bit float
- Type
- number
float() → {number}
Returns:
the read signed 32-bit float
- Type
- number
int() → {number}
Returns:
the read signed 32-bit integer
- Type
- number
intArray() → {Array.<number>}
Returns:
the read array of 32-bit ints
- Type
- Array.<number>
list() → {Object}
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.
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.
Returns:
the read array of 64-bit ints
split into [upper, lower]
- Type
- Array.<number>
short() → {number}
Returns:
the read signed 16-bit short
- Type
- number
string() → {string}
Returns:
the read string
- Type
- string