max-mapper / max-mapper/minecraft-region

Zlib problem in getChunk method

Open
#3 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
18
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test.js and the getChunk implementation at index.js:68, then reproduce the failure using the reported r.0.1.mca sample under the stated Node versions. Compare the behavior of zlibjs-node and native zlib at the selection in index.js. Done means getChunk(0, 0) reads the sample chunk without either reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.