mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Performance Improvements Pregenerator
This commit is contained in:
parent
c99c7ee6c9
commit
ecb869695e
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.pregen;
|
package com.volmit.iris.pregen;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.nms.INMS;
|
import com.volmit.iris.nms.INMS;
|
||||||
import com.volmit.iris.scaffold.cache.Cache;
|
import com.volmit.iris.scaffold.cache.Cache;
|
||||||
import com.volmit.iris.scaffold.data.mca.Chunk;
|
import com.volmit.iris.scaffold.data.mca.Chunk;
|
||||||
@ -234,4 +235,21 @@ public class DirectWorldWriter {
|
|||||||
|
|
||||||
return biomeIds;
|
return biomeIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void verify(int mcaox, int mcaoz) {
|
||||||
|
MCAFile file = getMCA(mcaox, mcaoz);
|
||||||
|
|
||||||
|
for(int i = 0; i < 32; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < 32; j++)
|
||||||
|
{
|
||||||
|
Chunk c = file.getChunk(i, j);
|
||||||
|
|
||||||
|
if(c == null)
|
||||||
|
{
|
||||||
|
Iris.warn("Chunk " + ((mcaox << 5) + i) + ", " + ((mcaoz << 5) + j) + " is null in MCA File " + mcaox + ", " + mcaoz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
@ -91,6 +92,7 @@ public class Pregenerator implements Listener {
|
|||||||
private final ChronoLatch latch;
|
private final ChronoLatch latch;
|
||||||
private IrisAccess access;
|
private IrisAccess access;
|
||||||
private final KList<ChunkPosition> regionReload;
|
private final KList<ChunkPosition> regionReload;
|
||||||
|
private KList<ChunkPosition> wait = new KList<>();
|
||||||
|
|
||||||
public Pregenerator(World world, int blockSize, Runnable onComplete) {
|
public Pregenerator(World world, int blockSize, Runnable onComplete) {
|
||||||
this(world, blockSize);
|
this(world, blockSize);
|
||||||
@ -154,8 +156,6 @@ public class Pregenerator implements Listener {
|
|||||||
drawMCA(xx, zz, COLOR_MCA_PREPARE);
|
drawMCA(xx, zz, COLOR_MCA_PREPARE);
|
||||||
if (access != null && generateMCARegion(xx, zz, burst, access, mcaIteration)) {
|
if (access != null && generateMCARegion(xx, zz, burst, access, mcaIteration)) {
|
||||||
flushWorld();
|
flushWorld();
|
||||||
} else {
|
|
||||||
drawMCA(xx, zz, COLOR_MCA_DEFERRED);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -182,6 +182,11 @@ public class Pregenerator implements Listener {
|
|||||||
flushWorld();
|
flushWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(wait.isNotEmpty())
|
||||||
|
{
|
||||||
|
J.sleep(50);
|
||||||
|
}
|
||||||
|
|
||||||
burst.shutdownNow();
|
burst.shutdownNow();
|
||||||
directWriter.flush();
|
directWriter.flush();
|
||||||
flushWorld();
|
flushWorld();
|
||||||
@ -222,6 +227,7 @@ public class Pregenerator implements Listener {
|
|||||||
|
|
||||||
private boolean generateMCARegion(int x, int z, MultiBurst burst, IrisAccess access, Consumer3<Integer, Integer, Consumer2<Integer, Integer>> mcaIteration) {
|
private boolean generateMCARegion(int x, int z, MultiBurst burst, IrisAccess access, Consumer3<Integer, Integer, Consumer2<Integer, Integer>> mcaIteration) {
|
||||||
if (!Iris.instance.isMCA()) {
|
if (!Iris.instance.isMCA()) {
|
||||||
|
generateDeferedMCARegion(x, z, burst, mcaIteration);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,12 +250,9 @@ public class Pregenerator implements Listener {
|
|||||||
}));
|
}));
|
||||||
e.complete();
|
e.complete();
|
||||||
directWriter.flush();
|
directWriter.flush();
|
||||||
if (!install(mcg, mca)) {
|
|
||||||
drawMCA(x, z, COLOR_MCA_DEFERRED);
|
|
||||||
generated.set(generated.get() - 1024);
|
|
||||||
}
|
|
||||||
totalChunks.getAndAdd(1024);
|
totalChunks.getAndAdd(1024);
|
||||||
mcaDefer.add(new ChunkPosition(x, z));
|
mcaDefer.add(new ChunkPosition(x, z));
|
||||||
|
install(mcg, mca);
|
||||||
} else {
|
} else {
|
||||||
totalChunks.getAndAdd(1024);
|
totalChunks.getAndAdd(1024);
|
||||||
mcaDefer.add(new ChunkPosition(x, z));
|
mcaDefer.add(new ChunkPosition(x, z));
|
||||||
@ -289,30 +292,33 @@ public class Pregenerator implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateDeferedMCARegion(int x, int z, MultiBurst burst, Consumer3<Integer, Integer, Consumer2<Integer, Integer>> mcaIteration) {
|
private void generateDeferedMCARegion(int x, int z, MultiBurst burst, Consumer3<Integer, Integer, Consumer2<Integer, Integer>> mcaIteration) {
|
||||||
BurstExecutor e = burst.burst(1024);
|
|
||||||
int mcaox = x << 5;
|
int mcaox = x << 5;
|
||||||
int mcaoz = z << 5;
|
int mcaoz = z << 5;
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
method.set("PaperAsync (Slow)");
|
method.set("PaperAsync (Slow)");
|
||||||
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> e.queue(() -> {
|
|
||||||
try {
|
while(wait.size() > 8192)
|
||||||
CompletableFuture<Chunk> cc = PaperLib.getChunkAtAsync(world, ii, jj);
|
{
|
||||||
|
J.sleep(25);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> {
|
||||||
|
ChunkPosition cx = new ChunkPosition(ii,jj);
|
||||||
|
PaperLib.getChunkAtAsync(world, ii, jj).thenAccept((c) -> {
|
||||||
draw(ii, jj, COLOR_MCA_GENERATE_SLOW_ASYNC);
|
draw(ii, jj, COLOR_MCA_GENERATE_SLOW_ASYNC);
|
||||||
cc.join();
|
|
||||||
draw(ii, jj, COLOR_MCA_GENERATED);
|
draw(ii, jj, COLOR_MCA_GENERATED);
|
||||||
generated.getAndIncrement();
|
generated.getAndIncrement();
|
||||||
vcax.set(ii);
|
vcax.set(ii);
|
||||||
vcaz.set(jj);
|
vcaz.set(jj);
|
||||||
} catch (Throwable ex) {
|
|
||||||
draw(ii, jj, COLOR_ERROR);
|
synchronized (wait)
|
||||||
ChunkPosition pos = new ChunkPosition(ii, jj);
|
{
|
||||||
errors.add(pos);
|
wait.remove(cx);
|
||||||
totalChunks.addAndGet(1024);
|
|
||||||
mcaDefer.add(new ChunkPosition(pos.getX() >> 5, pos.getZ() >> 5));
|
|
||||||
Iris.warn("Hole Detected in Chunk: " + pos.getX() + ", " + pos.getZ() + " (at block " + (pos.getX() << 4) + ", " + lowestBedrock + ", " + (pos.getZ() << 4) + ")");
|
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
e.complete();
|
|
||||||
|
wait.add(cx);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
AtomicInteger m = new AtomicInteger();
|
AtomicInteger m = new AtomicInteger();
|
||||||
method.set("Spigot (Very Slow)");
|
method.set("Spigot (Very Slow)");
|
||||||
@ -322,7 +328,6 @@ public class Pregenerator implements Listener {
|
|||||||
world.getChunkAt(ii, jj).load(true);
|
world.getChunkAt(ii, jj).load(true);
|
||||||
Chunk c = world.getChunkAt(ii, jj);
|
Chunk c = world.getChunkAt(ii, jj);
|
||||||
draw(ii, jj, COLOR_MCA_GENERATED);
|
draw(ii, jj, COLOR_MCA_GENERATED);
|
||||||
checkForError(c);
|
|
||||||
m.getAndIncrement();
|
m.getAndIncrement();
|
||||||
generated.getAndIncrement();
|
generated.getAndIncrement();
|
||||||
vcax.set(ii);
|
vcax.set(ii);
|
||||||
@ -355,19 +360,6 @@ public class Pregenerator implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForError(Chunk c) {
|
|
||||||
if (lowestBedrock >= 0 && lowestBedrock < 256) {
|
|
||||||
if (!c.getBlock(14, lowestBedrock, 14).getType().equals(Material.BEDROCK)) {
|
|
||||||
ChunkPosition pos = new ChunkPosition(c.getX(), c.getZ());
|
|
||||||
errors.add(pos);
|
|
||||||
totalChunks.addAndGet(1024);
|
|
||||||
mcaDefer.add(new ChunkPosition(pos.getX() >> 5, pos.getZ() >> 5));
|
|
||||||
draw(pos.getX(), pos.getZ(), COLOR_ERROR);
|
|
||||||
Iris.warn("Hole Detected in Chunk: " + pos.getX() + ", " + pos.getZ() + " (at block " + (pos.getX() << 4) + ", " + lowestBedrock + ", " + (pos.getZ() << 4) + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private KList<ChunkPosition> computeChunkOrder() {
|
private KList<ChunkPosition> computeChunkOrder() {
|
||||||
ChunkPosition center = new ChunkPosition(15, 15);
|
ChunkPosition center = new ChunkPosition(15, 15);
|
||||||
KList<ChunkPosition> p = new KList<>();
|
KList<ChunkPosition> p = new KList<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user