Skip to content

Commit f03e16c

Browse files
authored
Properly relight surrounding chunks (#3147)
1 parent 5a148ea commit f03e16c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/StarlightRelighter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,14 @@ protected void fixLighting(LongSet chunks, Runnable andThen) {
118118
public boolean addChunk(int cx, int cz, byte[] skipReason, int bitmask) {
119119
areaLock.lock();
120120
try {
121-
long key = MathMan.pairInt(cx >> CHUNKS_PER_BATCH_SQRT_LOG2, cz >> CHUNKS_PER_BATCH_SQRT_LOG2);
122-
// TODO probably submit here already if chunks.size == CHUNKS_PER_BATCH?
123-
LongSet chunks = this.regions.computeIfAbsent(key, k -> new LongArraySet(CHUNKS_PER_BATCH >> 2));
124-
chunks.add(asLong(cx, cz));
121+
// light can go into neighboring chunks, make sure they are relighted too.
122+
for (int x = cx - 1; x <= cx + 1; x++) {
123+
for (int z = cz - 1; z <= cz + 1; z++) {
124+
long key = MathMan.pairInt(x >> CHUNKS_PER_BATCH_SQRT_LOG2, z >> CHUNKS_PER_BATCH_SQRT_LOG2);
125+
LongSet chunks = this.regions.computeIfAbsent(key, k -> new LongArraySet(CHUNKS_PER_BATCH >> 2));
126+
chunks.add(asLong(x, z));
127+
}
128+
}
125129
} finally {
126130
areaLock.unlock();
127131
}

0 commit comments

Comments
 (0)