diff --git a/server/chunkManager.js b/server/chunkManager.js index 60a087d..3864df8 100644 --- a/server/chunkManager.js +++ b/server/chunkManager.js @@ -43,15 +43,14 @@ module.exports = class { break; case "generate": - const startTime = new Date().getTime(); this.chunks[data[2]][data[3]] = data[1]; this.toRemove.push(data[4]); const treeBlocksRef = data[5]; treeBlocksRef.forEach((block) => { - this.setBlock(block[0], block[1], block[2], block[3]); + this.setBlock(block[0], block[1], block[2], block[3], 0, false); }); + this.queuedBlockUpdates.regenerateIterableArray(); this.threadPool[myID][0] = false; - console.log(`Trees fin took ${new Date().getTime() - startTime}ms`); break; } }); @@ -113,7 +112,7 @@ module.exports = class { this.workPool.add([false, ["chunk", [chunkX, chunkZ, this.chunks[chunkX][chunkZ]], user.id, null]]); } - setBlock(x = 0, y = 0, z = 0, id = 0, metadata = 0) { + setBlock(x = 0, y = 0, z = 0, id = 0, metadata = 0, regenerate = true) { if (y < 0 || y > 127) return console.error("Tried to set a block outside of the world!"); const chunkX = x >> 4; @@ -126,6 +125,6 @@ module.exports = class { if (this.chunks[chunkX][chunkZ] != null) if (this.chunks[chunkX][chunkZ][y][blockX][blockZ] == id) return; - this.queuedBlockUpdates.add([chunkX, chunkZ, y, blockX, blockZ, id, metadata]); + this.queuedBlockUpdates.add([chunkX, chunkZ, y, blockX, blockZ, id, metadata], regenerate); } } \ No newline at end of file diff --git a/server/server.js b/server/server.js index 1a83055..cde6cf8 100644 --- a/server/server.js +++ b/server/server.js @@ -90,11 +90,10 @@ module.exports.init = function(config) { for (let i = 0; i < Math.min(global.chunkManager.queuedBlockUpdates.getLength(), 128); i++) { const chunkUpdateKey = global.chunkManager.queuedBlockUpdates.itemKeys[i]; const chunkUpdate = global.chunkManager.queuedBlockUpdates.items[chunkUpdateKey]; - // Don't update if chunk is nonexistant - + // TODO: Remove this once infinite terrain is in :) - if (chunkUpdate[0] < -10 || chunkUpdate[0] > 10 || chunkUpdate[1] < -10 || chunkUpdate[1] > 10) { - itemsToRemove.push(chunkUpdateKey); + if (chunkUpdate[0] < -3 || chunkUpdate[0] > 4 || chunkUpdate[1] < -3 || chunkUpdate[1] > 4) { + itemsToRemove.push(chunkUpdateKey, false); continue; }