From 797e0b8dd7dae3dd1a62a50919977ad6197cebca Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 28 Sep 2018 22:37:43 -0400 Subject: [PATCH] Remove Water optimization from the Light Optimizations case was found where it could cause light to become incorrect But we still get to optimize out any same block updates which reduces light operations --- .../Optimize-Light-Recalculations.patch | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/Spigot-Server-Patches/Optimize-Light-Recalculations.patch b/Spigot-Server-Patches/Optimize-Light-Recalculations.patch index df2472200f..5c49e9965d 100644 --- a/Spigot-Server-Patches/Optimize-Light-Recalculations.patch +++ b/Spigot-Server-Patches/Optimize-Light-Recalculations.patch @@ -10,38 +10,21 @@ do not impact light calculations. So the only way light should change, is if the block itself changes from 1 block to another. -Additionally, as of 1.13, water now only blocks 1 light level -instead of 3, meaning that light level decreasing is the same as air. - -This means, transitions between water and air also do not need -to recalculate light, which saves a TON of updates caused by -fluids flowing. - diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 53aab97866..dad294ecbe 100644 +index 53aab97866..e4bda70bb9 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - // Keep this synced with entitySlices.add() and entitySlices.remove() - private final int[] itemCounts = new int[16]; - private final int[] inventoryEntityCounts = new int[16]; -+ public static boolean shouldRecheckLight(Block block, Block block1) { -+ return !(block == block1 || (block1 == Blocks.WATER && block == Blocks.AIR) || (block == Blocks.WATER && block1 == Blocks.AIR)); -+ } - // Paper end - public boolean areNeighborsLoaded(final int radius) { - switch (radius) { @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { } else { if (flag1) { this.initLighting(); - } else { -+ } else if (shouldRecheckLight(block, block1)) { // Paper - Optimize light recalculations ++ } 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..cd25bf3d9e 100644 +index 13f69f1b82..763401835d 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc @@ -49,7 +32,7 @@ index 13f69f1b82..cd25bf3d9e 100644 IBlockData iblockdata2 = this.getType(blockposition); - if (iblockdata2.b(this, blockposition) != iblockdata1.b(this, blockposition) || iblockdata2.e() != iblockdata1.e()) { -+ if (Chunk.shouldRecheckLight(iblockdata.getBlock(), iblockdata2.getBlock()) && iblockdata2.b(this, blockposition) != iblockdata1.b(this, blockposition) || iblockdata2.e() != iblockdata1.e()) { // Paper - optimize light recalculations ++ 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();