From 4f23ede23ade4b6f09398c7b12f6044ad88914d7 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 28 Sep 2018 20:46:29 -0400 Subject: [PATCH] Optimize Light Recalculations The server triggers light recalculations even if the new block is the same as the old block. At this time, BlockData Properties do not impact light calculations. So the only way light should change, is if the block itself changes from 1 block to another. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index 53aab97866..e4bda70bb9 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -578,7 +578,7 @@ public class Chunk implements IChunkAccess { } else { if (flag1) { this.initLighting(); - } else { + } else if (block != block1) { // Paper - Optimize light recalculations this.runOrQueueLightUpdate(() -> { // Paper - Queue light update int i1 = iblockdata.b(this.world, blockposition); int j1 = iblockdata1.b(this.world, blockposition); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 13f69f1b82..763401835d 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -444,7 +444,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc } else { IBlockData iblockdata2 = this.getType(blockposition); - if (iblockdata2.b(this, blockposition) != iblockdata1.b(this, blockposition) || iblockdata2.e() != iblockdata1.e()) { + if (iblockdata.getBlock() != iblockdata2.getBlock() && iblockdata2.b(this, blockposition) != iblockdata1.b(this, blockposition) || iblockdata2.e() != iblockdata1.e()) { // Paper - optimize light recalculations this.methodProfiler.a("checkLight"); chunk.runOrQueueLightUpdate(() -> this.r(blockposition)); // Paper - Queue light update this.methodProfiler.e(); -- 2.19.0