Skip to content

Instantly share code, notes, and snippets.

@mogery
Created Aug 15, 2021
Embed
What would you like to do?
this.buffer = Buffer.concat([
// packet length is added by wrapper
BufferMangler.writeVarInt(this.constructor.id), // 0x25
BufferMangler.writeVarInt(this.x), // chunk x
BufferMangler.writeVarInt(this.z), // chunk y
BufferMangler.writeUInt8(1), // trust edges
// sky light mask
BufferMangler.writeVarInt(1),
BufferMangler.writeBigUInt64BE(0b111111111111111110n), // Y=17 to 0
// block light mask
BufferMangler.writeVarInt(1),
BufferMangler.writeBigUInt64BE(0b000000000000000000n), // Y=0
// empty sky light mask
BufferMangler.writeVarInt(1),
BufferMangler.writeBigUInt64BE(0b000000000000000001n), // Y=-1
// empty block light mask
BufferMangler.writeVarInt(1),
BufferMangler.writeBigUInt64BE(0b111111111111111111n), // Y=17 to -1
// sky light array
BufferMangler.writeVarInt(17), // length
Buffer.concat(new Array(17).fill(0).map(() => {
return Buffer.concat([
BufferMangler.writeVarInt(2048),
Buffer.concat(new Array(2048).fill(0xff).map(x => BufferMangler.writeUInt8(x)))
])
})),
// block light array
BufferMangler.writeVarInt(0), // length
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment