Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tigercrl/nbt-parser

Minecraft NBT (NamedBinary Tags) parser for Node.js
https://github.com/tigercrl/nbt-parser

minecraft nbt nodejs npm parser snbt

Last synced: 3 months ago
JSON representation

Minecraft NBT (NamedBinary Tags) parser for Node.js

Awesome Lists containing this project

README

        

# NBT-Parser

Minecraft NBT (NamedBinary Tags) parser for Node.js

## Supports
* Java & Bedrock(Not tested) edition
* Parsing NBT / SNBT to JSON
* Dumping JSON to NBT

## Installation
```
npm install nbt-parser
```

## Usage

```typescript
// Importing
const NBT = require('nbt-parser');
// or
import NBT from "nbt-parser";

// Parse NBT
const nbt = NBT.parseJSON({ key: "value" });
const nbt = NBT.parseNBT(new Uint8Array([]), 'java');
const nbt = NBT.parseSNBT("{key:value}");

// Dumping NBT
nbt.toJSON();
nbt.toJSONString();
nbt.toNBT('gzip', 'java');
nbt.toSNBT('formatted');

// Getting tags or payloads
const tag = nbt.getRootTag();
// tag.getTagName(), tag.getTagId() ...
const payload = tag.getPayload();
// payload.getValue(), payload.toSNBTValue(), payload.toUint8Array()...
```