Keep generating past failures

- REPLACE_SOURCE failures no longer stop the chunk: skip the piece or structure and warn once per structure and cause
- Replace requirePlacementOutput with placementOutput and remove requireAppliedPieces
- Key structure piece warnings on the structure, not the object
- Register the VolmLib placement failure hook from IrisEngine, using the engine failure rule
- Add HydrologyPlanException so a failed plan read inside a placement scope stops the chunk
- Add modded containment tests, with source rules for the 26.2 and 1.21.1 test sources
This commit is contained in:
Brian Fopiano committed 2026-11-04 03:08:58 -05:00
1 parent d0923de181
commit f4f7e92a4c
15 files changed
+689 -86

No files matched your search

@@ -1,5 +1,6 @@
package art.arcane.iris.generation.hydrology.engine;
import art.arcane.iris.generation.runtime.HydrologyPlanException;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.concurrent.MultiBurst;
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
@@ -630,7 +631,7 @@ public final class HydrologyRuntime {
throw cancelled;
} catch (RuntimeException failure) {
failures.failed(chunk);
throw new IllegalStateException("Hydrology could not build the water raster for chunk " + chunkX + "," + chunkZ + ".", failure);
throw new HydrologyPlanException("Hydrology could not build the water raster for chunk " + chunkX + "," + chunkZ + ".", failure);
}
}
@@ -98,9 +98,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
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");
}
}
@@ -160,7 +157,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
}
int failedPieces = placePieces(writer, placement, structure, pieces, rng);
requireAppliedPieces(resolved, cx, cz, failedPieces);
if (failedPieces == 0) {
capture.commit();
}
@@ -171,7 +167,8 @@ public class IrisStructureComponent extends IrisMantleComponent {
KList<PlacedStructurePiece> pieces, RNG rng) {
IrisStructureStiltSettings stilt = placement.getStilt();
PieceRun run = new PieceRun(structure, rng, stilt == null ? null : new Long2IntOpenHashMap(),
stilt != null && stilt.isSupportNonOccluding(), placement.isAllowWater());
stilt != null && stilt.isSupportNonOccluding(), placement.isAllowWater(),
placement.getNativeSuppression() == NativeStructureSuppression.REPLACE_SOURCE);
ObjectPlaceMode mode = structure.getPlaceMode();
int failedPieces = 0;
int water = writer.beginObjectPlacement(run.allowWater());
@@ -266,22 +263,14 @@ public class IrisStructureComponent extends IrisMantleComponent {
return null;
}
KList<PlacedStructurePiece> pieces = resolved.pieces();
if (!IrisStructureLocator.requirePlacementOutput(
if (!IrisStructureLocator.placementOutput(
resolved.placement(), resolved.structureKey(), chunkX, chunkZ,
pieces != null && !pieces.isEmpty(), "placement application received no assembled pieces")) {
pieces != null && !pieces.isEmpty(), "no assembled pieces", null)) {
return null;
}
return pieces;
}
static void requireAppliedPieces(IrisStructureLocator.ResolvedPlacement resolved,
int chunkX, int chunkZ, int failedPieces) {
IrisStructureLocator.requirePlacementOutput(
resolved.placement(), resolved.structureKey(), chunkX, chunkZ, failedPieces == 0,
"object placement rejected " + failedPieces + " of " + resolved.pieces().size()
+ " assembled piece(s)");
}
void boreStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
IrisStructureTerrain terrain) {
int[] bounds = computePieceBounds(pieces);
@@ -589,11 +578,15 @@ public class IrisStructureComponent extends IrisMantleComponent {
}
};
try {
return sampledHeight
int placed = 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());
if (placed == -1 && run.replacesSource()) {
GenerationFailures.skipStructure(run.structure().getLoadKey(), "piece rejected", objectKey, p.getX() >> 4, p.getZ() >> 4);
}
return placed;
} catch (Throwable e) {
GenerationFailures.skipPlacement(e, "structure piece", objectKey, p.getX(), p.getY(), p.getZ(), run.structure().getLoadKey());
GenerationFailures.skipStructurePiece(e, run.structure().getLoadKey(), objectKey, p.getX(), p.getY(), p.getZ());
return -1;
}
}
@@ -735,6 +728,6 @@ public class IrisStructureComponent extends IrisMantleComponent {
}
private record PieceRun(IrisStructure structure, RNG rng, Long2IntOpenHashMap foundationColumns,
boolean supportNonOccluding, boolean allowWater) {
boolean supportNonOccluding, boolean allowWater, boolean replacesSource) {
}
}
@@ -3,6 +3,7 @@ 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.nativelib.terrain.NativePlacementFailures;
import art.arcane.volmlib.util.mantle.MantleClosedException;
import java.io.IOException;
@@ -32,12 +33,18 @@ public final class GenerationFailures {
private GenerationFailures() {
}
public static void bindNativeFailures() {
NativePlacementFailures.register((Throwable failure, String kind, String id, int x, int z) ->
skipPlacement(failure, kind, id, x, -1, z, "none"));
}
public static boolean isEngineFailure(Throwable failure) {
return isShutdownFailure(failure) || hasCause(failure, (Throwable cause) -> cause instanceof Error
|| cause instanceof WrongEngineBroException
|| cause instanceof ProvisionalAnswerException
|| cause instanceof SavedBiomeUnavailableException unavailable && unavailable.isLoading()
|| cause instanceof GenerationSessionException
|| cause instanceof HydrologyPlanException
|| cause instanceof IOException
|| cause instanceof UncheckedIOException
|| cause instanceof TimeoutException);
@@ -99,6 +106,41 @@ public final class GenerationFailures {
}
}
/**
* One failed piece of one structure. The warning counts per structure and failure, however many objects fail.
*/
public static void skipStructurePiece(Throwable failure, String structure, String piece, int x, int y, int z) {
rethrowEngineFailure(failure);
String key = "structure piece|" + structure + '|' + failure.getClass().getName();
long suppressed = claimSkipWarning(key, System.nanoTime());
if (suppressed >= 0L) {
IrisLogging.warn(skipWarning("structure piece", structure + ' ' + piece, x, y, z, "none", failure, suppressed));
}
}
/**
* One structure that gave no output without throwing. The cause must stay the same between chunks: it is the
* warning's key, and the detail is only printed.
*/
public static void skipStructure(String structure, String cause, String detail, int chunkX, int chunkZ) {
long suppressed = claimSkipWarning("structure|" + structure + '|' + cause, System.nanoTime());
if (suppressed >= 0L) {
IrisLogging.warn(structureWarning(structure, cause, detail, chunkX, chunkZ, suppressed));
}
}
static String structureWarning(String structure, String cause, String detail, int chunkX, int chunkZ, long suppressed) {
StringBuilder line = new StringBuilder("Skipped structure ").append(structure)
.append(" in chunk ").append(chunkX).append(',').append(chunkZ).append(": ").append(cause);
if (detail != null && !detail.isBlank()) {
line.append(" (").append(detail.replaceAll("\\s+", " ")).append(')');
}
if (suppressed > 0L) {
line.append(", ").append(suppressed).append(" more");
}
return line.toString();
}
static long claimSkipWarning(String key, long now) {
SkipWarning warning = SKIP_WARNINGS.get(key);
if (warning == null) {
@@ -0,0 +1,10 @@
package art.arcane.iris.generation.runtime;
/**
* A hydrology plan could not be read. Water for the chunk can't be known, so no placement scope may skip this.
*/
public final class HydrologyPlanException extends IllegalStateException {
public HydrologyPlanException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -255,6 +255,7 @@ public class IrisEngine implements Engine {
GenerationKernelRegistry.Version kernelVersion,
TransitionGenerationPlan transitionPlan
) {
GenerationFailures.bindNativeFailures();
EngineTarget requiredTarget = Objects.requireNonNull(target, "engine target");
InitializationMode requiredMode = Objects.requireNonNull(initializationMode, "initialization mode");
this.initializationMode = requiredMode;
@@ -28,6 +28,7 @@ import art.arcane.volmlib.util.structure.StructureTerrainMode;
import art.arcane.volmlib.util.structure.StructureCarveShape;
import art.arcane.iris.generation.runtime.GenerationFailures;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.SeedManager;
import art.arcane.iris.structure.nativegen.NativeStructurePlacementPlanner;
@@ -545,15 +546,15 @@ public final class IrisStructureLocator {
StructureAssembler assembler = StructureAssembler.forData(
engine.getData(), structure, new IrisPosition(originX, baseY, originZ));
StructureAssemblyResult assembly = assembler.assemble(rng);
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
if (!placementOutput(placement, selectedKey, cx, cz,
assembly.hasOutput(), "assembly " + assembly.status(), assembly.detail())) {
return null;
}
KList<PlacedStructurePiece> pieces = new KList<>(assembly.pieces());
pieces = alignCavePieces(pieces, placement, baseY);
pieces = alignSurfacePieces(pieces, placement, structure, baseY);
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
pieces != null && !pieces.isEmpty(), "surface alignment produced no pieces")) {
if (!placementOutput(placement, selectedKey, cx, cz,
pieces != null && !pieces.isEmpty(), "surface alignment left no pieces", null)) {
return null;
}
boolean exactY = hasExactY(placement, structure, pieces);
@@ -562,8 +563,8 @@ public final class IrisStructureLocator {
int worldMax = engine.getMinHeight() + engine.getHeight() - 1;
if (exactY) {
Integer verticalShift = resolveVerticalShift(pieces, placement, baseY, worldMin, worldMax);
if (!requirePlacementOutput(placement, selectedKey, cx, cz, verticalShift != null,
"assembled pieces cannot fit the configured vertical and world bounds")) {
if (!placementOutput(placement, selectedKey, cx, cz, verticalShift != null,
"pieces do not fit the vertical bounds", null)) {
return null;
}
if (verticalShift != 0) {
@@ -574,8 +575,8 @@ public final class IrisStructureLocator {
if (placement.isAnchoredUnderground() && !placement.resolvedAnchor().isCave()) {
Integer burialShift = resolveUndergroundBurialShift(
engine, pieces, placement, baseY, worldMin, worldMax);
if (!requirePlacementOutput(placement, selectedKey, cx, cz, burialShift != null,
"assembled pieces and carving envelope cannot remain fully buried beneath terrain")) {
if (!placementOutput(placement, selectedKey, cx, cz, burialShift != null,
"pieces cannot stay buried", null)) {
return null;
}
if (burialShift != 0) {
@@ -588,8 +589,8 @@ public final class IrisStructureLocator {
int structureRadius = (int) Math.min(Integer.MAX_VALUE, configuredRadius);
boolean withinBounds = fitsHorizontalBounds(pieces, originX, originZ, structureRadius)
&& (!exactY || fitsVerticalBounds(pieces, worldMin, worldMax));
if (!requirePlacementOutput(placement, selectedKey, cx, cz, withinBounds,
"assembled pieces exceed the configured structure or world bounds")) {
if (!placementOutput(placement, selectedKey, cx, cz, withinBounds,
"pieces exceed the structure or world bounds", null)) {
return null;
}
if (!placement.isAnchoredUnderground() && !placement.isAllowWater()
@@ -607,23 +608,17 @@ public final class IrisStructureLocator {
return allowsResolvedFootprint(engine, resolved.placement(), resolved.structure(), resolved.pieces());
}
public static boolean requirePlacementOutput(IrisStructurePlacement placement, String structureKey,
int chunkX, int chunkZ, boolean outputPresent,
String failureReason) {
public static boolean placementOutput(IrisStructurePlacement placement, String structureKey, int chunkX, int chunkZ,
boolean outputPresent, String cause, String detail) {
if (outputPresent) {
return true;
}
if (placement == null
|| NativeStructureSuppression.REPLACE_SOURCE != placement.getNativeSuppression()) {
return false;
if (placement != null && NativeStructureSuppression.REPLACE_SOURCE == placement.getNativeSuppression()) {
String key = structureKey == null || structureKey.isBlank()
? String.valueOf(placement.getStructures()) : structureKey;
GenerationFailures.skipStructure(key, cause, detail, chunkX, chunkZ);
}
String key = structureKey == null || structureKey.isBlank()
? String.valueOf(placement.getStructures()) : structureKey;
String reason = failureReason == null || failureReason.isBlank()
? "placement produced no output" : failureReason;
throw new IllegalStateException("REPLACE_SOURCE placement for Iris structure '" + key
+ "' failed in chunk " + chunkX + "," + chunkZ + ": " + reason
+ ". Native generation is suppressed and will not be used as a fallback");
return false;
}
static boolean fitsWorldBounds(KList<PlacedStructurePiece> pieces, int worldMin, int worldMax,