3.1.2 • Published 5 months ago

parsenbt-js v3.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

ParseNBT.js

ParseNBT.js is a JavaScript-based minecraft NBT parser and serializer.

Install

npm i parsenbt-js

Usage

Reader

const fs = require('fs'), NBT = require('parsenbt-js');

var binData = fs.readFileSync('./path/of/nbt.nbt');
// The NBT.Reaer returns an object
console.log(NBT.Reader(binData));

Writer

const fs = require('fs'), NBT = require('parsenbt-js');

var nbtData = {
  "comp>": {
    "i32>count": 100,
    "list>pos": [ "i32", 0, 0, 0 ],
    "i64>ticks": { "low": 114514, "high": 1919810 }
  }
};

// The NBT.Writer returns an ArrayBuffer
// The second param determined the byte order
// little-endian if it's true
console.log(NBT.Writer(nbtData, !0));

API

See API.md

Data Structure

ParseNBT.js' output uses a special data structure for keys of the object.

For example:

{
  "comp>": { 
    "i32>count": 100,
    "list>pos": [ "i32", 0, 0, 0 ],
    "i64>ticks": { "low": 114514, "high": 1919810 }
  }
}

In the object, keys are separated into two parts with character >.

In the left-hand-side is the tag type, and the right-hand-side is the tag name. Tag name can be an empty string like above.

The comparison table between the type string and the actual type is as follows: | Tag ID | Tag Type | Tag Type String | | ---- | ---- | ---- | | 0 | TAG_End | null | | 1 | TAG_Byte | i8 | | 2 | TAG_Short | i16 | | 3 | TAG_Int | i32 | | 4 | TAG_Long | i64 | | 5 | TAG_Float | f32 | | 6 | TAG_Double | f64 | | 7 | TAG_Byte_Array | a8 | | 8 | TAG_String | str | | 9 | TAG_List | list | | 10 | TAG_Compound | comp | | 11 | TAG_Int_Array | a32 | | 12 | TAG_Long_Array | a64 |

Especially, the type of elements in TAG_List is the first element of the list array. And for TAG_Long, it'll be formatted into an object which has two values named low and high, that produces the high 32 bits and the low 32 bits separately.

2.3.0

9 months ago

2.2.2

9 months ago

3.0.4

9 months ago

3.1.2

5 months ago

3.0.3

9 months ago

3.1.1

5 months ago

3.0.2

9 months ago

3.1.0

9 months ago

3.0.1

9 months ago

3.0.5

9 months ago

3.0.0

9 months ago

2.2.1

10 months ago

2.1.2

10 months ago

2.2.0

10 months ago

2.1.1

10 months ago

2.1.0

10 months ago

2.0.0

10 months ago

1.1.3

10 months ago

1.1.1

1 year ago

1.0.2

1 year ago

1.1.0

1 year ago

1.1.2

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago