Skip to content

Instantly share code, notes, and snippets.

@eddyb
Created September 18, 2011 05:37
Show Gist options
  • Save eddyb/1224773 to your computer and use it in GitHub Desktop.
Save eddyb/1224773 to your computer and use it in GitHub Desktop.
wc.Chunk = function(x, z, data) {
this.x = x / 16;
this.z = z / 16;
this.size = 16*128*16;
data = atob(data);
function byte(pos) {
return data.charCodeAt(pos);
}
function nibble(pos) {
var b = byte(Math.floor(pos/2));
return (pos % 2) ? b >> 4 : b & 0xf;
}
this.data = [];
for(var i = 0; i < this.size; i++)
this.data[i] = /*type*/byte(i) | /*dataVal*/(nibble(this.size*2 + i) << 8) | /*light*/(nibble(this.size*3 + i) << 12) | /*skyLight*/(nibble(this.size*4 + i) << 16);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment