From 9c6cb1796c3aeaf25f331b66fb35359774c12906 Mon Sep 17 00:00:00 2001 From: iam Date: Sun, 28 May 2023 16:32:44 -0400 Subject: [PATCH] More aggressive lighting delay, resend neighbour lighting data after chunk generation (#16) --- .../server/instance/LightingChunk.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/LightingChunk.java b/src/main/java/net/minestom/server/instance/LightingChunk.java index f5409c08c..8ce8bb34e 100644 --- a/src/main/java/net/minestom/server/instance/LightingChunk.java +++ b/src/main/java/net/minestom/server/instance/LightingChunk.java @@ -214,24 +214,24 @@ public class LightingChunk extends DynamicChunk { } } - if (sendingTask == null) { - sendingTask = MinecraftServer.getSchedulerManager().scheduleTask(() -> { - sendingTask = null; + if (sendingTask != null) sendingTask.cancel(); + sendingTask = MinecraftServer.getSchedulerManager().scheduleTask(() -> { + sendingTask = null; - for (LightingChunk f : sendQueue) { - if (f.isLoaded()) { - f.sections.forEach(s -> { - s.blockLight().invalidate(); - s.skyLight().invalidate(); - }); - f.sendLighting(); - sendQueue.remove(f); - } + for (LightingChunk f : sendQueue) { + if (f.isLoaded()) { + f.sections.forEach(s -> { + s.blockLight().invalidate(); + s.skyLight().invalidate(); + }); + sendQueue.remove(f); f.chunkCache.invalidate(); + f.lightCache.invalidate(); + f.sendLighting(); } - }, TaskSchedule.tick(5), TaskSchedule.stop(), ExecutionType.ASYNC); - } + } + }, TaskSchedule.tick(10), TaskSchedule.stop(), ExecutionType.ASYNC); } private static void flushQueue(Instance instance, Set queue, LightType type) { @@ -338,7 +338,7 @@ public class LightingChunk extends DynamicChunk { if (c == null) return; Set collected = collectRequiredNearby(instance, new Vec(chunkX, sectionY, chunkZ)); - // System.out.println("Calculating " + chunkX + " " + sectionY + " " + chunkZ + " | " + collected.size()); + // System.out.println("Calculating " + chunkX + " " + sectionY + " " + chunkZ + " | " + collected.size() + " | " + type); synchronized (instance) { relight(instance, collected, type);