PrismarineJS / minecraft-chunk-dumper

Dumps chunks for any minecraft version
9 stars 7 forks source link

minecraft-chunk-dumper

NPM version Build Status

Dumps chunks for minecraft versions 1.7 to 1.15

Install

To install a minecraftChunkDumper command line program, run:

npm install minecraft-chunk-dumper -g

Usage

Cli

$ minecraftChunkDumper --help

Usage:
    minecraftChunkDumper [command] <minecraft-version> <options>

Example:
    minecraftChunkDumper saveChunk "1.14.4" "chunk.dump" "chunk.meta" "chunk_light.dump" "chunk_light.meta"

Commands:
    saveChunk <minecraft-version> <chunk-file> <meta-file>    save a single chunk file to specified files
    saveChunks <minecraft-version> <folder> <count>           save the specified number of chunks to the given folder
    continuouslySave <minecraft-version> <folder>             continuously saves chunks to the specified folder, until the program is stopped

Programmatic example

const ChunkDumper = require('minecraft-chunk-dumper')

const chunkDumper = new ChunkDumper('1.14.4')

async function run () {
  await chunkDumper.start()
  chunkDumper.on('chunk', (x, z, bitMap, chunkData) => console.log('I received a chunk at ' + x + ';' + z))
  chunkDumper.on('chunk_light', ({ chunkX, chunkZ }) => console.log('I received a chunk light at ' + chunkX + ';' + chunkZ))
  await chunkDumper.saveChunks('dumps/', 100)
  await chunkDumper.stop()
}

run().then(() => console.log('All done !'))

Debugging

You can enable some debugging output using DEBUG environment variable:

DEBUG="chunk-dumper" node [...]

API

ChunkDumper is a class which can dumps chunk for a given minecraft version.

It saves 2 type of files :

for more recent versions (starting from 1.14), it also saves chunk light files :

You should create an instance with the version you want. Then start it. You then have several possibilities :

When you are done, you should call the stop method to finish your session.

ChunkDumper(version)

Build a new ChunkDumper for minecraft version

ChunkDumper.start()

Downloads and starts the server then connect a node-minecraft-protocol client to it. Returns a promise when ready.

ChunkDumper.stop()

Stops the nmp client then stops the server. Returns a promise when finished.

ChunkDumper.saveChunk(chunkFile, metaFile, chunkLightFile, metaChunkLightFile)

Save 1 chunk in specified chunkFile and metaFile Save 1 chunk light in specified chunkLightFile and metaChunkLightFile Returns a promise when finished.

ChunkDumper.saveChunks(folder, n)

Save n chunks in specified folder Returns a promise when finished.

ChunkDumper.startSavingChunks(folder)

Continuously saves all chunk and metadata file to folder.

ChunkDumper.stopSavingChunks()

Stops saving chunks

"chunk"(x, z, bitMap, chunkData)

Emitted when a chunk is received

License

MIT. Copyright (c) Romain Beaumont