All Projects → BoogeeDoo → mcnbt

BoogeeDoo / mcnbt

Licence: MIT License
Yet another Minecraft NBT format file / buffer parser for Node.js.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to mcnbt

minecraft-lambda-function
AWS Lambda function for managing Minecraft server
Stars: ✭ 37 (+146.67%)
Mutual labels:  minecraft
Retroguard
The MCP teams Retroguard version
Stars: ✭ 20 (+33.33%)
Mutual labels:  minecraft
Loot-Slash-Conquer-Pre1.14
An immersive, action-RPG mod based on Hack/Mine.
Stars: ✭ 17 (+13.33%)
Mutual labels:  minecraft
FrogCraft-Rebirth
A standalone rewrite of FrogCraft, an IC2 Addon with theme of chemical industry, starting from scratch.
Stars: ✭ 27 (+80%)
Mutual labels:  minecraft
picraft
An alternate Python Minecraft API for the Raspberry Pi
Stars: ✭ 49 (+226.67%)
Mutual labels:  minecraft
BedrockProxy
Allow Minecraft Bedrock players on your BungeeCord server!
Stars: ✭ 16 (+6.67%)
Mutual labels:  minecraft
roboserver
Control OpenComputers robots without writing any code!
Stars: ✭ 52 (+246.67%)
Mutual labels:  minecraft
Crucible
Crucible is a Thermos fork containing various patches for bug fixes and performance improvements. Join our discord to stay updated with the project development.
Stars: ✭ 67 (+346.67%)
Mutual labels:  minecraft
AutoSaveWorld
Bukkit plugin that provides advanced bukkit server management capabilities. Supports automatic saves, backups, stale data purge, plugin management, and more.
Stars: ✭ 31 (+106.67%)
Mutual labels:  minecraft
BlockTuner
A Minecraft data pack which helps you tune note blocks
Stars: ✭ 18 (+20%)
Mutual labels:  minecraft
TotalEconomy
All in one economy plugin for Minecraft and Sponge.
Stars: ✭ 32 (+113.33%)
Mutual labels:  minecraft
JSPrismarine
Dedicated Minecraft Bedrock Edition server written in TypeScript.
Stars: ✭ 162 (+980%)
Mutual labels:  minecraft
NpcDialog
🗽 PocketMine-MP virion to add dialogs to entities easily
Stars: ✭ 55 (+266.67%)
Mutual labels:  minecraft
Allomancy
Brandon Sanderson's Allomancy, now in Minecraft
Stars: ✭ 18 (+20%)
Mutual labels:  minecraft
Hytilities
Hypixel-focused Quality of Life mod.
Stars: ✭ 53 (+253.33%)
Mutual labels:  minecraft
anticope.ml
Welcome to the AntiCope Website! Here you can find a list of free and open-source Meteor Client addons as well as other client-side Fabric Minecraft mods.
Stars: ✭ 39 (+160%)
Mutual labels:  minecraft
BTW-Public
Community repository for the BTW CE mod
Stars: ✭ 16 (+6.67%)
Mutual labels:  minecraft
beet
The Minecraft pack development kit.
Stars: ✭ 51 (+240%)
Mutual labels:  minecraft
minicraft
SEU CS Computer Graphics Course Design: a Minecraft-like game based on openGL
Stars: ✭ 25 (+66.67%)
Mutual labels:  minecraft
UHC
UHC plugin for Minecraft: Bedrock Edition.
Stars: ✭ 23 (+53.33%)
Mutual labels:  minecraft

MCNBT

Yet another Minecraft NBT format file / buffer parser for Node.js.

Installation

$ npm install --save mcnbt

Usage

First require this package into your code:

var NBT = require("mcnbt");

Load & Parse NBT

There're several function for you to parse an NBT structure after you instantiating an object:

  • loadFromBuffer(buff, callback)
  • loadFromZlibCompressedBuffer(buff, callback)
  • loadFromFile(filename, callback)
  • loadFromZlibCompressedFile(filename, callback)

All those functions's callback should be written like:

function(err) {
    //... Your code here
}

For an example:

var nbt = new NBT();
nbt.loadFromZlibCompressedFile("level.dat", function(err) {
    if(err) return console.error(err);
    console.log(nbt);
});

Write Back To NBT

Two methods for you to write NBT:

  • writeToCompressedBuffer(callback, [method])
  • writeToBuffer(): returns the buffer (sync)
  • writeToCompressedFile(filename, callback, [method])
  • writeToFile(filename, callback)

method is an optional parameter that indicates the zlib algorithm. The default value is "gzip".

Get Tag(s)

After parsing your NBT, you can get the root tag(s).

  • keys(): get the root tag-key(s) into an array
  • count(): root tag(s) count
  • select(tagname): this function will returns you a instance of tag which named tagname

The tag(s) are instance(s) of BaseTag. There're 10 subclasses of BaseTag.

Tag Class

All the tag classes's parent class is BaseTag.

BaseTag and all of the tags have functions below:

  • getType(): get this tag's type name. eg. "TAG_Compound"
  • getId(): alias of getType
  • getTypeId(): get this tag's type id. eg. "TAG_Compound"'s id is 10
  • getName(): get this tag's name
  • getValue(): get this tag's content
  • setValue(value): set this tag's value
  • count(): get this tag's children count / length (if any)
  • selectAt(idx): get this tag's children / char at idx (if any)
  • select(tagname): get this tag's children by tagname (if any)
  • getAt(idx): alias of selectAt
  • get(tagname): alias of select
  • toJSON(): convert this tag and all of its children into a JSON object

TAGByte

The value's type is byte (number in js).

No extra method.

TAGShort

The value's type is short (number in js).

No extra method.

TAGInt

The value's type is integer (number in js).

No extra method.

TAGLong

The value's type is long long (bignum in js).

No extra method.

TAGFloat

The value's type is float (number in js).

No extra method.

TAGDouble

The value's type is double (nbumer in js).

No extra method.

TAGByteArray

The value's type is array of byte (array of number in js).

There're 5 extra methods:

  • shift()
  • unshift(value)
  • pop()
  • push(value)
  • insert(value, position)

TAGString

The value's type is string.

No extra method.

TAGList

The value's type is array of any Tag instances (array of Tag instances in js).

There're 6 extra methods:

  • shift()
  • unshift(value)
  • pop()
  • push(value)
  • insert(value, position)
  • clean()

TAGCompound

The value's type is object contains any Tag instances.

There're 4 extra methods:

  • setByName(name, value, [replace]): set name child into a certain Tag instance. if replace equals to false, it won't replace an exsiting child. replace defaults to false
  • getNames(): get children's names
  • deleteByName(name): delete a child tag by tag name
  • clean(): clean all children

TAGIntArray

The value's type is array of integer (array of number in js).

There're 5 extra methods:

  • shift()
  • unshift(value)
  • pop()
  • push(value)
  • insert(value, position)

Example

You may refer to test/test.js:

var NBT = require("../nbt");
var nbt = new NBT();
nbt.loadFromZlibCompressedFile("./level.dat", function(err) {
    if(err) return console.error(err);
    var gameRules = nbt.select("").select("Data").select("GameRules");
    console.log(gameRules.getType());
    console.log(gameRules.getTypeId());
    console.log(gameRules.toString());
});

Contribute

You're welcome to pull requests!

「雖然我覺得不怎麼可能有人會關注我」

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].