0.1.15 • Published 4 years ago

@bedrocker/mc-nbt v0.1.15

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Minecraft NBT Parser

Built with TypeScript

NPM version Build Status

MC-NBT is a TypeScript parser and serializer for NBT archives, for use with Node.js.

Installation

To install into your project, simply run npm install --save @bedrocker/mc-nbt in the root of your project.

Usage

To read NBT headers from a file, the following code snippet should get you going:

const NBT = require('@bedrocker/mc-nbt')
const fs = require('fs')

fs.readFile('data.nbt', (error, data) => {
  if (error) throw error;

  nbt.parse(data, (error, data) => {
    console.log(data.value.stringTest.value);
    console.log(data.value['nested compound test'].value);
  });
});

If the file is ZLib compressed, then it will automatically be decompressed first

API

writeUncompressed(value,isLittleEndian)

Returns a buffer with a serialized nbt value. If isLittleEndian is passed and is true, write little endian nbt (mcpe).

parseUncompressed(data,isLittleEndian)

Takes a buffer data and returns a parsed nbt value. If isLittleEndian is passed and is true, read little endian nbt (mcpe).

parse(data,isLittleEndian, callback)

Takes an optionally compressed data and provide a parsed nbt value in the callback(err,value). If isLittleEndian is passed and is true, read little endian nbt (mcpe).

simplify(nbt)

Returns a simplified nbt representation : keep only the value to remove one level. This loses the types so you cannot use the resulting representation to write it back to nbt.

proto

Provide the protodef instance used to parse and serialize nbt.

protoLE

Provide the protodef instance used to parse and serialize little endian nbt.

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago