Readd ignore chunk loads
This commit is contained in:
parent
3760549dda
commit
4d046fc4de
3 changed files with 67 additions and 60 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package org.dynmap.common.chunk;
|
package org.dynmap.common.chunk;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
@ -38,6 +39,7 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
||||||
private int snapcnt;
|
private int snapcnt;
|
||||||
private GenericChunk[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
|
private GenericChunk[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
|
||||||
private boolean[][] isSectionNotEmpty; /* Indexed by snapshot index, then by section index */
|
private boolean[][] isSectionNotEmpty; /* Indexed by snapshot index, then by section index */
|
||||||
|
private AtomicInteger loadingChunks = new AtomicInteger(0); //the amount of threads loading threads at this moment, used by async loading
|
||||||
|
|
||||||
private static final BlockStep unstep[] = { BlockStep.X_MINUS, BlockStep.Y_MINUS, BlockStep.Z_MINUS,
|
private static final BlockStep unstep[] = { BlockStep.X_MINUS, BlockStep.Y_MINUS, BlockStep.Z_MINUS,
|
||||||
BlockStep.X_PLUS, BlockStep.Y_PLUS, BlockStep.Z_PLUS };
|
BlockStep.X_PLUS, BlockStep.Y_PLUS, BlockStep.Z_PLUS };
|
||||||
|
|
@ -928,8 +930,12 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
||||||
chunks = new ArrayList<>();
|
chunks = new ArrayList<>();
|
||||||
iterator.forEachRemaining(chunks::add);
|
iterator.forEachRemaining(chunks::add);
|
||||||
}
|
}
|
||||||
// DynmapCore.setIgnoreChunkLoads(true);
|
//if before increent was 0, means that we are the first, so we need to set this
|
||||||
|
if (loadingChunks.getAndIncrement() == 0) {
|
||||||
|
DynmapCore.setIgnoreChunkLoads(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
List<DynmapChunk> cached = new ArrayList<>();
|
List<DynmapChunk> cached = new ArrayList<>();
|
||||||
List<Map.Entry<Supplier<GenericChunk>, DynmapChunk>> notCached = new ArrayList<>();
|
List<Map.Entry<Supplier<GenericChunk>, DynmapChunk>> notCached = new ArrayList<>();
|
||||||
|
|
||||||
|
|
@ -974,8 +980,6 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// DynmapCore.setIgnoreChunkLoads(false);
|
|
||||||
|
|
||||||
isempty = true;
|
isempty = true;
|
||||||
/* Fill missing chunks with empty dummy chunk */
|
/* Fill missing chunks with empty dummy chunk */
|
||||||
for (int i = 0; i < snaparray.length; i++) {
|
for (int i = 0; i < snaparray.length; i++) {
|
||||||
|
|
@ -985,7 +989,11 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
||||||
isempty = false;
|
isempty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (loadingChunks.decrementAndGet() == 0) {
|
||||||
|
DynmapCore.setIgnoreChunkLoads(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ package org.dynmap.bukkit.helper.v118_2;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.server.level.WorldServer;
|
import net.minecraft.server.level.WorldServer;
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import net.minecraft.world.level.chunk.Chunk;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -51,7 +49,8 @@ public class AsyncChunkProvider118_2 {
|
||||||
return future.thenApply((resultFuture) -> {
|
return future.thenApply((resultFuture) -> {
|
||||||
if (resultFuture == null) return null;
|
if (resultFuture == null) return null;
|
||||||
try {
|
try {
|
||||||
return (NBTTagCompound) resultFuture.getClass().getField("chunkData").get(resultFuture);
|
NBTTagCompound compound = (NBTTagCompound) resultFuture.getClass().getField("chunkData").get(resultFuture);
|
||||||
|
return ifFailed.test(compound) ? null : compound;
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ public class MapChunkCache118_2 extends GenericMapChunkCache {
|
||||||
};
|
};
|
||||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return () -> loadChunk(chunk);
|
||||||
}
|
}
|
||||||
return () -> null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Supplier<GenericChunk> getLoadedChunk(DynmapChunk chunk, boolean async) {
|
private Supplier<GenericChunk> getLoadedChunk(DynmapChunk chunk, boolean async) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue