From bcbf307e8d84332d240c08ba9897620dddc98085 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 16 Jan 2018 13:49:29 +1100 Subject: [PATCH] Don't unlight border chunks --- .../com/boydti/fawe/example/NMSRelighter.java | 28 ++++++++++++++++++- .../boydti/fawe/example/NullRelighter.java | 5 ++++ .../com/boydti/fawe/example/Relighter.java | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java b/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java index cbeb108b..309fd5d7 100644 --- a/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java +++ b/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java @@ -6,6 +6,7 @@ import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.RunnableVal; +import com.boydti.fawe.object.collection.LocalBlockVector2DSet; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -100,6 +101,14 @@ public class NMSRelighter implements Relighter { } } + public synchronized void clear() { + queuedSkyToRelight.clear(); + skyToRelight.clear(); + chunksToSend.clear(); + lightQueue.clear(); + concurrentLightQueue.clear(); + } + public boolean addChunk(int cx, int cz, byte[] fix, int bitmask) { RelightSkyEntry toPut = new RelightSkyEntry(cx, cz, fix, bitmask); queuedSkyToRelight.add(toPut); @@ -380,6 +389,23 @@ public class NMSRelighter implements Relighter { private void fixSkyLighting(List sorted) { RelightSkyEntry[] chunks = sorted.toArray(new RelightSkyEntry[sorted.size()]); + boolean remove = this.removeFirst; + LocalBlockVector2DSet chunkSet = null; + if (remove) { + chunkSet = new LocalBlockVector2DSet(); + LocalBlockVector2DSet tmpSet = new LocalBlockVector2DSet(); + for (RelightSkyEntry chunk : chunks) { + chunkSet.add(chunk.x, chunk.z); + } + for (RelightSkyEntry chunk : chunks) { + int x = chunk.x; + int z = chunk.z; + if (tmpSet.contains(x + 1, z) && tmpSet.contains(x - 1, z) && tmpSet.contains(x, z + 1) && tmpSet.contains(x, z - 1)) { + chunkSet.add(x, z); + } + } + } + byte[] cacheX = FaweCache.CACHE_X[0]; byte[] cacheZ = FaweCache.CACHE_Z[0]; for (int y = FaweChunk.HEIGHT - 1; y > 0; y--) { @@ -401,7 +427,7 @@ public class NMSRelighter implements Relighter { if (section == null) continue; chunk.smooth = false; - if (removeFirst && (y & 15) == 15) { + if (remove && (y & 15) == 15 && chunkSet.contains(chunk.x, chunk.z)) { queue.removeSectionLighting(section, y >> 4, true); } diff --git a/core/src/main/java/com/boydti/fawe/example/NullRelighter.java b/core/src/main/java/com/boydti/fawe/example/NullRelighter.java index 94d62c76..59ced065 100644 --- a/core/src/main/java/com/boydti/fawe/example/NullRelighter.java +++ b/core/src/main/java/com/boydti/fawe/example/NullRelighter.java @@ -22,6 +22,11 @@ public class NullRelighter implements Relighter { } + @Override + public void clear() { + + } + @Override public void removeLighting() { diff --git a/core/src/main/java/com/boydti/fawe/example/Relighter.java b/core/src/main/java/com/boydti/fawe/example/Relighter.java index 901dd4c6..3bdc4fc6 100644 --- a/core/src/main/java/com/boydti/fawe/example/Relighter.java +++ b/core/src/main/java/com/boydti/fawe/example/Relighter.java @@ -12,6 +12,8 @@ public interface Relighter { fixLightingSafe(sky); } + void clear(); + void removeLighting(); void fixBlockLighting();