From f0a89e99f5140e6408a1e9e27ca857ac61fd1fe1 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Thu, 22 Jul 2021 19:23:31 -0400 Subject: [PATCH] Error Test --- src/main/java/com/volmit/iris/Iris.java | 19 ++++++++ .../framework/EngineCompositeGenerator.java | 48 ++++++++++++++----- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index f205d02ff..9032b0001 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -561,6 +561,25 @@ public class Iris extends VolmitPlugin implements Listener { return IrisSettings.get().getGenerator().isMcaPregenerator(); } + + public static void reportErrorChunk(int x, int z, Throwable e) { + if (IrisSettings.get().getGeneral().isDebug()) { + File f = instance.getDataFile("debug", "chunk-errors", "chunk."+ x + "." + z + ".txt"); + + if (!f.exists()) { + J.attempt(() -> { + PrintWriter pw = new PrintWriter(f); + pw.println("Thread: " + Thread.currentThread().getName()); + pw.println("First: " + new Date(M.ms())); + e.printStackTrace(pw); + pw.close(); + }); + } + + Iris.debug("Chunk " + x + "," + z + " Exception Logged: " + e.getClass().getSimpleName() + ": " + C.RESET + "" + C.LIGHT_PURPLE + e.getMessage()); + } + } + public static synchronized void reportError(Throwable e) { if (IrisSettings.get().getGeneral().isDebug()) { String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber(); diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java b/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java index 677000a5b..c253bd94b 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineCompositeGenerator.java @@ -71,6 +71,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; public class EngineCompositeGenerator extends ChunkGenerator implements IrisAccess { + private static final BlockData ERROR_BLOCK = Material.RED_GLAZED_TERRACOTTA.createBlockData(); private final AtomicReference compound = new AtomicReference<>(); private final AtomicBoolean initialized; private final String dimensionQuery; @@ -448,23 +449,46 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce @NotNull @Override public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) { - PrecisionStopwatch ps = PrecisionStopwatch.start(); - TerrainChunk tc = TerrainChunk.create(world, biome); - IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld(); - generateChunkRawData(ww, x, z, tc).run(); + try + { + PrecisionStopwatch ps = PrecisionStopwatch.start(); + TerrainChunk tc = TerrainChunk.create(world, biome); + IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld(); + generateChunkRawData(ww, x, z, tc).run(); - if (!getComposite().getWorld().hasRealWorld()) { - getComposite().getWorld().bind(world); + if (!getComposite().getWorld().hasRealWorld()) { + getComposite().getWorld().bind(world); + } + + generated++; + ps.end(); + + if (IrisSettings.get().getGeneral().isDebug()) { + Iris.debug("Chunk " + C.GREEN + x + "," + z + C.LIGHT_PURPLE + " in " + C.YELLOW + Form.duration(ps.getMillis(), 2) + C.LIGHT_PURPLE + " Rate: " + C.BLUE + Form.f(getGeneratedPerSecond(), 0) + "/s"); + } + + return tc.getRaw(); } - generated++; - ps.end(); + catch(Throwable e) + { + Iris.error("======================================"); + e.printStackTrace(); + Iris.reportErrorChunk(x, z, e); + Iris.error("======================================"); + + ChunkData d = Bukkit.createChunkData(world); - if (IrisSettings.get().getGeneral().isDebug()) { - Iris.debug("Chunk " + C.GREEN + x + "," + z + C.LIGHT_PURPLE + " in " + C.YELLOW + Form.duration(ps.getMillis(), 2) + C.LIGHT_PURPLE + " Rate: " + C.BLUE + Form.f(getGeneratedPerSecond(), 0) + "/s"); + for(int i = 0; i < 16; i++) + { + for(int j = 0; j < 16; j++) + { + d.setBlock(i, 0, j, ERROR_BLOCK); + } + } + + return d; } - - return tc.getRaw(); } public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator) {