From b4b6f4a7620b117d071ff2591aecb0970c120342 Mon Sep 17 00:00:00 2001 From: LabyStudio Date: Tue, 1 Feb 2022 12:53:33 +0100 Subject: [PATCH] disable light updates on chunk load --- src/js/net/minecraft/client/Minecraft.js | 2 ++ src/js/net/minecraft/client/world/World.js | 30 ++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/js/net/minecraft/client/Minecraft.js b/src/js/net/minecraft/client/Minecraft.js index b77b144..ece1e13 100644 --- a/src/js/net/minecraft/client/Minecraft.js +++ b/src/js/net/minecraft/client/Minecraft.js @@ -99,6 +99,7 @@ window.Minecraft = class { if (button === 0) { if (hitResult != null) { this.world.setBlockAt(hitResult.x, hitResult.y, hitResult.z, 0); + this.world.updateBlockLightAt(hitResult.x, hitResult.y, hitResult.z); } } @@ -124,6 +125,7 @@ window.Minecraft = class { // Don't place blocks if the player is standing there if (!placedBoundingBox.intersects(this.player.boundingBox)) { this.world.setBlockAt(x, y, z, this.pickedBlock); + this.world.updateBlockLightAt(x, y, z); } } } diff --git a/src/js/net/minecraft/client/world/World.js b/src/js/net/minecraft/client/world/World.js index 4e56469..2ea1a37 100644 --- a/src/js/net/minecraft/client/world/World.js +++ b/src/js/net/minecraft/client/world/World.js @@ -15,22 +15,22 @@ window.World = class { onTick() { // Handle 128 light updates per tick - for (let i = 0; i < 128; i++) { + for (let i = 0; i < 128; i++) { - // Light updates - if (this.lightUpdateQueue.length !== 0) { + // Light updates + if (this.lightUpdateQueue.length !== 0) { - // Get next position to update - let positionIndex = this.lightUpdateQueue.shift(); - if (positionIndex != null) { - let z = positionIndex >> 16; - let x = positionIndex - (z << 16); - this.updateBlockLightsAtXZ(x, z); - } else { - break; - } - } - } + // Get next position to update + let positionIndex = this.lightUpdateQueue.shift(); + if (positionIndex != null) { + let z = positionIndex >> 16; + let x = positionIndex - (z << 16); + this.updateBlockLightsAtXZ(x, z); + } else { + break; + } + } + } } loadChunk(chunk) { @@ -85,8 +85,6 @@ window.World = class { let chunkSection = this.getChunkAtBlock(x, y, z); if (chunkSection != null) { chunkSection.setBlockAt(x & 15, y & 15, z & 15, type); - - this.updateBlockLightAt(x, y, z); } this.onBlockChanged(x, y, z);