From 3d1532a649ba88699a9fa33f18f97a7a93a5fffe Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky <vital2580@icloud.com> Date: Fri, 7 Jun 2024 23:21:00 +0300 Subject: [PATCH 1/5] fix type! --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index fbe88ea0..6198473d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -46,7 +46,7 @@ declare class PCChunk extends CommonChunk { dumpBiomes(): Array<number> dumpLight(): Buffer loadLight(data: Buffer, skyLightMask: number, blockLightMask: number, emptySkyLightMask?: number, emptyBlockLightMask?: number): void - loadLightParse(skyLight: Buffer[], blockLight: Buffer[], skyLightMask: number[][], blockLightMask: number[][], emptySkyLightMask: number[][], emptyBlockLightMask: number[][]): void + loadParsedLights(skyLight: Buffer[], blockLight: Buffer[], skyLightMask: number[][], blockLightMask: number[][], emptySkyLightMask: number[][], emptyBlockLightMask: number[][]): void loadBiomes(newBiomesArray: Array<number>): void; dump(bitMap?: number, skyLightSent?: boolean): Buffer load(data: Buffer, bitMap?: number, skyLightSent?: boolean, fullChunk?: boolean): void From ff0dee5c6c0b48dbf322768ce85aceebbed25457 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky <vital2580@icloud.com> Date: Fri, 7 Jun 2024 23:21:59 +0300 Subject: [PATCH 2/5] fix again! --- types/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 6198473d..03bccf22 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -34,7 +34,7 @@ declare class PCChunk extends CommonChunk { getBlockData(pos: Vec3): number getBlockLight(pos: Vec3): number getSkyLight(pos: Vec3): number - getBiome(pos: Vec3): number + getBiome(pos: Vec3): number setBlockStateId(pos: Vec3, stateId: number): number setBlockType(pos: Vec3, id: number): void setBlockData(pos: Vec3, data: Buffer): void @@ -46,7 +46,7 @@ declare class PCChunk extends CommonChunk { dumpBiomes(): Array<number> dumpLight(): Buffer loadLight(data: Buffer, skyLightMask: number, blockLightMask: number, emptySkyLightMask?: number, emptyBlockLightMask?: number): void - loadParsedLights(skyLight: Buffer[], blockLight: Buffer[], skyLightMask: number[][], blockLightMask: number[][], emptySkyLightMask: number[][], emptyBlockLightMask: number[][]): void + loadParsedLights?(skyLight: Buffer[], blockLight: Buffer[], skyLightMask: number[][], blockLightMask: number[][], emptySkyLightMask: number[][], emptyBlockLightMask: number[][]): void loadBiomes(newBiomesArray: Array<number>): void; dump(bitMap?: number, skyLightSent?: boolean): Buffer load(data: Buffer, bitMap?: number, skyLightSent?: boolean, fullChunk?: boolean): void @@ -113,7 +113,7 @@ declare class BedrockChunk extends CommonChunk { maxCY: number // The version of the chunk column (analog to DataVersion on PCChunk) chunkVersion: number - // Holds all the block entities in the chunk, the string keys are + // Holds all the block entities in the chunk, the string keys are // the concatenated chunk column-relative position of the block. blockEntities: Record<string, NBT> // Holds entities in the chunk, the string key is the entity ID @@ -174,7 +174,7 @@ declare class BedrockChunk extends CommonChunk { networkEncodeSubChunkNoCache(y: number): Promise<Buffer> /** - * + * * @param blobs The blob hashes sent in the SubChunk packet * @param blobStore The Blob Store holding the chunk data * @param payload The remaining data sent in the SubChunk packet, border blocks @@ -198,7 +198,7 @@ declare class BedrockChunk extends CommonChunk { loadHeights(map: Uint16Array): void writeHeightMap(stream): void - // + // // Section management getSection(pos): SubChunk // Returns chunk at a Y index, adjusted for chunks at negative-Y @@ -226,4 +226,4 @@ export const enum BlobType { Biomes = 1, } -export default function loader(mcVersionOrRegistry: string | Registry): typeof PCChunk | typeof BedrockChunk \ No newline at end of file +export default function loader(mcVersionOrRegistry: string | Registry): typeof PCChunk | typeof BedrockChunk From becb25b85f0884e70738dcb8ab1474ce730af86b Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky <vital2580@icloud.com> Date: Fri, 7 Jun 2024 23:22:43 +0300 Subject: [PATCH 3/5] and fix again! --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 03bccf22..6cece3cd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -46,7 +46,7 @@ declare class PCChunk extends CommonChunk { dumpBiomes(): Array<number> dumpLight(): Buffer loadLight(data: Buffer, skyLightMask: number, blockLightMask: number, emptySkyLightMask?: number, emptyBlockLightMask?: number): void - loadParsedLights?(skyLight: Buffer[], blockLight: Buffer[], skyLightMask: number[][], blockLightMask: number[][], emptySkyLightMask: number[][], emptyBlockLightMask: number[][]): void + loadParsedLight?(skyLight: Buffer[], blockLight: Buffer[], skyLightMask: number[][], blockLightMask: number[][], emptySkyLightMask: number[][], emptyBlockLightMask: number[][]): void loadBiomes(newBiomesArray: Array<number>): void; dump(bitMap?: number, skyLightSent?: boolean): Buffer load(data: Buffer, bitMap?: number, skyLightSent?: boolean, fullChunk?: boolean): void From d38c5b3d1d2a48badaa12d3216cf29ddd457fdb3 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky <vital2580@icloud.com> Date: Fri, 7 Jun 2024 23:48:31 +0300 Subject: [PATCH 4/5] fix: dumped buffer must not be empty --- src/pc/1.13/ChunkColumn.js | 4 ++++ src/pc/1.14/ChunkColumn.js | 4 ++++ src/pc/1.15/ChunkColumn.js | 3 +++ src/pc/1.16/ChunkColumn.js | 3 +++ src/pc/1.17/ChunkColumn.js | 3 +++ src/pc/1.18/ChunkColumn.js | 3 +++ src/pc/1.9/ChunkColumn.js | 4 ++++ 7 files changed, 24 insertions(+) diff --git a/src/pc/1.13/ChunkColumn.js b/src/pc/1.13/ChunkColumn.js index 1dd0900c..0172f393 100644 --- a/src/pc/1.13/ChunkColumn.js +++ b/src/pc/1.13/ChunkColumn.js @@ -199,6 +199,10 @@ module.exports = (Block, mcData) => { smartBuffer.writeInt32BE(biome) }) + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } + return smartBuffer.toBuffer() } diff --git a/src/pc/1.14/ChunkColumn.js b/src/pc/1.14/ChunkColumn.js index 60061ff6..bb2fb4ff 100644 --- a/src/pc/1.14/ChunkColumn.js +++ b/src/pc/1.14/ChunkColumn.js @@ -221,6 +221,10 @@ module.exports = (Block, mcData) => { smartBuffer.writeInt32BE(biome) }) + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } + return smartBuffer.toBuffer() } diff --git a/src/pc/1.15/ChunkColumn.js b/src/pc/1.15/ChunkColumn.js index 066b520b..067eb40c 100644 --- a/src/pc/1.15/ChunkColumn.js +++ b/src/pc/1.15/ChunkColumn.js @@ -210,6 +210,9 @@ module.exports = (Block, mcData) => { section.write(smartBuffer) } }) + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } return smartBuffer.toBuffer() } diff --git a/src/pc/1.16/ChunkColumn.js b/src/pc/1.16/ChunkColumn.js index 0bf0f884..e3cb54d0 100644 --- a/src/pc/1.16/ChunkColumn.js +++ b/src/pc/1.16/ChunkColumn.js @@ -210,6 +210,9 @@ module.exports = (Block, mcData) => { section.write(smartBuffer) } }) + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } return smartBuffer.toBuffer() } diff --git a/src/pc/1.17/ChunkColumn.js b/src/pc/1.17/ChunkColumn.js index 8990c674..335b9244 100644 --- a/src/pc/1.17/ChunkColumn.js +++ b/src/pc/1.17/ChunkColumn.js @@ -251,6 +251,9 @@ module.exports = (Block, mcData) => { section.write(smartBuffer) } }) + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } return smartBuffer.toBuffer() } diff --git a/src/pc/1.18/ChunkColumn.js b/src/pc/1.18/ChunkColumn.js index 8413f8e3..6618029c 100644 --- a/src/pc/1.18/ChunkColumn.js +++ b/src/pc/1.18/ChunkColumn.js @@ -233,6 +233,9 @@ module.exports = (Block, mcData) => { this.sections[i].write(smartBuffer) this.biomes[i].write(smartBuffer) } + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } return smartBuffer.toBuffer() } diff --git a/src/pc/1.9/ChunkColumn.js b/src/pc/1.9/ChunkColumn.js index 1de1a3c8..e436186f 100644 --- a/src/pc/1.9/ChunkColumn.js +++ b/src/pc/1.9/ChunkColumn.js @@ -183,6 +183,10 @@ module.exports = (Block, mcData) => { smartBuffer.writeUInt8(biome) }) + if (!smartBuffer.length) { + return Buffer.alloc(4096) + } + return smartBuffer.toBuffer() } From 8884ea0879399838b9f5ae2ddf4cd77c90703b84 Mon Sep 17 00:00:00 2001 From: Vitaly <vital2580@icloud.com> Date: Mon, 10 Jun 2024 18:45:53 +0300 Subject: [PATCH 5/5] 4096->1024 --- src/pc/1.13/ChunkColumn.js | 2 +- src/pc/1.14/ChunkColumn.js | 2 +- src/pc/1.15/ChunkColumn.js | 2 +- src/pc/1.16/ChunkColumn.js | 2 +- src/pc/1.17/ChunkColumn.js | 2 +- src/pc/1.18/ChunkColumn.js | 2 +- src/pc/1.9/ChunkColumn.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pc/1.13/ChunkColumn.js b/src/pc/1.13/ChunkColumn.js index 0172f393..4b1d0366 100644 --- a/src/pc/1.13/ChunkColumn.js +++ b/src/pc/1.13/ChunkColumn.js @@ -200,7 +200,7 @@ module.exports = (Block, mcData) => { }) if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer() diff --git a/src/pc/1.14/ChunkColumn.js b/src/pc/1.14/ChunkColumn.js index bb2fb4ff..ebfeaad7 100644 --- a/src/pc/1.14/ChunkColumn.js +++ b/src/pc/1.14/ChunkColumn.js @@ -222,7 +222,7 @@ module.exports = (Block, mcData) => { }) if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer() diff --git a/src/pc/1.15/ChunkColumn.js b/src/pc/1.15/ChunkColumn.js index 067eb40c..d8cd11eb 100644 --- a/src/pc/1.15/ChunkColumn.js +++ b/src/pc/1.15/ChunkColumn.js @@ -211,7 +211,7 @@ module.exports = (Block, mcData) => { } }) if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer() } diff --git a/src/pc/1.16/ChunkColumn.js b/src/pc/1.16/ChunkColumn.js index e3cb54d0..beb783ed 100644 --- a/src/pc/1.16/ChunkColumn.js +++ b/src/pc/1.16/ChunkColumn.js @@ -211,7 +211,7 @@ module.exports = (Block, mcData) => { } }) if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer() } diff --git a/src/pc/1.17/ChunkColumn.js b/src/pc/1.17/ChunkColumn.js index 335b9244..20ed3bde 100644 --- a/src/pc/1.17/ChunkColumn.js +++ b/src/pc/1.17/ChunkColumn.js @@ -252,7 +252,7 @@ module.exports = (Block, mcData) => { } }) if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer() } diff --git a/src/pc/1.18/ChunkColumn.js b/src/pc/1.18/ChunkColumn.js index 6618029c..5e537e11 100644 --- a/src/pc/1.18/ChunkColumn.js +++ b/src/pc/1.18/ChunkColumn.js @@ -234,7 +234,7 @@ module.exports = (Block, mcData) => { this.biomes[i].write(smartBuffer) } if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer() } diff --git a/src/pc/1.9/ChunkColumn.js b/src/pc/1.9/ChunkColumn.js index e436186f..384dd2ae 100644 --- a/src/pc/1.9/ChunkColumn.js +++ b/src/pc/1.9/ChunkColumn.js @@ -184,7 +184,7 @@ module.exports = (Block, mcData) => { }) if (!smartBuffer.length) { - return Buffer.alloc(4096) + return Buffer.alloc(1024) } return smartBuffer.toBuffer()