Last active
November 27, 2021 17:12
-
-
Save lucasdamianjohnson/bbe9d8a6a324f1c022f63d76a5c8cf38 to your computer and use it in GitHub Desktop.
Byte Set Example TypeScript
This file contains 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
const chunk : number[][][] = []; | |
const blockBytes : number[] = []; | |
for(const x of chunk.keys()) { | |
for(const z of chunk[x].keys()) { | |
for(const y of chunk[x][z].keys()) { | |
const block = chunk[x][z][y]; | |
if(!block)continue; | |
let blockByte = 0; | |
if(!chunk[x][z][y + 1]) { | |
blockByte = setBit(blockByte,0,1); | |
} | |
if(!chunk[x][z][y - 1]) { | |
blockByte = setBit(blockByte,1,1); | |
} | |
if(!chunk[x + 1][z][y]) { | |
blockByte = setBit(blockByte,2,1); | |
} | |
if(!chunk[x - 1][z][y]) { | |
blockByte = setBit(blockByte,3,1); | |
} | |
if(!chunk[x][z + 1][y]) { | |
blockByte = setBit(blockByte,4,1); | |
} | |
if(!chunk[x][z - 1][y]) { | |
blockByte = setBit(blockByte,5,1); | |
} | |
blockBytes.push(blockByte); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment