2.0.15 • Published 2 years ago

mc-anvil v2.0.15

Weekly downloads
45
License
MIT
Repository
-
Last release
2 years ago

mc-anvil

A Typescript library for reading Minecraft Anvil format files and Minecraft NBT format files in the browser.

Installation

For npm use: npm install mc-anvil --save

For yarn use: yarn add mc-anvil

Usage

Importing

import { NBTParser, AnvilParser } from "mc-anvil";

Reading NBT data

The following example reads the root tag from an NBT file uploaded into the browser:

const reader = new FileReader();
reader.onload = e => {
    const parser = new NBTParser(e);
    const tag = parser.getTag(); // receives contents of the root tag
};
reader.readAsArrayBuffer(file); // file is a File object or Blob containing NBT data

Reading Anvil data

The following example extracts a chunk from an Anvil file uploaded into the browser:

const reader = new FileReader();
reader.onload = e => {
    const parser = new AnvilParser(e);
    const chunks = parser.getLocationEntries();
    const firstNonEmptyChunk = chunks.filter(x => x.offset > 0)[0].offset;
    const data = parser.getChunkData(firstNonEmptyChunk); // receives NBT data of the first chunk
    const nbtParser = new NBTParser(data);
    const tag = nbtParser.getTag(); // receives contents of the chunk's root NBT tag
};
reader.readAsArrayBuffer(file); // file is a File object or Blob containing Anvil data

For contributers

Building

  • Run yarn install to install dependencies.
  • Run yarn build to build.

Testing

You must have Node.js and docker-compose installed.

  • scripts/test.sh to run automated tests.
  • scripts/run-dependencies.sh to stand up a web server to host static sample NBT and Anvil files. scripts/test.sh runs this for you.
  • scripts/stop-dependencies.sh to stop bring down the server.
2.0.15

2 years ago

2.0.14

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.13

3 years ago

2.0.5

3 years ago

2.0.11

3 years ago

2.0.7

3 years ago

2.0.12

3 years ago

2.0.6

3 years ago

2.0.9

3 years ago

2.0.10

3 years ago

2.0.8

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.9.3

4 years ago

1.9.1

4 years ago

1.9.2

4 years ago

1.9.0

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago