Async flush AsyncWorld

This commit is contained in:
Jesse Boyd 2017-02-20 11:11:28 +11:00
parent e6dfdf0ecf
commit 01a7c9c388
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 14 additions and 4 deletions

View File

@ -121,9 +121,19 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
}
public void changeWorld(World world, FaweQueue queue) {
flush();
this.parent = world;
if (queue != this.queue) {
if (this.queue != null) {
final FaweQueue oldQueue = this.queue;
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
oldQueue.flush();
}
});
}
this.queue = queue;
}
setParent(queue);
}

View File

@ -196,7 +196,7 @@ public class NMSRelighter implements Relighter{
Map<Integer, Object> currentMap = lightQueue.get(index);
if (currentMap == null) {
currentMap = new Int2ObjectOpenHashMap<>();
synchronized (lightQueue) {
synchronized (this) {
this.lightQueue.put(index, currentMap);
}
}

View File

@ -33,7 +33,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap {
public Reference<FaweChunk> put(long key, Reference<FaweChunk> value) {
if (parent.getProgressTask() != null) {
try {
parent.getProgressTask().run(FaweQueue.ProgressType.QUEUE, size() + 1);
parent.getProgressTask().run(FaweQueue.ProgressType.QUEUE, size());
} catch (Throwable e) {
e.printStackTrace();
}