geforkt von Mirrors/FastAsyncWorldEdit
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 int maxY;
|
||||||
private final boolean calculateHeightMaps;
|
private final boolean calculateHeightMaps;
|
||||||
private final ReentrantLock lightingLock;
|
private final ReentrantLock lightingLock;
|
||||||
|
private final AtomicBoolean finished = new AtomicBoolean(false);
|
||||||
private boolean removeFirst;
|
private boolean removeFirst;
|
||||||
|
|
||||||
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps) {
|
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps) {
|
||||||
@ -99,6 +100,11 @@ public class NMSRelighter implements Relighter {
|
|||||||
return lightingLock;
|
return lightingLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return finished.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override public synchronized void removeAndRelight(boolean sky) {
|
@Override public synchronized void removeAndRelight(boolean sky) {
|
||||||
removeFirst = true;
|
removeFirst = true;
|
||||||
fixLightingSafe(sky);
|
fixLightingSafe(sky);
|
||||||
@ -839,10 +845,12 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
if (Settings.IMP.LIGHTING.ASYNC) {
|
if (Settings.IMP.LIGHTING.ASYNC) {
|
||||||
queue.flush();
|
queue.flush();
|
||||||
|
finished.set(true);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
queue.flush();
|
queue.flush();
|
||||||
|
finished.set(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -873,6 +881,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
Fawe.imp().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true);
|
Fawe.imp().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
|
finished.set(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (Settings.IMP.LIGHTING.ASYNC) {
|
if (Settings.IMP.LIGHTING.ASYNC) {
|
||||||
|
@ -53,4 +53,9 @@ public class NullRelighter implements Relighter {
|
|||||||
public ReentrantLock getLock() {
|
public ReentrantLock getLock() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,13 @@ public interface Relighter {
|
|||||||
|
|
||||||
ReentrantLock getLock();
|
ReentrantLock getLock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the Relighter has been flushed
|
||||||
|
*
|
||||||
|
* @return true if finished
|
||||||
|
*/
|
||||||
|
boolean isFinished();
|
||||||
|
|
||||||
class SkipReason {
|
class SkipReason {
|
||||||
public static final byte NONE = 0;
|
public static final byte NONE = 0;
|
||||||
public static final byte AIR = 1;
|
public static final byte AIR = 1;
|
||||||
|
@ -1098,18 +1098,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
limit.set(originalLimit);
|
limit.set(originalLimit);
|
||||||
try {
|
try {
|
||||||
if (relighter != null && !(relighter instanceof NullRelighter)) {
|
if (relighter != null && !(relighter instanceof NullRelighter)) {
|
||||||
// Only relight once!
|
// Don't relight twice!
|
||||||
if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING && !relighter.getLock().tryLock()) {
|
if (!relighter.isFinished() && relighter.getLock().tryLock()) {
|
||||||
relighter.getLock().lock();
|
try {
|
||||||
relighter.getLock().unlock();
|
|
||||||
} else {
|
|
||||||
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
|
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
|
||||||
relighter.removeAndRelight(true);
|
relighter.removeAndRelight(true);
|
||||||
} else {
|
} else {
|
||||||
relighter.fixSkyLighting();
|
relighter.fixLightingSafe(true);
|
||||||
relighter.fixBlockLighting();
|
|
||||||
}
|
}
|
||||||
if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) {
|
} finally {
|
||||||
relighter.getLock().unlock();
|
relighter.getLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren