Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
better locking of lighting and use correct method for relight without removing first
Fixes #847
Dieser Commit ist enthalten in:
Ursprung
b066ca8349
Commit
97209d5680
@ -71,6 +71,7 @@ public class NMSRelighter implements Relighter {
|
||||
private final int maxY;
|
||||
private final boolean calculateHeightMaps;
|
||||
private final ReentrantLock lightingLock;
|
||||
private final AtomicBoolean finished = new AtomicBoolean(false);
|
||||
private boolean removeFirst;
|
||||
|
||||
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps) {
|
||||
@ -99,6 +100,11 @@ public class NMSRelighter implements Relighter {
|
||||
return lightingLock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return finished.get();
|
||||
}
|
||||
|
||||
@Override public synchronized void removeAndRelight(boolean sky) {
|
||||
removeFirst = true;
|
||||
fixLightingSafe(sky);
|
||||
@ -839,10 +845,12 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
if (Settings.IMP.LIGHTING.ASYNC) {
|
||||
queue.flush();
|
||||
finished.set(true);
|
||||
} else {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override public void run(Object value) {
|
||||
queue.flush();
|
||||
finished.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -873,6 +881,7 @@ public class NMSRelighter implements Relighter {
|
||||
Fawe.imp().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true);
|
||||
iter.remove();
|
||||
}
|
||||
finished.set(true);
|
||||
}
|
||||
};
|
||||
if (Settings.IMP.LIGHTING.ASYNC) {
|
||||
|
@ -53,4 +53,9 @@ public class NullRelighter implements Relighter {
|
||||
public ReentrantLock getLock() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,13 @@ public interface Relighter {
|
||||
|
||||
ReentrantLock getLock();
|
||||
|
||||
/**
|
||||
* Returns true if the Relighter has been flushed
|
||||
*
|
||||
* @return true if finished
|
||||
*/
|
||||
boolean isFinished();
|
||||
|
||||
class SkipReason {
|
||||
public static final byte NONE = 0;
|
||||
public static final byte AIR = 1;
|
||||
|
@ -1098,18 +1098,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
limit.set(originalLimit);
|
||||
try {
|
||||
if (relighter != null && !(relighter instanceof NullRelighter)) {
|
||||
// Only relight once!
|
||||
if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING && !relighter.getLock().tryLock()) {
|
||||
relighter.getLock().lock();
|
||||
relighter.getLock().unlock();
|
||||
} else {
|
||||
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
|
||||
relighter.removeAndRelight(true);
|
||||
} else {
|
||||
relighter.fixSkyLighting();
|
||||
relighter.fixBlockLighting();
|
||||
}
|
||||
if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) {
|
||||
// Don't relight twice!
|
||||
if (!relighter.isFinished() && relighter.getLock().tryLock()) {
|
||||
try {
|
||||
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
|
||||
relighter.removeAndRelight(true);
|
||||
} else {
|
||||
relighter.fixLightingSafe(true);
|
||||
}
|
||||
} finally {
|
||||
relighter.getLock().unlock();
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren