Skip to content

Instantly share code, notes, and snippets.

@wtfaremyinitials wtfaremyinitials/Chunk.js Secret
Created Mar 3, 2015

Embed
What would you like to do?
Chunk.js
var CHUNK_SIZE = 16;
var CHUNK_HEIGHT = 256;
var Chunk = function(buf) {
if(!(this instanceof Chunk))
return new Chunk(buf);
this.data = buf || new Buffer(CHUNK_SIZE * CHUNK_SIZE * CHUNK_HEIGHT);
};
Chunk.prototype.getBlockAt = function(location) {
var position = (location.x) + (location.z * CHUNK_SIZE) + (location.y * CHUNK_HEIGHT);
var block = {
id: bitwiseStuff(this.data[position]),
data: moreBitwiseStuff(this.data[position])
};
return block;
};
module.exports = Chunk;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.