mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Skip unresolved structure captures
- Skip structure placements that fail to resolve in history capture - Pass underground step to the structure river check - Update planner tests for the new river check signature
This commit is contained in:
4 files changed
+71
-15
No files matched your search
+1
-1
@@ -161,7 +161,7 @@ final class HeadlessStructurePlanner {
|
||||
policies.injection().discard(plan.structureKey(), chunk.getPos().x(), chunk.getPos().z());
|
||||
continue;
|
||||
}
|
||||
if (!StructureWaterRules.admitsStart(plan, policies.water(), NativeStructureTerrainIntegrator.pieceFootprints(generated))) {
|
||||
if (!StructureWaterRules.admitsStart(plan, false, policies.water(), NativeStructureTerrainIntegrator.pieceFootprints(generated))) {
|
||||
chunk.setStartForStructure(structure, StructureStart.INVALID_START);
|
||||
policies.injection().discard(plan.structureKey(), chunk.getPos().x(), chunk.getPos().z());
|
||||
continue;
|
||||
|
||||
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.runtime.DimensionStackContext;
|
||||
import art.arcane.iris.generation.runtime.DimensionStackLayout;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.GenerationFailures;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementMarker;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementScope;
|
||||
@@ -398,13 +399,19 @@ public final class GenerationSemanticCapture {
|
||||
if (placement == null || !placement.hasIrisStructures()) {
|
||||
continue;
|
||||
}
|
||||
IrisStructureLocator.ResolvedPlacement resolved = IrisStructureLocator.resolvePlacement(
|
||||
engine,
|
||||
placement,
|
||||
chunkX,
|
||||
chunkZ
|
||||
);
|
||||
if (resolved == null || !IrisStructureLocator.allowsResolvedFootprint(engine, resolved)) {
|
||||
IrisStructureLocator.ResolvedPlacement resolved;
|
||||
try {
|
||||
resolved = IrisStructureLocator.resolvePlacement(
|
||||
engine,
|
||||
placement,
|
||||
chunkX,
|
||||
chunkZ
|
||||
);
|
||||
if (resolved == null || !IrisStructureLocator.allowsResolvedFootprint(engine, resolved)) {
|
||||
continue;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
GenerationFailures.skipPlacement(e, "structure", String.valueOf(placement.getStructures()), chunkX << 4, -1, chunkZ << 4, "none");
|
||||
continue;
|
||||
}
|
||||
semantics.addStructure(
|
||||
|
||||
+7
-7
@@ -171,11 +171,11 @@ public class NativeStructurePlacementPlannerTest {
|
||||
|
||||
assertNotNull(plan);
|
||||
assertTrue("64 of 640 piece columns, all beyond the start chunk, are 10% river",
|
||||
StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
StructureWaterRules.admitsStart(plan, false, stageWater, VILLAGE));
|
||||
|
||||
roles.put(columnKey(35, 15), WaterRole.CHANNEL);
|
||||
assertFalse("65 of 640 piece columns are more than 10% river",
|
||||
StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
StructureWaterRules.admitsStart(plan, false, stageWater, VILLAGE));
|
||||
|
||||
roles.clear();
|
||||
WaterRole[] dry = {WaterRole.MOUTH, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.BANK, WaterRole.DAM};
|
||||
@@ -186,7 +186,7 @@ public class NativeStructurePlacementPlannerTest {
|
||||
}
|
||||
}
|
||||
assertTrue("mouths, shores, banks and dams do not count as river water",
|
||||
StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
StructureWaterRules.admitsStart(plan, false, stageWater, VILLAGE));
|
||||
|
||||
roles.clear();
|
||||
for (int x = 0; x <= 39; x++) {
|
||||
@@ -194,7 +194,7 @@ public class NativeStructurePlacementPlannerTest {
|
||||
roles.put(columnKey(x, z), x % 2 == 0 ? WaterRole.INLET : WaterRole.BANK);
|
||||
}
|
||||
}
|
||||
assertFalse("a sea inlet under the pieces counts as river water", StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
assertFalse("a sea inlet under the pieces counts as river water", StructureWaterRules.admitsStart(plan, false, stageWater, VILLAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +234,7 @@ public class NativeStructurePlacementPlannerTest {
|
||||
NativeStructureStartPlan plan = NativeStructurePlacementPlanner.planAt(engine, placement, 12, -7);
|
||||
|
||||
assertNotNull(plan);
|
||||
assertTrue(StructureWaterRules.admitsStart(plan, new BukkitStructureStagePolicy(engine).water(engine), VILLAGE));
|
||||
assertTrue(StructureWaterRules.admitsStart(plan, false, new BukkitStructureStagePolicy(engine).water(engine), VILLAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -247,12 +247,12 @@ public class NativeStructurePlacementPlannerTest {
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
|
||||
assertFalse(StructureWaterRules.admitsStart(
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0), stageWater, VILLAGE));
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0), false, stageWater, VILLAGE));
|
||||
|
||||
placement.setAllowWater(true);
|
||||
NativeStructureStartPlan plan = NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0);
|
||||
assertTrue(plan.allowWater());
|
||||
assertTrue(StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
assertTrue(StructureWaterRules.admitsStart(plan, false, stageWater, VILLAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,6 +17,10 @@ import art.arcane.iris.pack.value.IrisRange;
|
||||
import art.arcane.iris.world.IrisWorld;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementMarker;
|
||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementScope;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveAction;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
@@ -586,6 +590,51 @@ public final class GenerationSemanticCaptureTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aStructurePlacementThatFailsToResolveIsSkippedAndTheChunkStillCaptures() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisStructurePlacement broken = mock(IrisStructurePlacement.class);
|
||||
IrisStructurePlacement working = mock(IrisStructurePlacement.class);
|
||||
when(broken.hasIrisStructures()).thenReturn(true);
|
||||
when(working.hasIrisStructures()).thenReturn(true);
|
||||
when(fixture.complex.allowsNewGenerationChunk(-2, 3)).thenReturn(true);
|
||||
when(fixture.mantle.hasFlag(-2, 3, ReservedFlag.JIGSAW)).thenReturn(true);
|
||||
IrisStructureLocator.ResolvedPlacement resolved = mock(IrisStructureLocator.ResolvedPlacement.class);
|
||||
when(resolved.structureKey()).thenReturn("iris:ruin");
|
||||
try (MockedStatic<StructurePlacementScope> scope = mockStatic(StructurePlacementScope.class);
|
||||
MockedStatic<IrisStructureLocator> locator = mockStatic(IrisStructureLocator.class)) {
|
||||
scope.when(() -> StructurePlacementScope.placementsAt(fixture.engine, -2, 3))
|
||||
.thenReturn(new KList<>(broken, working));
|
||||
locator.when(() -> IrisStructureLocator.resolvePlacement(fixture.engine, broken, -2, 3))
|
||||
.thenThrow(new IllegalStateException("Iris structure 'iris:bad' has no runtime-viable assembly graph"));
|
||||
locator.when(() -> IrisStructureLocator.resolvePlacement(fixture.engine, working, -2, 3)).thenReturn(resolved);
|
||||
locator.when(() -> IrisStructureLocator.allowsResolvedFootprint(fixture.engine, resolved)).thenReturn(true);
|
||||
|
||||
ChunkGenerationSemantics captured = GenerationSemanticCapture.capture(fixture.engine, -2, 3, 5L);
|
||||
|
||||
assertEquals(1, captured.structures().size());
|
||||
assertTrue(captured.sealed());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBrokenEngineDuringStructureCaptureStillFailsTheChunk() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisStructurePlacement placement = mock(IrisStructurePlacement.class);
|
||||
when(placement.hasIrisStructures()).thenReturn(true);
|
||||
when(fixture.complex.allowsNewGenerationChunk(-2, 3)).thenReturn(true);
|
||||
when(fixture.mantle.hasFlag(-2, 3, ReservedFlag.JIGSAW)).thenReturn(true);
|
||||
try (MockedStatic<StructurePlacementScope> scope = mockStatic(StructurePlacementScope.class);
|
||||
MockedStatic<IrisStructureLocator> locator = mockStatic(IrisStructureLocator.class)) {
|
||||
scope.when(() -> StructurePlacementScope.placementsAt(fixture.engine, -2, 3))
|
||||
.thenReturn(new KList<>(placement));
|
||||
locator.when(() -> IrisStructureLocator.resolvePlacement(fixture.engine, placement, -2, 3))
|
||||
.thenThrow(new OutOfMemoryError("test"));
|
||||
|
||||
assertThrows(OutOfMemoryError.class, () -> GenerationSemanticCapture.capture(fixture.engine, -2, 3, 5L));
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<HydrologyFeatureType, Long> features(Fixture fixture, int chunkX, int chunkZ) {
|
||||
Map<HydrologyFeatureType, Long> features = new TreeMap<>();
|
||||
for (ChunkGenerationSemantics.RiverFeatureOccurrence occurrence
|
||||
|
||||
Reference in new issue
Block a user