From 5ffeb7018615aa4780cdb1e83564e2e17ec32368 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 8 Jul 2022 15:27:37 -0700 Subject: [PATCH] Use getChunkForLighting instead of getChunkAtImmediately in fixlight to properly ignore imposter chunks We need chunks to actually have their light status future done to relight them, an imposter with for example only the empty future complete but with a light status cannot be relit. getChunkForLighting gives the desired behavior and is the method used by the light engine, so updating fixlight to use it as well fixes #8115 --- patches/server/0791-Rewrite-the-light-engine.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/server/0791-Rewrite-the-light-engine.patch b/patches/server/0791-Rewrite-the-light-engine.patch index ec4f865d8..ab6f47251 100644 --- a/patches/server/0791-Rewrite-the-light-engine.patch +++ b/patches/server/0791-Rewrite-the-light-engine.patch @@ -4358,7 +4358,7 @@ index 0000000000000000000000000000000000000000..dd995e25ae620ae36cd5eecb2fe10ad0 + +} diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index a538473f4a75791c7c657f9f1e3ddf96042ab071..a96b3f62a7a6aa5c87976dcda93f4b47bc2cd252 100644 +index a538473f4a75791c7c657f9f1e3ddf96042ab071..86c41f9ad92dc5fb762d56107f58e3acc07d8890 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -709,6 +709,46 @@ public class PaperCommand extends Command { @@ -4374,7 +4374,7 @@ index a538473f4a75791c7c657f9f1e3ddf96042ab071..a96b3f62a7a6aa5c87976dcda93f4b47 + for (java.util.Iterator iterator = chunks.iterator(); iterator.hasNext();) { + final ChunkPos chunkPos = iterator.next(); + -+ final net.minecraft.world.level.chunk.ChunkAccess chunk = world.getChunkSource().getChunkAtImmediately(chunkPos.x, chunkPos.z); ++ final net.minecraft.world.level.chunk.ChunkAccess chunk = (net.minecraft.world.level.chunk.ChunkAccess) world.getChunkSource().getChunkForLighting(chunkPos.x, chunkPos.z); + if (chunk == null || !chunk.isLightCorrect() || !chunk.getStatus().isOrAfter(net.minecraft.world.level.chunk.ChunkStatus.LIGHT)) { + // cannot relight this chunk + iterator.remove(); @@ -4471,7 +4471,7 @@ index 537d34a0325a985948c744929b90144a66a35ee3..06e4d3a02e0d1326b7029157856476db while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 5539f2a7e069cbe98997b734f3b1cd498148f09b..53a4bf5815eb05bf1a4c82c08dd5a51c9ce913b8 100644 +index 5539f2a7e069cbe98997b734f3b1cd498148f09b..b57bffce30154b196b879209c1ce559d0b82456e 100644 --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -23,6 +23,17 @@ import net.minecraft.world.level.chunk.LightChunkGetter; @@ -4536,7 +4536,7 @@ index 5539f2a7e069cbe98997b734f3b1cd498148f09b..53a4bf5815eb05bf1a4c82c08dd5a51c + for (java.util.Iterator iterator = chunks.iterator(); iterator.hasNext();) { + final ChunkPos chunkPos = iterator.next(); + -+ final ChunkAccess chunk = ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().getChunkAtImmediately(chunkPos.x, chunkPos.z); ++ final ChunkAccess chunk = (ChunkAccess)((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().getChunkForLighting(chunkPos.x, chunkPos.z); + if (chunk == null || !chunk.isLightCorrect() || !chunk.getStatus().isOrAfter(ChunkStatus.LIGHT)) { + // cannot relight this chunk + iterator.remove();