From ca164e1c0aa0cf062d613e322b519597ea6887d1 Mon Sep 17 00:00:00 2001 From: Holly Date: Tue, 19 Oct 2021 08:17:18 +0100 Subject: [PATCH] we don't need to floor this it's an integer and we're doing a bit shift on it lmao. --- server/chunkManager.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/chunkManager.js b/server/chunkManager.js index c2fd122..6ce0811 100644 --- a/server/chunkManager.js +++ b/server/chunkManager.js @@ -97,6 +97,14 @@ module.exports = class { this.workPool.add([false, ["generate", cx, cz, null]]); } + chunkExists(cx = 0, cz = 0) { + if (this.chunks[cx] == null) return false; + if (this.chunks[cx][cz] == null) return false; + + // In any other case the chunk exists + return true; + } + multiBlockChunk(chunkX = 0, chunkZ = 0, user) { this.workPool.add([false, ["chunk", [chunkX, chunkZ, this.chunks[chunkX][chunkZ]], user.id, null]]); } @@ -104,8 +112,8 @@ module.exports = class { setBlock(id = 0, x = 0, y = 0, z = 0) { if (y < 0 || y > 127) return console.error("Tried to set a block outside of the world!"); - const chunkX = Math.floor(x >> 4); - const chunkZ = Math.floor(z >> 4); + const chunkX = x >> 4; + const chunkZ = z >> 4; const blockX = x - (16 * chunkX); const blockZ = z - (16 * chunkZ);