Contain failed placements

- Only touch vine faces in getAllowedFaces, so a ceiling vine never asks Bukkit for DOWN
- Add GenerationFailures.skipPlacement: engine failures rethrow, anything else is one warning per 60s per key with a suppressed count
- Count generation sessions, IOException and UncheckedIOException as engine failures
- Contain decorators, water plants, deposits, post and perfection columns, custom blocks, waterlogging fixes and structure pieces at their own scope
- Move object, floating, rotation and surface layer catches to the terse warning
- REPLACE_SOURCE structure failures still fail the chunk
- Add probeFaultSurface to generationOrderProbe for skip determinism runs
This commit is contained in:
Brian Fopiano committed 2026-11-04 02:24:46 -05:00
1 parent 343da05e3d
commit ebe4aa1e41
26 files changed
+583 -233

No files matched your search

@@ -27,7 +27,6 @@ import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.iris.generation.block.B;
import art.arcane.iris.generation.block.BoundBlockState;
@@ -233,8 +232,7 @@ final class IrisBiomeLayerGenerator {
data.add(layer.get(random, layerIndex + offset,
(wx + offset) / zoom, offset, (wz - offset) / zoom, rdata));
} catch (Throwable error) {
GenerationFailures.rethrowEngineFailure(error);
IrisLogging.reportError(error);
GenerationFailures.skipPlacement(error, "surface layer", "block", (int) wx, height - depth, (int) wz, biome.getLoadKey());
}
}
@@ -335,8 +333,7 @@ final class IrisBiomeLayerGenerator {
blocks.add(layer.get(random, layerIndex + offset,
(x + offset) / zoom, offset, (z - offset) / zoom, data));
} catch (Throwable error) {
GenerationFailures.rethrowEngineFailure(error);
IrisLogging.reportError(error);
GenerationFailures.skipPlacement(error, "surface layer", "block", (int) x, -1, (int) z, "none");
}
}
}
@@ -23,7 +23,6 @@ import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.generation.mantle.EngineMantle;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.platform.bukkit.BukkitBlockState;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.iris.generation.block.B;
import art.arcane.volmlib.util.hunk.Hunk;
@@ -50,6 +49,26 @@ final class DecoratorCore {
static final ThreadLocal<PlaceOpts> SCRATCH_OPTS = ThreadLocal.withInitial(PlaceOpts::new);
static void skip(Throwable failure, IrisDecorator decorator, IrisData data, int x, int y, int z, IrisBiome biome) {
GenerationFailures.rethrowEngineFailure(failure);
GenerationFailures.skipPlacement(failure, "decoration", paletteLabel(decorator, data),
x, y, z, biome == null ? "none" : biome.getLoadKey());
}
private static String paletteLabel(IrisDecorator decorator, IrisData data) {
try {
NativeBlockState[] palette = decorator.getBlockDataArray(data);
if (palette.length == 0) {
return "empty palette";
}
String first = palette[0] == null ? "null" : palette[0].key();
return palette.length == 1 ? first : first + " +" + (palette.length - 1);
} catch (Throwable unreadable) {
GenerationFailures.rethrowEngineFailure(unreadable);
return "unreadable palette";
}
}
static final class PlaceOpts {
boolean caveSkipFluid;
boolean underwater;
@@ -91,8 +110,7 @@ final class DecoratorCore {
}
}
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
skip(e, d, data, (int) realX, -1, (int) realZ, biome);
}
}
@@ -158,8 +176,7 @@ final class DecoratorCore {
data.set(x, lowerY, z, lower);
data.set(x, upperY, z, IrisProceduralBlocks.normalizeWaterlogging(upper, data.get(x, upperY, z), true));
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
skip(e, decorator, irisData, realX, lowerY, realZ, null);
}
return;
}
@@ -366,8 +383,7 @@ final class DecoratorCore {
data.set(xf, lowerY, zf, IrisProceduralBlocks.normalizeWaterlogging(lower, data.get(xf, lowerY, zf), true));
data.set(xf, upperY, zf, IrisProceduralBlocks.normalizeWaterlogging(upper, data.get(xf, upperY, zf), true));
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
skip(e, decorator, irisData, realX, lowerY, realZ, null);
}
return;
}
@@ -460,10 +476,8 @@ final class DecoratorCore {
if (keepSupportedSides(data, VINE.equals(IrisProceduralBlocks.materialKey(b)), hunk, rX, rZ, x, y, z, mantle)) {
return BukkitBlockState.of(cloned);
}
for (BlockFace f : Faces.CARTESIAN) {
if (data.hasFace(f)) {
data.setFace(f, false);
}
for (BlockFace f : data.getFaces()) {
data.setFace(f, false);
}
boolean found = false;
@@ -487,7 +501,7 @@ final class DecoratorCore {
boolean ceiling = sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle);
boolean side = false;
for (BlockFace f : Faces.SIDES) {
if (!data.hasFace(f)) {
if (!data.getAllowedFaces().contains(f) || !data.hasFace(f)) {
continue;
}
if (sturdy(f, hunk, rX, rZ, x, y, z, mantle) || vine && (ceiling || vineAboveCarries(f, hunk, rX, rZ, x, y, z, mantle))) {
@@ -502,7 +516,7 @@ final class DecoratorCore {
if (data.getAllowedFaces().contains(BlockFace.UP)) {
data.setFace(BlockFace.UP, ceiling);
}
if (data.hasFace(BlockFace.DOWN) && !sturdy(BlockFace.DOWN, hunk, rX, rZ, x, y, z, mantle)) {
if (data.getAllowedFaces().contains(BlockFace.DOWN) && data.hasFace(BlockFace.DOWN) && !sturdy(BlockFace.DOWN, hunk, rX, rZ, x, y, z, mantle)) {
data.setFace(BlockFace.DOWN, false);
}
return true;
@@ -111,7 +111,12 @@ public final class HydrologyVegetation {
long choice = seed + part.ordinal();
int count = 0;
for (IrisDecorator decorator : bucket) {
if (!decorator.passesChanceGate(partRng, column.x, column.z, column.data)) {
try {
if (!decorator.passesChanceGate(partRng, column.x, column.z, column.data)) {
continue;
}
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, column.data, column.x, column.ground, column.z, null);
continue;
}
count++;
@@ -230,6 +235,14 @@ public final class HydrologyVegetation {
}
private void place(IrisDecorator decorator, RNG rng, int baseY, int room, Slot slot, NativeBlockState support) {
try {
placePicked(decorator, rng, baseY, room, slot, support);
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, data, x, baseY, z, null);
}
}
private void placePicked(IrisDecorator decorator, RNG rng, int baseY, int room, Slot slot, NativeBlockState support) {
NativeBlockState first = decorator.pickBlockData(rng, data, x, z);
if (first == null) {
return;
@@ -53,6 +53,15 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
return;
}
try {
place(decorator, x, z, realX, realZ, data, height, max, caveSkipFluid);
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
}
}
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
int height, int max, boolean caveSkipFluid) {
if (!decorator.isStacking()) {
if (caveSkipFluid) {
NativeBlockState state = data.get(x, height, z);
@@ -48,6 +48,15 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
return;
}
try {
place(decorator, x, z, realX, realZ, data, biome, height, max, limit);
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
}
}
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
IrisBiome biome, int height, int max, int limit) {
if (!decorator.isStacking()) {
if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault()
&& !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) {
@@ -48,6 +48,15 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
return;
}
try {
place(decorator, x, z, realX, realZ, data, biome, height, max, maxBaseY);
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
}
}
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
IrisBiome biome, int height, int max, int maxBaseY) {
if (!decorator.isStacking()) {
int targetY = height + 1;
if (DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
@@ -89,6 +89,15 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
return;
}
try {
placePicked(decorator, x, z, realX, realZ, data, biome, height, max);
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
}
}
private void placePicked(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
IrisBiome biome, int height, int max) {
NativeBlockState support = data.get(x, height, z);
if (support == null || !support.isSolid()) {
return;
@@ -79,6 +79,15 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
return;
}
try {
place(decorator, x, z, realX, realZ, data, height, max, underwater, fluidHeight, caveSkipFluid);
} catch (Throwable e) {
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
}
}
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
int height, int max, boolean underwater, int fluidHeight, boolean caveSkipFluid) {
AquaticPlacementSnapshot aquaticSnapshot = captureAquaticPlacement(
decorator, getData(), data, x, z, height, max);
if (decorator.isStacking()) {
@@ -28,6 +28,7 @@ import art.arcane.iris.configuration.IrisSettings;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.generation.cache.Cache;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.structure.placement.IrisStructureLocator;
import art.arcane.iris.structure.placement.IrisStructureWater;
import art.arcane.iris.structure.placement.PlacedStructurePiece;
@@ -45,6 +46,7 @@ import art.arcane.iris.structure.placement.IrisStructure;
import art.arcane.volmlib.util.structure.StructureCarveShape;
import art.arcane.iris.structure.placement.IrisStructurePlacement;
import art.arcane.iris.structure.placement.IrisStructureStiltSettings;
import art.arcane.iris.structure.nativegen.NativeStructureSuppression;
import art.arcane.iris.structure.placement.IrisStructureTerrain;
import art.arcane.volmlib.util.structure.StructureTerrainMode;
import art.arcane.iris.spi.IrisLogging;
@@ -93,7 +95,14 @@ public class IrisStructureComponent extends IrisMantleComponent {
if (!placement.hasIrisStructures()) {
continue;
}
placeFromPlacement(writer, placement, x, z, placementOrdinal);
try {
placeFromPlacement(writer, placement, x, z, placementOrdinal);
} catch (Throwable e) {
if (placement.getNativeSuppression() == NativeStructureSuppression.REPLACE_SOURCE) {
throw e;
}
GenerationFailures.skipPlacement(e, "structure", String.valueOf(placement.getStructures()), x << 4, -1, z << 4, "none");
}
}
}
@@ -579,9 +588,14 @@ public class IrisStructureComponent extends IrisMantleComponent {
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
}
};
return sampledHeight
? object.place(p.getX(), p.getZ(), writer, config, run.rng(), listener, null, getData())
: object.place(p.getX(), p.getY() - getEngineMantle().getEngine().getMinHeight(), p.getZ(), writer, config, run.rng(), listener, null, getData());
try {
return sampledHeight
? object.place(p.getX(), p.getZ(), writer, config, run.rng(), listener, null, getData())
: object.place(p.getX(), p.getY() - getEngineMantle().getEngine().getMinHeight(), p.getZ(), writer, config, run.rng(), listener, null, getData());
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "structure piece", objectKey, p.getX(), p.getY(), p.getZ(), run.structure().getLoadKey());
return -1;
}
}
static IrisObjectPlacement piecePlacement(IrisStructure structure, PlacedStructurePiece piece, ObjectPlaceMode mode,
@@ -235,8 +235,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
throw failure;
} catch (Throwable e) {
transaction.discard();
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "floating object", obj.getLoadKey(), xx, -1, zz, "floating");
}
}
}
@@ -332,8 +331,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
throw failure;
} catch (Throwable e) {
transaction.discard();
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "floating object", obj.getLoadKey(), wx, yv, wz, "floating");
}
}
}
@@ -446,8 +444,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
throw failure;
} catch (Throwable e) {
transaction.discard();
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "floating object", obj.getLoadKey(), wx, yv, wz, "floating");
}
}
}
@@ -498,12 +498,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
nullObjects += result.nullObjects();
errors += result.errors();
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
GenerationFailures.skipPlacement(e, "object", i.getPlace().toString(", "), x << 4, -1, z << 4, surfaceBiome.getLoadKey());
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place objects in the following biome: " + surfaceBiome.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
}
}
}
@@ -532,12 +528,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
nullObjects += result.nullObjects();
errors += result.errors();
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
GenerationFailures.skipPlacement(e, "object", i.getPlace().toString(", "), x << 4, -1, z << 4, caveBiome.getLoadKey());
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place cave objects in the following biome: " + caveBiome.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
}
}
}
@@ -563,12 +555,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
nullObjects += result.nullObjects();
errors += result.errors();
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
GenerationFailures.skipPlacement(e, "object", i.getPlace().toString(", "), x << 4, -1, z << 4, region.getLoadKey());
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place objects in the following region: " + region.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
}
}
}
@@ -597,12 +585,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
nullObjects += result.nullObjects();
errors += result.errors();
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
GenerationFailures.skipPlacement(e, "object", i.getPlace().toString(", "), x << 4, -1, z << 4, region.getLoadKey());
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Failed to place cave objects in the following region: " + region.getName());
IrisLogging.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
IrisLogging.error("Are these objects missing?");
}
}
}
@@ -806,9 +790,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
+ " commit=" + commitResult);
}
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
IrisLogging.error("Failed to place procedural object '" + p.getName() + "' in " + scope);
GenerationFailures.skipPlacement(e, "procedural object", p.getName(), x << 4, -1, z << 4, scope);
}
}
}
@@ -1053,15 +1035,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
+ " density=" + density);
}
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
GenerationFailures.skipPlacement(e, "object", v.getLoadKey(), chunkX << 4, -1, chunkZ << 4, scope);
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ
+ " scope=" + scope
+ " object=" + v.getLoadKey()
+ " densityIndex=" + i
+ " density=" + density
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage());
}
}
@@ -1259,15 +1234,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
+ " density=" + density);
}
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
GenerationFailures.skipPlacement(e, "cave object", object.getLoadKey(), metricChunkX << 4, y, metricChunkZ << 4, scope);
errors++;
IrisLogging.reportError(e);
IrisLogging.error("Regen cave object placement exception: chunk=" + metricChunkX + "," + metricChunkZ
+ " scope=" + scope
+ " object=" + object.getLoadKey()
+ " densityIndex=" + i
+ " density=" + density
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage());
logCaveReject(
scope,
"EXCEPTION",
@@ -1319,10 +1287,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
try {
placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, complex, forcePlace, traceRegen, "upper-biome-surface");
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
IrisLogging.error("Failed to place upper-dimension objects in biome " + upperBiome.getName()
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")");
GenerationFailures.skipPlacement(e, "upper object", i.getPlace().toString(", "), chunkX << 4, -1, chunkZ << 4, upperBiome.getLoadKey());
}
}
}
@@ -1335,10 +1300,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
try {
placeUpperObject(writer, rng, chunkX, chunkZ, i, upperCtx, complex, forcePlace, traceRegen, "upper-region-surface");
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
IrisLogging.error("Failed to place upper-dimension objects in region " + upperRegion.getName()
+ ": " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")");
GenerationFailures.skipPlacement(e, "upper object", i.getPlace().toString(", "), chunkX << 4, -1, chunkZ << 4, upperRegion.getLoadKey());
}
}
}
@@ -1,14 +1,19 @@
package art.arcane.iris.generation.runtime;
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.world.history.SavedBiomeUnavailableException;
import art.arcane.volmlib.util.mantle.MantleClosedException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UncheckedIOException;
import java.nio.channels.ClosedChannelException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Predicate;
/**
@@ -19,6 +24,10 @@ import java.util.function.Predicate;
*/
public final class GenerationFailures {
private static final int MAXIMUM_CAUSE_DEPTH = 32;
private static final int MAXIMUM_SKIP_KEYS = 512;
private static final String OVERFLOW_SKIP_KEY = "overflow";
static final long SKIP_WARNING_NANOS = 60_000_000_000L;
private static final ConcurrentHashMap<String, SkipWarning> SKIP_WARNINGS = new ConcurrentHashMap<>();
private GenerationFailures() {
}
@@ -28,6 +37,9 @@ public final class GenerationFailures {
|| cause instanceof WrongEngineBroException
|| cause instanceof ProvisionalAnswerException
|| cause instanceof SavedBiomeUnavailableException unavailable && unavailable.isLoading()
|| cause instanceof GenerationSessionException
|| cause instanceof IOException
|| cause instanceof UncheckedIOException
|| cause instanceof TimeoutException);
}
@@ -72,4 +84,61 @@ public final class GenerationFailures {
}
throw new IllegalStateException("Iris generation stopped: " + failure, failure);
}
/**
* Ends one failed placement: an engine failure leaves through {@link #rethrowEngineFailure}, anything else is one
* rate-limited warning and the caller moves on. The warning state only decides what is logged, never what is
* placed, so a skip gives the same blocks in any chunk order.
*/
public static void skipPlacement(Throwable failure, String kind, String block, int x, int y, int z, String biome) {
rethrowEngineFailure(failure);
String key = kind + '|' + block + '|' + failure.getClass().getName();
long suppressed = claimSkipWarning(key, System.nanoTime());
if (suppressed >= 0L) {
IrisLogging.warn(skipWarning(kind, block, x, y, z, biome, failure, suppressed));
}
}
static long claimSkipWarning(String key, long now) {
SkipWarning warning = SKIP_WARNINGS.get(key);
if (warning == null) {
String resolved = SKIP_WARNINGS.size() >= MAXIMUM_SKIP_KEYS ? OVERFLOW_SKIP_KEY : key;
warning = SKIP_WARNINGS.computeIfAbsent(resolved, ignored -> new SkipWarning(now - SKIP_WARNING_NANOS));
}
return warning.claim(now);
}
static String skipWarning(String kind, String block, int x, int y, int z, String biome, Throwable failure, long suppressed) {
String message = failure.getMessage() == null ? "" : ": " + failure.getMessage().replaceAll("\\s+", " ");
StringBuilder line = new StringBuilder("Skipped ").append(kind).append(' ').append(block)
.append(" at ").append(x).append(',').append(y).append(',').append(z)
.append(" biome ").append(biome).append(": ").append(failure.getClass().getSimpleName()).append(message);
StackTraceElement[] frames = failure.getStackTrace();
if (frames.length > 0) {
String file = frames[0].getFileName() == null ? frames[0].getClassName() : frames[0].getFileName().replace(".java", "");
line.append(" (").append(file).append(':').append(frames[0].getLineNumber()).append(')');
}
if (suppressed > 0L) {
line.append(", ").append(suppressed).append(" more");
}
return line.toString();
}
private static final class SkipWarning {
private final AtomicLong last;
private final AtomicLong suppressed = new AtomicLong();
private SkipWarning(long start) {
last = new AtomicLong(start);
}
private long claim(long now) {
long previous = last.get();
if (now - previous >= SKIP_WARNING_NANOS && last.compareAndSet(previous, now)) {
return suppressed.getAndSet(0L);
}
suppressed.incrementAndGet();
return -1L;
}
}
}
@@ -24,6 +24,7 @@ import art.arcane.iris.generation.subterrain.SubterrainPlanner;
import art.arcane.iris.generation.subterrain.SubterrainRasterizer;
import art.arcane.iris.generation.subterrain.SubterrainSurfaceMaterials;
import art.arcane.iris.generation.runtime.DimensionStackContext;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.runtime.DimensionStackLayout;
import art.arcane.iris.generation.runtime.UpperDimensionContext;
import art.arcane.iris.generation.terrain.Terrain3DColumn;
@@ -1173,14 +1174,18 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
NativeBlockState columnFluid = hydrology.isWet()
? getComplex().resolveCaveCellFluid(hydrology.fluidProfileKey(), worldX, worldZ)
: null;
NativeBlockState normalized = normalizeHydrologyWaterlogging(
current,
baseline,
hydrology,
columnFluid
);
if (normalized != current) {
output.setRaw(localX, y, localZ, normalized);
try {
NativeBlockState normalized = normalizeHydrologyWaterlogging(
current,
baseline,
hydrology,
columnFluid
);
if (normalized != current) {
output.setRaw(localX, y, localZ, normalized);
}
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "waterlogging", current == null ? "null" : current.key(), worldX, y, worldZ, "none");
}
}
}
@@ -2,6 +2,7 @@ package art.arcane.iris.generation.stage;
import art.arcane.iris.integration.Identifier;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.runtime.EngineAssignedModifier;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.iris.generation.concurrent.BurstExecutor;
@@ -39,16 +40,20 @@ public class IrisCustomModifier extends EngineAssignedModifier<NativeBlockState>
if (b == null || !b.isCustom()) {
continue;
}
String placementKey = b.deferredPlacementKey();
NativeBlockState baseState = b.placementBaseState();
if (placementKey == null || baseState == null) {
continue;
}
try {
String placementKey = b.deferredPlacementKey();
NativeBlockState baseState = b.placementBaseState();
if (placementKey == null || baseState == null) {
continue;
}
mc.getOrCreate(finalY >> 4)
.slice(Identifier.class)
.set(rX, finalY & 15, rZ, Identifier.fromString(placementKey));
output.set(rX, finalY, rZ, baseState);
mc.getOrCreate(finalY >> 4)
.slice(Identifier.class)
.set(rX, finalY & 15, rZ, Identifier.fromString(placementKey));
output.set(rX, finalY, rZ, baseState);
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "custom block", b.key(), x + rX, finalY, z + rZ, "none");
}
}
}
});
@@ -19,6 +19,7 @@
package art.arcane.iris.generation.stage;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.runtime.IrisEngine;
import art.arcane.iris.generation.runtime.EngineAssignedModifier;
import art.arcane.iris.generation.runtime.DimensionStackLayout;
@@ -101,14 +102,18 @@ public class IrisDepositModifier extends EngineAssignedModifier<NativeBlockState
AboveTerrainHosts aboveTerrainHosts = new AboveTerrainHosts(terrain, context);
int attempts = 0;
for (int i = 0; i < generators.size(); i++) {
DepositPlan plan = plan(generators.get(i), rng.nextParallelRNG(seed * (i + 1L)), context);
if (plan.attempts() == 0 || footprintsMissTerrain(plan, highestSurface)
|| plan.generator().getPlacementScope() == IrisDepositPlacementScope.ABOVE_TERRAIN
&& !aboveTerrainHosts.present(plan.generator().getSurfaceClearance())) {
continue;
try {
DepositPlan plan = plan(generators.get(i), rng.nextParallelRNG(seed * (i + 1L)), context);
if (plan.attempts() == 0 || footprintsMissTerrain(plan, highestSurface)
|| plan.generator().getPlacementScope() == IrisDepositPlacementScope.ABOVE_TERRAIN
&& !aboveTerrainHosts.present(plan.generator().getSurfaceClearance())) {
continue;
}
plans.add(plan);
attempts += plan.attempts();
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "deposit", String.valueOf(generators.get(i).getPalette()), x << 4, -1, z << 4, "none");
}
plans.add(plan);
attempts += plan.attempts();
}
if (attempts == 0) {
return;
@@ -271,104 +276,118 @@ public class IrisDepositModifier extends EngineAssignedModifier<NativeBlockState
boolean needsCaveBiome = scalable || k.usesCaveBiomeFilter();
IrisDimensionCarvingResolver.State carvingState = needsCaveBiome ? new IrisDimensionCarvingResolver.State() : null;
boolean terrainScoped = k.getPlacementScope() == IrisDepositPlacementScope.TERRAIN;
int highest = highestSurface;
int engineHeight = getEngine().getHeight();
List<PreparedClump> clumps = new ArrayList<>(limit - first);
for (int l = first; l < limit; l++) {
DepositRandom clumpRng = new DepositRandom(clumpSeed(plan.seed(), l));
if (k.getPerClumpSpawnChance() < clumpRng.d()) {
continue;
}
IrisDepositGenerator.ClumpFootprint footprint = k.sampleClumpFootprint(clumpRng, getData());
if (footprint != null && footprint.empty() && !scalable) {
continue;
}
IrisObject clump = footprint == null ? k.getClump(getEngine(), clumpRng, getData()) : null;
int dim = footprint == null ? clump.getW() : footprint.width();
int min = dim / 2;
int max = (int) (16D - dim / 2D);
if (min > max || min < 0 || max > 15) {
min = 6;
max = 9;
}
int x = clumpRng.i(min, max + 1);
int z = clumpRng.i(min, max + 1);
int terrainSurface = getDepositTerrainSurface(cx, cz, x, z, he, context);
int height = terrainScoped
? depositSurfaceLimit(terrainSurface, k.getSurfaceClearance())
: engineHeight - 1;
if (height < 0) {
continue;
}
int y = sampleHeight(
k.getHeightDistribution(), clumpRng, k.getMinHeight(), k.getMaxHeight(),
Math.min(height, engineHeight - 1));
if (y == Integer.MIN_VALUE) {
continue;
}
boolean clippedHeight = k.getHeightDistribution() == IrisDepositHeightDistribution.CLIPPED_UNIFORM;
if (clippedHeight && y > height - 2) {
continue;
}
boolean footprintLimited = footprint != null && terrainScoped && !footprint.empty();
if (footprintLimited && highest == Integer.MIN_VALUE) {
highest = highestTerrainSurface(cx, cz, he, context);
}
int terrainLimit = highest - Math.max(0, k.getSurfaceClearance());
if (footprintLimited && !scalable && y + footprint.minY() > terrainLimit) {
continue;
}
int biomeY = Math.max(0, Math.min(engineHeight - 1, y));
IrisBiome surfaceBiome = context.getBiome().get(x, z);
IrisBiome depositBiome = needsCaveBiome
? getEngine().getCaveBiome(
(cx << 4) + x, biomeY, (cz << 4) + z, carvingState)
: null;
if (!k.matchesBiome(surfaceBiome, depositBiome)) {
continue;
}
if (oreDeposit && depositBiome != null) {
double frequencyMultiplier = depositBiome.getOreDepositFrequencyMultiplier();
if (frequencyMultiplier < 1D
&& !passesOreFrequency(frequencyMultiplier, clumpRng.d())) {
continue;
}
double sizeMultiplier = depositBiome.getOreDepositSizeMultiplier();
if (sizeMultiplier != 1D) {
IrisObject scaledClump = k.getClump(getEngine(), clumpRng, getData(), sizeMultiplier);
int scaledDimension = scaledClump.getW();
x = clampDepositCenter(x, scaledDimension, 16);
if (clippedHeight) {
y = clampDepositCenter(y, scaledDimension, engineHeight);
}
z = clampDepositCenter(z, scaledDimension, 16);
clump = scaledClump;
try {
PreparedClump prepared = prepareClump(k, plan, l, oreDeposit, scalable, needsCaveBiome, carvingState,
terrainScoped, engineHeight, cx, cz, he, context, highestSurface);
if (prepared != null) {
clumps.add(prepared);
}
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "deposit", String.valueOf(k.getPalette()), (cx << 4) + 8, -1, (cz << 4) + 8, "none");
}
if (clump != null) {
clumps.add(new PreparedClump(clump, null, x, y, z, clumpRng));
continue;
}
if (footprint.empty() || footprintLimited && y + footprint.minY() > terrainLimit) {
continue;
}
clumps.add(new PreparedClump(null, footprint.cells(), x, y, z, clumpRng));
}
return new PreparedDeposit(k, oreDeposit, clumps);
}
private PreparedClump prepareClump(IrisDepositGenerator k, DepositPlan plan, int l, boolean oreDeposit, boolean scalable,
boolean needsCaveBiome, IrisDimensionCarvingResolver.State carvingState,
boolean terrainScoped, int engineHeight, int cx, int cz, HeightMap he,
ChunkContext context, int highestSurface) {
int highest = highestSurface;
DepositRandom clumpRng = new DepositRandom(clumpSeed(plan.seed(), l));
if (k.getPerClumpSpawnChance() < clumpRng.d()) {
return null;
}
IrisDepositGenerator.ClumpFootprint footprint = k.sampleClumpFootprint(clumpRng, getData());
if (footprint != null && footprint.empty() && !scalable) {
return null;
}
IrisObject clump = footprint == null ? k.getClump(getEngine(), clumpRng, getData()) : null;
int dim = footprint == null ? clump.getW() : footprint.width();
int min = dim / 2;
int max = (int) (16D - dim / 2D);
if (min > max || min < 0 || max > 15) {
min = 6;
max = 9;
}
int x = clumpRng.i(min, max + 1);
int z = clumpRng.i(min, max + 1);
int terrainSurface = getDepositTerrainSurface(cx, cz, x, z, he, context);
int height = terrainScoped
? depositSurfaceLimit(terrainSurface, k.getSurfaceClearance())
: engineHeight - 1;
if (height < 0) {
return null;
}
int y = sampleHeight(
k.getHeightDistribution(), clumpRng, k.getMinHeight(), k.getMaxHeight(),
Math.min(height, engineHeight - 1));
if (y == Integer.MIN_VALUE) {
return null;
}
boolean clippedHeight = k.getHeightDistribution() == IrisDepositHeightDistribution.CLIPPED_UNIFORM;
if (clippedHeight && y > height - 2) {
return null;
}
boolean footprintLimited = footprint != null && terrainScoped && !footprint.empty();
if (footprintLimited && highest == Integer.MIN_VALUE) {
highest = highestTerrainSurface(cx, cz, he, context);
}
int terrainLimit = highest - Math.max(0, k.getSurfaceClearance());
if (footprintLimited && !scalable && y + footprint.minY() > terrainLimit) {
return null;
}
int biomeY = Math.max(0, Math.min(engineHeight - 1, y));
IrisBiome surfaceBiome = context.getBiome().get(x, z);
IrisBiome depositBiome = needsCaveBiome
? getEngine().getCaveBiome(
(cx << 4) + x, biomeY, (cz << 4) + z, carvingState)
: null;
if (!k.matchesBiome(surfaceBiome, depositBiome)) {
return null;
}
if (oreDeposit && depositBiome != null) {
double frequencyMultiplier = depositBiome.getOreDepositFrequencyMultiplier();
if (frequencyMultiplier < 1D
&& !passesOreFrequency(frequencyMultiplier, clumpRng.d())) {
return null;
}
double sizeMultiplier = depositBiome.getOreDepositSizeMultiplier();
if (sizeMultiplier != 1D) {
IrisObject scaledClump = k.getClump(getEngine(), clumpRng, getData(), sizeMultiplier);
int scaledDimension = scaledClump.getW();
x = clampDepositCenter(x, scaledDimension, 16);
if (clippedHeight) {
y = clampDepositCenter(y, scaledDimension, engineHeight);
}
z = clampDepositCenter(z, scaledDimension, 16);
clump = scaledClump;
}
}
if (clump != null) {
return new PreparedClump(clump, null, x, y, z, clumpRng);
}
if (footprint.empty() || footprintLimited && y + footprint.minY() > terrainLimit) {
return null;
}
return new PreparedClump(null, footprint.cells(), x, y, z, clumpRng);
}
private void place(PreparedDeposit deposit, MantleChunk chunk, Hunk<NativeBlockState> data,
int cx, int cz, HeightMap he, ChunkContext context) {
if (deposit.clumps().isEmpty()) {
@@ -381,17 +400,21 @@ public class IrisDepositModifier extends EngineAssignedModifier<NativeBlockState
int y = prepared.y();
int z = prepared.z();
RNG rng = prepared.rng();
IrisDepositGenerator.ClumpCells cells = prepared.cells();
if (cells != null) {
for (int cell = 0; cell < cells.size(); cell++) {
placement.place(cells.x(cell) + x, cells.y(cell) + y, cells.z(cell) + z, cells.block(cell), rng);
try {
IrisDepositGenerator.ClumpCells cells = prepared.cells();
if (cells != null) {
for (int cell = 0; cell < cells.size(); cell++) {
placement.place(cells.x(cell) + x, cells.y(cell) + y, cells.z(cell) + z, cells.block(cell), rng);
}
continue;
}
continue;
}
VectorMap<NativeBlockState>.Cursor cursor = prepared.object().getBlocks().cursor();
while (cursor.next()) {
IrisBlockVector j = cursor.key();
placement.place(j.getBlockX() + x, j.getBlockY() + y, j.getBlockZ() + z, cursor.value(), rng);
VectorMap<NativeBlockState>.Cursor cursor = prepared.object().getBlocks().cursor();
while (cursor.next()) {
IrisBlockVector j = cursor.key();
placement.place(j.getBlockX() + x, j.getBlockY() + y, j.getBlockZ() + z, cursor.value(), rng);
}
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "deposit", String.valueOf(deposit.generator().getPalette()), (cx << 4) + x, y, (cz << 4) + z, "none");
}
}
}
@@ -39,7 +39,6 @@ import art.arcane.iris.generation.decoration.IrisDecorationPart;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.generation.biome.IrisFloatingChildBiomes;
import art.arcane.iris.generation.terrain.IrisSlopeClip;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.generation.block.B;
import art.arcane.iris.generation.context.ChunkContext;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
@@ -104,8 +103,7 @@ public class IrisFloatingChildBiomeModifier extends EngineAssignedModifier<Nativ
try {
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.getZoom(), j, (wz - j) / layer.getZoom(), data));
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "surface layer", "block", (int) wx, -1, (int) wz, "floating");
}
}
@@ -364,8 +362,7 @@ public class IrisFloatingChildBiomeModifier extends EngineAssignedModifier<Nativ
RNG colRng = rng.nextParallelRNG((int) FloatingIslandSample.columnSeed(baseSeed, wx, wz));
FloatingDecorator.decorateColumn(getEngine(), target, IrisDecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS);
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "floating decoration", "column", wx, topY, wz, target.getLoadKey());
}
}
}
@@ -399,8 +396,7 @@ public class IrisFloatingChildBiomeModifier extends EngineAssignedModifier<Nativ
try {
seaSurfaceDecorator.decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, output, target, fluidTopY, chunkHeight);
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "floating decoration", "sea surface", wx, fluidTopY, wz, target.getLoadKey());
}
}
}
@@ -464,8 +460,7 @@ public class IrisFloatingChildBiomeModifier extends EngineAssignedModifier<Nativ
context.floatingBiomes(chunkHeight).record(wx & 15, y, wz & 15, matter.identity());
}
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "floating sky biome", "column", wx, sample.topY(), wz, parent.getLoadKey());
}
}
@@ -22,6 +22,7 @@ import art.arcane.iris.generation.chunk.ColumnExtent;
import art.arcane.iris.generation.chunk.ColumnReadHunk;
import art.arcane.iris.generation.decoration.IrisSpeleothems;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.runtime.EngineAssignedModifier;
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
import art.arcane.iris.generation.block.BoundBlockState;
@@ -94,14 +95,14 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<NativeBlockSt
BurstExecutor burst = burst().burst(multicore);
for (int task = 0; task < tasks; task++) {
int firstSlice = task * slicesPerTask;
burst.queue(() -> perfectSlices(output, firstSlice, firstSlice + slicesPerTask));
burst.queue(() -> perfectSlices(output, firstSlice, firstSlice + slicesPerTask, x, z));
}
burst.complete();
getEngine().getMetrics().getPerfection().put(p.getMilliseconds());
}
private void perfectSlices(Hunk<NativeBlockState> output, int firstSlice, int lastSlice) {
private void perfectSlices(Hunk<NativeBlockState> output, int firstSlice, int lastSlice, int originX, int originZ) {
IntArrayList surfaces = new IntArrayList();
StateFlags states = new StateFlags();
NativeBlockState air = AIR.get();
@@ -109,7 +110,11 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<NativeBlockSt
NativeBlockState[] column = new NativeBlockState[output.getHeight()];
for (int x = firstSlice; x < lastSlice; x++) {
for (int z = 0; z < 16; z++) {
perfectColumn(output, x, z, surfaces, states, air, water, column);
try {
perfectColumn(output, x, z, surfaces, states, air, water, column);
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "perfection", "column", originX + x, -1, originZ + z, "none");
}
}
}
}
@@ -20,6 +20,7 @@ package art.arcane.iris.generation.stage;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.EngineAssignedModifier;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.mantle.EngineMantle;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.terrain.IrisDimension;
@@ -62,7 +63,11 @@ public class IrisPostModifier extends EngineAssignedModifier<NativeBlockState> {
boolean slabs = dimension.isPostProcessingSlabs();
for (int i = 0; i < width; i++) {
for (int j = 0; j < depth; j++) {
post(i, j, sync, i + x, j + z, context, heights, rivers, planeWidth, walls, slabs);
try {
post(i, j, sync, i + x, j + z, context, heights, rivers, planeWidth, walls, slabs);
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "post", "column", i + x, -1, j + z, "none");
}
}
}
@@ -26,7 +26,6 @@ import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.Snippet;
import art.arcane.iris.pack.validation.MissingBlockState;
import art.arcane.iris.platform.bukkit.BukkitBlockState;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.iris.generation.block.IrisCustomData;
import art.arcane.iris.generation.geometry.IrisBlockVector;
@@ -443,9 +442,7 @@ public class IrisObjectRotation {
}
}
} catch (Throwable e) {
GenerationFailures.rethrowEngineFailure(e);
IrisLogging.reportError(e);
GenerationFailures.skipPlacement(e, "block rotation", String.valueOf(dd), spinxx, spinyy, spinzz, "none");
}
return d;
@@ -2,14 +2,12 @@ package art.arcane.iris.generation.biome;
import art.arcane.iris.generation.noise.NoiseStyle;
import art.arcane.iris.generation.terrain.IrisSlopeClip;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.noise.CNG;
import art.arcane.volmlib.util.stream.ProceduralStream;
import org.junit.Test;
import org.mockito.MockedStatic;
import java.util.List;
@@ -21,7 +19,6 @@ import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -152,16 +149,13 @@ public class IrisBiomeLockedLayerTest {
}
@Test
public void sampledPaletteFailuresAreReported() {
public void sampledPaletteFailuresAreSkipped() {
IrisBiomePaletteLayer layer = spy(palette(1, 1, 1D, mock(NativeBlockState.class)));
IrisBiome biome = new IrisBiome().setLockLayers(true).setLayers(new KList<>(layer));
RNG rng = new RNG(37L);
IllegalStateException failure = new IllegalStateException("Palette unavailable");
doThrow(failure).when(layer).get(same(rng), anyInt(), anyDouble(), anyDouble(), anyDouble(), isNull());
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
assertTrue(biome.generateLockedLayers(0D, 0D, rng, 7, 64, null, null).isEmpty());
logging.verify(() -> IrisLogging.reportError(failure));
}
assertTrue(biome.generateLockedLayers(0D, 0D, rng, 7, 64, null, null).isEmpty());
}
private static IrisBiomePaletteLayer palette(int minimum, int maximum, double zoom, NativeBlockState... blocks) {
@@ -0,0 +1,135 @@
package art.arcane.iris.generation.decoration;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.mantle.EngineMantle;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.GenerationClosedException;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.runtime.SeedManager;
import art.arcane.iris.generation.terrain.InferredType;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformRegistries;
import art.arcane.iris.testsupport.PlatformLeakGuard;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.util.hunk.Hunk;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import java.util.function.Function;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public class DecorationFailureContainmentTest {
private static final int FAILING_X = 3;
@ClassRule
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
@BeforeClass
public static void bindPlatform() {
IrisPlatforms.unbind();
NativeBlockState air = mock(NativeBlockState.class);
doReturn(true).when(air).isAir();
doReturn("minecraft:air").when(air).key();
PlatformRegistries registries = mock(PlatformRegistries.class);
doReturn(air).when(registries).block(anyString());
doReturn(air).when(registries).air();
IrisPlatform platform = mock(IrisPlatform.class);
doReturn(registries).when(platform).registries();
IrisPlatforms.bind(platform);
}
@AfterClass
public static void unbindPlatform() {
IrisPlatforms.unbind();
}
@Test
public void badBlockFaceSkipsOnlyThatColumnAndTheRestOfTheChunkDecorates() {
Hunk<NativeBlockState> first = decorateRow(x -> new IllegalArgumentException("Invalid blockFace"), false);
Hunk<NativeBlockState> second = decorateRow(x -> new IllegalArgumentException("Invalid blockFace"), true);
for (int x = 0; x < 16; x++) {
assertEquals(key(first.get(x, 9, 0)), key(second.get(x, 9, 0)));
if (x == FAILING_X) {
assertNull(first.get(x, 9, 0));
} else {
assertEquals("minecraft:vine", first.get(x, 9, 0).key());
}
}
}
@Test
public void engineFailureStillEscapesTheDecorator() {
assertThrows(GenerationClosedException.class,
() -> decorateRow(x -> new GenerationClosedException("router closed"), false));
}
private static String key(NativeBlockState state) {
return state == null ? null : state.key();
}
private static Hunk<NativeBlockState> decorateRow(Function<Integer, RuntimeException> failure, boolean reverse) {
NativeBlockState vine = mock(NativeBlockState.class);
doReturn(true).when(vine).isVineBlock();
doReturn("minecraft:vine").when(vine).key();
doReturn("minecraft:vine").when(vine).materialKey();
IrisDecorator decorator = mock(IrisDecorator.class);
doReturn(true).when(decorator).passesChanceGate(any(), anyDouble(), anyDouble(), any());
doReturn(true).when(decorator).isForcePlace();
doReturn(vine).when(decorator).pickBlockData(any(), any(), anyDouble(), anyDouble());
doReturn(new NativeBlockState[]{vine}).when(decorator).getBlockDataArray(any());
IrisBiome biome = mock(IrisBiome.class);
doReturn("test/biome").when(biome).getLoadKey();
doReturn(InferredType.CAVE).when(biome).getInferredType();
doReturn(new IrisDecorator[]{decorator}).when(biome).getDecoratorBucket(IrisDecorationPart.CEILING);
Hunk<NativeBlockState> output = Hunk.newArrayHunk(16, 32, 16);
DecoratorPlatformHooks.Bindings previous = DecoratorPlatformHooks.bind((state, hunk, rX, rZ, x, y, z, mantle) -> {
if (x == FAILING_X) {
throw failure.apply(x);
}
return state;
}, (surface, upward) -> true);
try {
IrisCeilingDecorator ceiling = new IrisCeilingDecorator(engine());
for (int i = 0; i < 16; i++) {
int x = reverse ? 15 - i : i;
ceiling.decorate(x, 0, x, x, x, 0, 0, 0, output, biome, InferredType.CAVE, 9, 4);
}
} finally {
DecoratorPlatformHooks.restore(previous);
}
return output;
}
private static Engine engine() {
Engine engine = mock(Engine.class);
doReturn(mock(SeedManager.class)).when(engine).getSeedManager();
doReturn(mock(IrisData.class)).when(engine).getData();
IrisDimension dimension = mock(IrisDimension.class);
doReturn(63).when(dimension).getFluidHeight();
doReturn(dimension).when(engine).getDimension();
doReturn(mock(IrisComplex.class)).when(engine).getComplex();
EngineMantle mantle = mock(EngineMantle.class);
doReturn(63).when(mantle).getFluidHeight(anyInt(), anyInt());
doReturn(engine).when(mantle).getEngine();
doReturn(mantle).when(engine).getMantle();
return engine;
}
}
@@ -838,6 +838,19 @@ public class DecoratorCoreTest {
faces(DecoratorCore.fixFacesForHunk(vine, output, 8, 8, 8, 3, 8, null)));
}
@Test
public void ceilingVineNeverAsksForAFaceItDoesNotAllow() {
NativeBlockState lone = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.UP));
Hunk<NativeBlockState> ceiling = Hunk.newArrayHunk(16, 8, 16);
ceiling.set(8, 4, 8, sturdyState());
assertEquals(EnumSet.of(BlockFace.UP), faces(DecoratorCore.fixFacesForHunk(lone, ceiling, 8, 8, 8, 3, 8, null)));
NativeBlockState sided = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH));
ceiling.set(8, 3, 7, sturdyState());
assertEquals(EnumSet.of(BlockFace.NORTH, BlockFace.UP),
faces(DecoratorCore.fixFacesForHunk(sided, ceiling, 8, 8, 8, 3, 8, null)));
}
private NativeBlockState facingState(String material, Set<BlockFace> allowed, Set<BlockFace> faces) {
MultipleFacing handle = facing(material, allowed, faces);
String key = handle.getAsString();
@@ -855,7 +868,13 @@ public class DecoratorCoreTest {
MultipleFacing data = mock(MultipleFacing.class);
when(data.getAllowedFaces()).thenReturn(allowed);
when(data.getFaces()).thenAnswer(invocation -> EnumSet.copyOf(current));
when(data.hasFace(any(BlockFace.class))).thenAnswer(invocation -> current.contains(invocation.<BlockFace>getArgument(0)));
when(data.hasFace(any(BlockFace.class))).thenAnswer(invocation -> {
BlockFace face = invocation.getArgument(0);
if (!allowed.contains(face)) {
throw new IllegalArgumentException("Invalid blockFace, only " + allowed + " are allowed.");
}
return current.contains(face);
});
doAnswer(invocation -> {
BlockFace face = invocation.getArgument(0);
if (!allowed.contains(face)) {
@@ -6,12 +6,15 @@ import art.arcane.volmlib.util.mantle.MantleClosedException;
import org.junit.Test;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.channels.ClosedByInterruptException;
import java.util.concurrent.CompletionException;
import java.util.concurrent.RejectedExecutionException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -30,6 +33,40 @@ public class GenerationFailuresTest {
new IllegalStateException("placement failed", new GenerationClosedException("router closed")))));
}
@Test
public void mantleInputOutputIsAnEngineFailure() {
assertTrue(GenerationFailures.isEngineFailure(new UncheckedIOException(new IOException("plate read"))));
assertTrue(GenerationFailures.isEngineFailure(new IllegalStateException("placement failed",
new IOException("plate read"))));
}
@Test
public void skippedPlacementRethrowsEngineFailuresAndReturnsOnContentFailures() {
GenerationFailures.skipPlacement(new IllegalArgumentException("Invalid blockFace"),
"decoration", "minecraft:vine", 1, 2, 3, "test/biome");
GenerationClosedException closed = new GenerationClosedException("router closed");
assertSame(closed, assertThrows(GenerationClosedException.class, () -> GenerationFailures.skipPlacement(closed,
"decoration", "minecraft:vine", 1, 2, 3, "test/biome")));
}
@Test
public void skipWarningNamesBlockPositionBiomeAndFailureOnOneLine() {
String line = GenerationFailures.skipWarning("decoration", "minecraft:vine", 1, 2, 3, "test/biome",
new IllegalArgumentException("Invalid\nblockFace"), 0L);
assertEquals("Skipped decoration minecraft:vine at 1,2,3 biome test/biome: IllegalArgumentException: Invalid blockFace"
+ " (GenerationFailuresTest:" + line.substring(line.lastIndexOf(':') + 1), line);
}
@Test
public void repeatedSkipsAreLimitedPerKeyAndCountedOnTheNextLine() {
long start = 1_000_000_000L;
assertEquals(0L, GenerationFailures.claimSkipWarning("limit-test", start));
assertEquals(-1L, GenerationFailures.claimSkipWarning("limit-test", start + 1L));
assertEquals(-1L, GenerationFailures.claimSkipWarning("limit-test", start + 2L));
assertEquals(0L, GenerationFailures.claimSkipWarning("limit-test-other", start + 2L));
assertEquals(2L, GenerationFailures.claimSkipWarning("limit-test", start + GenerationFailures.SKIP_WARNING_NANOS + 1L));
}
@Test
public void contentFailuresRemainSkippable() {
assertFalse(GenerationFailures.isEngineFailure(new IllegalArgumentException("malformed object")));
@@ -2,6 +2,7 @@ package art.arcane.iris.generation.stage;
import art.arcane.iris.generation.runtime.IrisEngine;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.GenerationClosedException;
import art.arcane.iris.generation.decoration.IrisDepositGenerator;
import art.arcane.iris.generation.decoration.IrisDepositHeightDistribution;
import art.arcane.iris.generation.decoration.IrisDepositPlacementScope;
@@ -21,6 +22,7 @@ import art.arcane.volmlib.util.math.RNG;
import org.junit.ClassRule;
import org.junit.Test;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -79,9 +81,9 @@ public class IrisDepositModifierContextTest {
@Test
public void workerPreparationFailurePropagatesAfterAllScopesClose() throws Exception {
try (Fixture fixture = new Fixture(mock(IrisEngine.class, RETURNS_DEEP_STUBS), true)) {
IllegalStateException failure = new IllegalStateException("worker clump preparation failed");
GenerationClosedException failure = new GenerationClosedException("worker clump preparation failed");
doThrow(failure).when(fixture.dimensionDeposit).getClump(any(), any(), any());
assertSame(failure, assertThrows(IllegalStateException.class, () ->
assertSame(failure, assertThrows(GenerationClosedException.class, () ->
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context)));
verify(fixture.chunk).release();
assertEquals(1, fixture.closedScopes.get());
@@ -89,14 +91,24 @@ public class IrisDepositModifierContextTest {
}
}
@Test
public void contentFailureInOneClumpSkipsItAndTheChunkContinues() throws Exception {
try (Fixture fixture = new Fixture(mock(IrisEngine.class, RETURNS_DEEP_STUBS), true)) {
doThrow(new IllegalArgumentException("bad clump")).when(fixture.dimensionDeposit).getClump(any(), any(), any());
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context);
verify(fixture.chunk).release();
assertNull(IrisContext.get());
}
}
@Test
public void callerPlanFailureQueuesNoWorkAndRestoresContext() throws Exception {
try (Fixture fixture = new Fixture(mock(IrisEngine.class, RETURNS_DEEP_STUBS), true)) {
IllegalStateException failure = new IllegalStateException("caller deposit plan failed");
GenerationClosedException failure = new GenerationClosedException("caller deposit plan failed");
doThrow(failure).when(fixture.biomeDeposit).getSpawnChance();
ChunkContext callerContext = mock(ChunkContext.class);
try (IrisContext.Scope ignored = IrisContext.open(fixture.engine, 19L, callerContext)) {
assertSame(failure, assertThrows(IllegalStateException.class, () ->
assertSame(failure, assertThrows(GenerationClosedException.class, () ->
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context)));
assertSame(callerContext, IrisContext.require().getChunkContext());
assertEquals(19L, IrisContext.require().getGenerationSessionId());
@@ -111,12 +123,12 @@ public class IrisDepositModifierContextTest {
@Test
public void distinctWorkerFailuresAreRetainedAfterDraining() throws Exception {
try (Fixture fixture = new Fixture(mock(IrisEngine.class, RETURNS_DEEP_STUBS), true)) {
IllegalArgumentException firstWorker = new IllegalArgumentException("first worker failure");
UnsupportedOperationException secondWorker = new UnsupportedOperationException("second worker failure");
GenerationClosedException firstWorker = new GenerationClosedException("first worker failure");
RejectedExecutionException secondWorker = new RejectedExecutionException("second worker failure");
when(fixture.dimensionDeposit.getMinPerChunk()).thenReturn(200);
when(fixture.dimensionDeposit.getMaxPerChunk()).thenReturn(200);
doThrow(firstWorker, secondWorker).when(fixture.dimensionDeposit).getClump(any(), any(), any());
assertSame(firstWorker, assertThrows(IllegalArgumentException.class, () ->
assertSame(firstWorker, assertThrows(GenerationClosedException.class, () ->
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context)));
assertEquals(1, firstWorker.getSuppressed().length);
assertSame(secondWorker, firstWorker.getSuppressed()[0]);
+1
View File
@@ -308,6 +308,7 @@ tasks.register('generationOrderProbe', JavaExec) {
mainClass = 'art.arcane.iris.probe.GenerationOrderProbe'
classpath = sourceSets.main.runtimeClasspath
jvmArgs('--add-modules', 'jdk.incubator.vector')
systemProperty('iris.probe.faultSurface', providers.gradleProperty('probeFaultSurface').orElse('').get())
dependsOn(':core:compileJava')
doFirst {
Map<String, Provider<String>> required = [
@@ -66,8 +66,14 @@ public final class StubPlatform implements IrisPlatform {
}
public static void bindGenerationStateHandlers() {
String faultSurface = System.getProperty("iris.probe.faultSurface", "");
DecoratorPlatformHooks.bind((state, hunk, rX, rZ, x, y, z, mantle) -> state,
(surface, upward) -> surface.isOccluding());
(surface, upward) -> {
if (!faultSurface.isEmpty() && surface.key().startsWith(faultSurface)) {
throw new IllegalArgumentException("Probe fault on " + surface.key());
}
return surface.isOccluding();
});
IrisObjectRotation.bindPlatformRotator(StubPlatform::rotateState);
BlockDataMergeSupport.bindPlatformMerger(StubPlatform::mergeStates);
TileData.bindPlatformReader(StubTileData::read);