Created
January 7, 2017 17:42
-
-
Save GeorgesOatesLarsen/c92c333c39ab2a2ee91639385cbaa293 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dump() { | |
//OLD/INTERNAL FORMAT: | |
//The first w*l*h*2 bytes are blocks, each of which are shorts. | |
//After that, the first w*l*h*0.5 bytes are block-light-levels, each half-bytes. | |
//Next, the first w*l*h*0.5 bytes are sky-light-levels, each half-bytes. | |
//Finally, the next w*l bytes are biomes. | |
let outputBuffer = Buffer.alloc(0); | |
let chunkBlocks = Chunk.l * Chunk.w * 16; | |
let blockLightStart = Chunk.l * Chunk.w * Chunk.h * 2; | |
let skyLightStart = blockLightStart + Chunk.l * Chunk.w * Chunk.h/2; | |
let biomestart = skyLightStart + Chunk.l * Chunk.w * Chunk.h/2; | |
for (let y = 0; y < 16; y++) | |
{ | |
outputBuffer = Buffer.concat([outputBuffer, proto.createPacketBuffer('section', { | |
bitsPerBlock: 13, | |
palette: Buffer.alloc(0), | |
blockData: this.packBlockData(this.data.slice(y * chunkBlocks*2, (y + 1) * chunkBlocks*2)), | |
blockLight: this.data.slice(blockLightStart + y * chunkBlocks/2, (y + 1) * chunkBlocks/2), | |
skyLight: this.data.slice(blockLightStart + y * chunkBlocks/2, (y + 1) * chunkBlocks/2), | |
})]); | |
//Is biome data even needed? I am not certain. | |
} | |
return outputBuffer.concat([buffer, this.data.slice(biomestart, biomestart+250)]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment