Giter VIP home page Giter VIP logo

minecraft-region's Introduction

minecraft-region

parses chunks out of a minecraft region file

extracted from code originally written by @ithkuil for mcchunkloader, turned into a module and now maintained by @maxogden

minecraft is property of Mojang AB

var mcRegion = require('minecraft-region')
var region = mcRegion(binaryRegionData) // from a .mca file
var chunkX = 0
var chunkY = 0
if (region.hasChunk(chunkX, chunkY))
  var chunk = region.getChunk(chunkX, chunkY)

now use the chunk with minecraft-region to get voxel data

this module works with minecraft-chunk and is used by minecraft-mca

designed for use with browserify

license

BSD

minecraft-region's People

Contributors

max-mapper avatar shama avatar

Stargazers

Gabriel Bertola Bocca avatar electrovir avatar Konrad Linkowski avatar  avatar Cedric TESNIERE avatar Vinicius A. Portela avatar Rudie Dirkx avatar Memorias de un informático (Lorenzo) avatar Jason Mandel avatar Chien-Yu Lin avatar Ian Paschal avatar ilixn avatar  avatar  avatar Steve De Jonghe avatar  avatar James Koval avatar

Watchers

evandrix avatar  avatar

minecraft-region's Issues

Zlib problem in getChunk method

I'm trying to view and manipulate mca data in node.js. I'd like to use the getChunk(x, y) method, but it's been giving me trouble. Here some test code I used to see if I could read chunks. It's a modified version of the test.js file in the repo.

mcRegion = require('./')
var fs = require('fs')
var mcaData = fs.readFileSync('r.0.1.mca')
var region = mcRegion(mcaData)
console.log('region loaded')
console.log(region.getChunk(0, 0)) 

Here's the output I'm getting:

region loaded
[ommited path info]/zlibjs-node.js:2
(function() {'use strict';function m(a){throw a;}var p=void 0,u=!0;var A="unde
                                              ^
Error: unsupported compression method
    at Error (native)
    at new Db (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/zlibjs-node.js:53:430)
    at Object.Hb [as inflateSync] (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/zlibjs-node.js:55:46)
    at Region.getChunk (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/index.js:68:29)
    at Region.getChunk (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/index.js:8:59)
    at Object.<anonymous> (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/test.js:6:20)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

I'm using node v0.12.2. Also tried with node v0.10.40 and got the same error. The only other thing I tried was changing line 5 in index.js from

 else var Zlib = require('./zlibjs-node')

to

 else var Zlib = require('zlib')

That gave me the following output:

region loaded
zlib.js:236
    throw new TypeError('Not a string or buffer');
          ^
TypeError: Not a string or buffer
    at zlibBufferSync (zlib.js:236:11)
    at Object.exports.inflateSync (zlib.js:172:10)
    at Region.getChunk (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/index.js:68:29)
    at Region.getChunk (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/index.js:8:59)
    at Object.<anonymous> (/Users/eric/Documents/Programming/Projects/local/minecraft-journal/node_modules/minecraft-region/test.js:6:20)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

Any help would be much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.