implement mojang lightning of a1.2.6

This commit is contained in:
LabyStudio
2022-02-01 21:08:09 +01:00
parent 76e7f9fd84
commit 14c13297fb
12 changed files with 458 additions and 158 deletions
@@ -1,6 +1,6 @@
window.BlockRenderer = class {
static CLASSIC_LIGHTNING = false;
static CLASSIC_LIGHTNING = true;
constructor(worldRenderer) {
this.worldRenderer = worldRenderer;
@@ -125,7 +125,7 @@ window.BlockRenderer = class {
if (typeId === 0 || Block.getById(typeId).isTransparent()) {
// Sum up the light levels
totalLightLevel += world.getLightAt(x + offsetX, y + offsetY, z + offsetZ);
totalLightLevel += world.getTotalLightAt(x + offsetX, y + offsetY, z + offsetZ);
totalBlocks++;
}
}
@@ -103,8 +103,7 @@ window.WorldRenderer = class {
renderChunks(cameraChunkX, cameraChunkZ) {
let world = this.minecraft.world;
for (let i in world.chunks) {
let chunk = world.chunks[i];
for (let [index, chunk] of world.chunks) {
let distanceX = Math.abs(cameraChunkX - chunk.x);
let distanceZ = Math.abs(cameraChunkZ - chunk.z);