From 7a852b41ec9f7c2e9a4e09251c45d35a06275b5e Mon Sep 17 00:00:00 2001 From: Bradley Watton Date: Fri, 23 Oct 2020 10:21:42 +0100 Subject: [PATCH] Tested and fully working with Stardust! --- src/Anvil.ts | 9 +++++---- src/Region.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Anvil.ts b/src/Anvil.ts index ed874c3..6855c14 100644 --- a/src/Anvil.ts +++ b/src/Anvil.ts @@ -80,10 +80,11 @@ export class Anvil { private readLocationTable(data: Buffer): LocationTable { const table: LocationTable = [] - for(let i = 0; i < 4096; i += 4) { - const offset = data.readUInt32BE(i) - const sectors = data.readIntBE(i + 3, 1) - const timestamp = data.readIntBE(i + 4096, 4) + for(let i = 0; i < 1024; i++) { + const pos = i * 4 + const offset = data.readUInt32BE(pos) + const sectors = data.readIntBE(pos + 3, 1) + const timestamp = data.readIntBE(pos + 4096, 4) if(offset === 0 || sectors === 0) { table[i] = null diff --git a/src/Region.ts b/src/Region.ts index f205f39..93d2fc7 100644 --- a/src/Region.ts +++ b/src/Region.ts @@ -84,7 +84,7 @@ export class Region { } public hasChunk(x: number, z: number): boolean { - return this.getChunkLocationItem(x, z) !== null + return !!this.getChunkLocationItem(x, z) } }