mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Platform starts fit through a neutral bridge to iris:structure
Core asks the pack's VanillaStructures providers (ModuleVanillaStructures) for rules, starts, the shift of each platform start and every module's reach, and runs the built-in fit through ModuleStructureFitting, which turns the platform's chunk into the API's StructureFit. minecraft-common's NativeStructureFitBridge hands Bukkit and the modded loaders' starts, processed template cells, template columns and legacy air to it; the platform helpers that held the fit (surface fitter, terrain integrator, support and foundation builders, post processor) are gone. The host only moves, clamps, wraps and places starts. Ownership records keep their binary layout: the two texts that held the stilts and terrain JSON now hold the start's memo, which the module writes in the same JSON, so records written before read the same. A recorded reference envelope only grows when today's reaches are wider. Tests: the fit's rules are tested in core against stated cells; the bridge and the fit end to end on the NMS harness; the object place mode and native structure fit pins stay identical.
This commit is contained in:
1 parent
6a1d2564e2
commit
0b3556f09c
90 files changed
+5278
-7051
No files matched your search
+42
-78
@@ -7,34 +7,29 @@ import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
||||
import art.arcane.iris.engine.framework.NativeStructureLayouts;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
||||
import art.arcane.iris.engine.IrisEngine;
|
||||
import art.arcane.iris.engine.platform.BukkitChunkGenerator;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecision;
|
||||
import art.arcane.iris.nativegen.NativeStructureFitBridge;
|
||||
import art.arcane.iris.nativegen.NativeStructureGenerationException;
|
||||
import art.arcane.iris.nativegen.NativeStructureStartInjector;
|
||||
import art.arcane.iris.nativegen.NativeStructureReferenceEnvelope;
|
||||
import art.arcane.iris.nativegen.NativeStructureLocateResults;
|
||||
import art.arcane.iris.nativegen.NativeStructureLocatePersistence;
|
||||
import art.arcane.iris.nativegen.NativeStructureOwnershipRecovery;
|
||||
import art.arcane.iris.nativegen.NativeStructurePostProcessor;
|
||||
import art.arcane.iris.nativegen.NativeStructureReferenceRepair;
|
||||
import art.arcane.iris.nativegen.NativeStructureSurfaceFitter;
|
||||
import art.arcane.iris.nativegen.NativeStructureTerrainIntegrator;
|
||||
import art.arcane.iris.nativegen.NativeStructureVegetationClearer;
|
||||
import art.arcane.iris.nativegen.NativeStructureVerticalPlacer;
|
||||
import art.arcane.iris.nativegen.NativeStructureVanillaLocator;
|
||||
import art.arcane.iris.nativegen.NativeStructureVolumeIndex;
|
||||
import art.arcane.iris.nativegen.WorldgenTerrainHeightmaps;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.IrisCustomData;
|
||||
import art.arcane.iris.util.common.reflect.WrappedField;
|
||||
import art.arcane.iris.util.common.reflect.WrappedReturningMethod;
|
||||
import art.arcane.iris.util.project.context.IrisContext;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -87,9 +82,7 @@ import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.generator.CustomChunkGenerator;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.spigotmc.SpigotWorldConfig;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -288,9 +281,7 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
throw new IllegalStateException("Native structure filtering received an unregistered structure holder");
|
||||
}
|
||||
String key = id.toString();
|
||||
IrisNativeStructureDecision decision = NativeStructureGenerationPolicy.resolve(engine,
|
||||
key, NativeStructureVegetationClearer.isUndergroundStep(holder.value().step()));
|
||||
if (!decision.generate()) {
|
||||
if (!NativeStructureGenerationPolicy.generates(engine, key)) {
|
||||
continue;
|
||||
}
|
||||
candidates.add(new NativeLocateCandidate(holder, key));
|
||||
@@ -405,33 +396,32 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
"resolution", null, chunkPos.x(), chunkPos.z());
|
||||
}
|
||||
boolean undergroundStep = NativeStructureVegetationClearer.isUndergroundStep(structure.step());
|
||||
IrisNativeStructureDecision decision;
|
||||
boolean generates;
|
||||
try {
|
||||
decision = NativeStructureGenerationPolicy.resolve(engine,
|
||||
structureId, undergroundStep);
|
||||
generates = NativeStructureGenerationPolicy.generates(engine, structureId);
|
||||
} catch (Throwable error) {
|
||||
throw NativeStructureGenerationException.failure(
|
||||
"policy resolution", structureId, chunkPos.x(), chunkPos.z(), error);
|
||||
}
|
||||
if (!decision.generate()) {
|
||||
if (!generates) {
|
||||
access.setStartForStructure(structure, StructureStart.INVALID_START);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
IntBinaryOperator surface = (x, z) -> engine.getHeight(x, z, true) + engine.getMinHeight();
|
||||
int shift = NativeStructureLayouts.shift(engine, NativeStructureVerticalPlacer.placementOf(
|
||||
start, structureId, undergroundStep, access.getMinY(), surface));
|
||||
NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start,
|
||||
structureId,
|
||||
decision.yShift(),
|
||||
shift,
|
||||
getSeaLevel(),
|
||||
access.getMinY(),
|
||||
access.getMinY() + access.getHeight(),
|
||||
undergroundStep,
|
||||
decision.preserveSourceY(),
|
||||
decision.yBand(),
|
||||
(x, z) -> engine.getHeight(x, z, true) + engine.getMinHeight());
|
||||
surface);
|
||||
StructureStart wrapped = NativeStructureReferenceEnvelope.wrapForPublication(
|
||||
start, structure, start.getReferences(),
|
||||
NativeStructureTerrainIntegrator.resolveNativeTerrain(start, decision.terrain()),
|
||||
NativeStructureLayouts.reaches(engine, structureId, undergroundStep, null),
|
||||
structureId);
|
||||
access.setStartForStructure(structure, wrapped);
|
||||
} catch (Throwable error) {
|
||||
@@ -822,7 +812,7 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
List<NativePlacementGroup> placementGroups = new ArrayList<>();
|
||||
List<StructureStart> heightmapStarts = new ArrayList<>();
|
||||
List<StructureStart> vegetationTargets = new ArrayList<>();
|
||||
List<NativeStructureTerrainIntegrator.TerrainTarget> terrainTargets = new ArrayList<>();
|
||||
List<NativeStructureFitBridge.FitTarget> fitTargets = new ArrayList<>();
|
||||
for (int step = 0; step < steps; step++) {
|
||||
int index = 0;
|
||||
for (Structure structure : byStep.get(step)) {
|
||||
@@ -833,25 +823,20 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
"resolution", null, chunkPos.x(), chunkPos.z());
|
||||
}
|
||||
try {
|
||||
IrisNativeStructureDecision sourceDecision = NativeStructureGenerationPolicy.resolve(engine,
|
||||
structureId, NativeStructureVegetationClearer.isUndergroundStep(structure.step()));
|
||||
boolean platformGenerates = NativeStructureGenerationPolicy.generates(engine, structureId);
|
||||
List<StructureStart> starts = structureManager.startsForStructure(sectionPos, structure);
|
||||
List<NativePlacement> resolvedPlacements = new ArrayList<>(starts.size());
|
||||
for (StructureStart start : starts) {
|
||||
NativeStructureOwnershipRecord ownership =
|
||||
NativeStructureOwnershipRecovery.resolve(
|
||||
engine, world.getLevel(), structureId, structure, start);
|
||||
IrisNativeStructureDecision decision =
|
||||
ownership == null ? sourceDecision : ownership.restoredDecision();
|
||||
if (!decision.generate()) {
|
||||
if (ownership == null && !platformGenerates) {
|
||||
continue;
|
||||
}
|
||||
resolvedPlacements.add(new NativePlacement(start, decision));
|
||||
resolvedPlacements.add(new NativePlacement(start, ownership != null));
|
||||
heightmapStarts.add(start);
|
||||
terrainTargets.add(new NativeStructureTerrainIntegrator.TerrainTarget(
|
||||
structureId, start,
|
||||
NativeStructureTerrainIntegrator.resolveNativeTerrain(
|
||||
start, decision.terrain())));
|
||||
fitTargets.add(new NativeStructureFitBridge.FitTarget(structureId, start,
|
||||
ownership == null ? null : ownership.restoredMemo()));
|
||||
vegetationTargets.add(start);
|
||||
}
|
||||
if (!resolvedPlacements.isEmpty()) {
|
||||
@@ -881,44 +866,29 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
"vegetation cleanup", nativeStructureBatchContext(placementGroups),
|
||||
chunkPos.x(), chunkPos.z(), error);
|
||||
}
|
||||
NativeStructureSurfaceFitter.VacuumFoundationPlan vacuumFoundationPlan;
|
||||
NativeStructureFitting.Session fit;
|
||||
try {
|
||||
vacuumFoundationPlan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, terrainTargets,
|
||||
(x, z) -> engine.getHeight(x, z, true) + engine.getMinHeight());
|
||||
fit = NativeStructureFitting.of(engine).beforePieces(NativeStructureFitBridge.chunk(
|
||||
world, area, fitTargets, (x, z) -> engine.getHeight(x, z, true) + engine.getMinHeight()));
|
||||
} catch (Throwable error) {
|
||||
throw NativeStructureGenerationException.failure(
|
||||
"terrain integration", nativeStructureBatchContext(placementGroups),
|
||||
chunkPos.x(), chunkPos.z(), error);
|
||||
}
|
||||
try {
|
||||
NativeStructurePostProcessor.prepareTerrain(
|
||||
world, area, terrainTargets, this::resolvePaletteBlock);
|
||||
} catch (Throwable error) {
|
||||
throw NativeStructureGenerationException.failure(
|
||||
"terrain preparation", nativeStructureBatchContext(placementGroups),
|
||||
"terrain fitting", nativeStructureBatchContext(placementGroups),
|
||||
chunkPos.x(), chunkPos.z(), error);
|
||||
}
|
||||
int placed = 0;
|
||||
for (NativePlacementGroup group : placementGroups) {
|
||||
random.setFeatureSeed(decoSeed, group.featureIndex(), group.step());
|
||||
try {
|
||||
for (NativePlacement placement : group.placements()) {
|
||||
placeVanillaStructure(world, structureManager, random, area, chunkPos,
|
||||
group.structureId(), placement.start(), placement.decision());
|
||||
group.structureId(), placement);
|
||||
fit.afterPieces(placed++);
|
||||
}
|
||||
} catch (Throwable error) {
|
||||
throw NativeStructureGenerationException.failure(
|
||||
"placement", group.structureId(), chunkPos.x(), chunkPos.z(), error);
|
||||
}
|
||||
}
|
||||
try {
|
||||
NativeStructureSurfaceFitter.repairVacuumFoundations(
|
||||
world, area, vacuumFoundationPlan);
|
||||
} catch (Throwable error) {
|
||||
throw NativeStructureGenerationException.failure(
|
||||
"foundation repair", nativeStructureBatchContext(placementGroups),
|
||||
chunkPos.x(), chunkPos.z(), error);
|
||||
}
|
||||
}
|
||||
|
||||
private static String nativeStructureBatchContext(List<NativePlacementGroup> placementGroups) {
|
||||
@@ -936,20 +906,29 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
}
|
||||
|
||||
private void placeVanillaStructure(WorldGenLevel world, StructureManager structureManager, WorldgenRandom random,
|
||||
BoundingBox area, ChunkPos chunkPos, String structureId, StructureStart start,
|
||||
IrisNativeStructureDecision decision) {
|
||||
BoundingBox area, ChunkPos chunkPos, String structureId,
|
||||
NativePlacement placement) {
|
||||
WorldGenLevel boundedWorld = NativeStructureWorldgenAccess.create(
|
||||
world, chunkPos, worldgenSurfaceHeight(), worldgenFloorHeight());
|
||||
world.setCurrentlyGenerating(() -> "Iris native structure " + structureId);
|
||||
try {
|
||||
NativeStructurePostProcessor.place(boundedWorld, structureManager, this, random, area, chunkPos,
|
||||
structureId, start, decision, this::resolvePaletteBlock,
|
||||
(x, z) -> engine.getHeight(x, z, true) + engine.getMinHeight());
|
||||
StructureStart start = placement.start();
|
||||
NativeStructureVerticalPlacer.ensureMonumentSeaLevelAlignment(start, structureId,
|
||||
() -> placement.recorded() ? 0 : platformShift(start, structureId, world.getMinY()),
|
||||
getSeaLevel(), area.minY(), area.maxY() + 1);
|
||||
start.placeInChunk(boundedWorld, structureManager, this, random, area, chunkPos);
|
||||
} finally {
|
||||
world.setCurrentlyGenerating(null);
|
||||
}
|
||||
}
|
||||
|
||||
/** The shift the pack's modules give the platform's own start, as when the start was published. */
|
||||
private int platformShift(StructureStart start, String structureId, int bottomY) {
|
||||
return NativeStructureLayouts.shift(engine, NativeStructureVerticalPlacer.placementOf(start, structureId,
|
||||
NativeStructureVegetationClearer.isUndergroundStep(start.getStructure().step()), bottomY,
|
||||
(x, z) -> engine.getHeight(x, z, true) + engine.getMinHeight()));
|
||||
}
|
||||
|
||||
private List<List<Structure>> structuresByStep(Registry<Structure> registry) {
|
||||
StructureStepCache cached = structureStepCache;
|
||||
if (cached != null && cached.registry() == registry) {
|
||||
@@ -977,22 +956,6 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private BlockState resolvePaletteBlock(IrisMaterialPalette palette, RNG rng, int x, int y, int z) {
|
||||
PlatformBlockState platformState = palette.get(rng, x, y, z, engine.getData());
|
||||
if (platformState == null || !(platformState.nativeHandle() instanceof BlockData blockData)) {
|
||||
throw new IllegalStateException("Configured native structure palette did not resolve a Bukkit block at "
|
||||
+ x + "," + y + "," + z);
|
||||
}
|
||||
if (blockData instanceof IrisCustomData customData) {
|
||||
blockData = customData.getBase();
|
||||
}
|
||||
if (blockData instanceof CraftBlockData craftBlockData) {
|
||||
return craftBlockData.getState();
|
||||
}
|
||||
throw new IllegalStateException("Configured native structure palette resolved unsupported Bukkit block data "
|
||||
+ blockData.getClass().getName() + " at " + x + "," + y + "," + z);
|
||||
}
|
||||
|
||||
private BoundingBox writableArea(ChunkAccess chunk) {
|
||||
ChunkPos cp = chunk.getPos();
|
||||
int i = cp.getMinBlockX();
|
||||
@@ -1205,7 +1168,8 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
||||
void publish() throws IllegalAccessException;
|
||||
}
|
||||
|
||||
private record NativePlacement(StructureStart start, IrisNativeStructureDecision decision) {
|
||||
/** A start placed in the chunk, and whether a module placed it (its ownership record kept its fit). */
|
||||
private record NativePlacement(StructureStart start, boolean recorded) {
|
||||
}
|
||||
|
||||
private record NativePlacementGroup(String structureId, int featureIndex, int step,
|
||||
|
||||
+9
-11
@@ -64,20 +64,18 @@ public class IrisChunkGeneratorFailureContractTest {
|
||||
assertTrue(adjustment.contains("\"vertical adjustment\""));
|
||||
assertFalse(adjustment.contains("IrisLogging.reportError"));
|
||||
assertTrue(placement.contains("\"resolution\""));
|
||||
assertTrue(placement.contains("\"terrain integration\""));
|
||||
assertTrue(placement.contains("\"terrain preparation\""));
|
||||
assertTrue(placement.contains("\"foundation repair\""));
|
||||
assertTrue(placement.contains("\"terrain fitting\""));
|
||||
assertFalse(placement.contains("\"terrain carving\""));
|
||||
assertTrue(placement.contains("\"vegetation cleanup\""));
|
||||
assertTrue(placement.contains("\"placement\""));
|
||||
assertTrue(placement.contains("because structure generation is disabled outside the pack"));
|
||||
assertTrue(placement.contains("prepareSurfaceStructures"));
|
||||
assertTrue(placement.contains(".beforePieces("));
|
||||
assertTrue(placement.contains("clearIntersectingVegetation"));
|
||||
assertTrue(placement.indexOf("clearIntersectingVegetation")
|
||||
< placement.indexOf("prepareSurfaceStructures"));
|
||||
assertTrue(placement.indexOf("prepareSurfaceStructures")
|
||||
< placement.indexOf(".beforePieces("));
|
||||
assertTrue(placement.indexOf(".beforePieces(")
|
||||
< placement.indexOf("for (NativePlacementGroup group"));
|
||||
assertTrue(placement.indexOf("repairVacuumFoundations")
|
||||
assertTrue(placement.indexOf("fit.afterPieces(")
|
||||
> placement.indexOf("for (NativePlacementGroup group"));
|
||||
assertFalse(placement.contains("IrisLogging.reportError"));
|
||||
}
|
||||
@@ -215,7 +213,7 @@ public class IrisChunkGeneratorFailureContractTest {
|
||||
assertEquals(1, occurrences(source, "WorldgenTerrainHeightmaps.primeTerrain("));
|
||||
assertTrue(placement.contains("WorldgenTerrainHeightmaps.primeStructurePlacement("));
|
||||
assertTrue(placement.indexOf("WorldgenTerrainHeightmaps.primeStructurePlacement(")
|
||||
< placement.indexOf("prepareSurfaceStructures"));
|
||||
< placement.indexOf(".beforePieces("));
|
||||
assertTrue(fill.contains("requireGenerationLease(\"bukkit_nms_chunk_pipeline\")"));
|
||||
assertTrue(source.contains("int minY = chunk.getMinY() + 1;"));
|
||||
}
|
||||
@@ -443,7 +441,7 @@ public class IrisChunkGeneratorFailureContractTest {
|
||||
|
||||
@Test
|
||||
public void worldgenHeightmapPrimingLivesInTheSharedNativegenSources() throws IOException {
|
||||
Path nativegen = Path.of(System.getProperty("iris.nativeStructurePostProcessorSource")).getParent();
|
||||
Path nativegen = Path.of(System.getProperty("iris.nativeStructureFitBridgeSource")).getParent();
|
||||
Path shared = nativegen.resolve("WorldgenTerrainHeightmaps.java");
|
||||
|
||||
assertTrue("Worldgen heightmap priming must be shared with the modded loaders through "
|
||||
@@ -470,11 +468,11 @@ public class IrisChunkGeneratorFailureContractTest {
|
||||
String placement = source.substring(placementStart, placementEnd);
|
||||
int ownershipResolution = placement.indexOf(
|
||||
"NativeStructureOwnershipRecovery.resolve(");
|
||||
int persistedDecision = placement.indexOf("ownership.restoredDecision()", ownershipResolution);
|
||||
int persistedDecision = placement.indexOf("ownership.restoredMemo()", ownershipResolution);
|
||||
int adjustmentStart = source.indexOf("private void adjustGeneratedStructures");
|
||||
int adjustmentEnd = source.indexOf("public ChunkGeneratorStructureState createState", adjustmentStart);
|
||||
String adjustment = source.substring(adjustmentStart, adjustmentEnd);
|
||||
Path nativegen = Path.of(System.getProperty("iris.nativeStructurePostProcessorSource")).getParent();
|
||||
Path nativegen = Path.of(System.getProperty("iris.nativeStructureFitBridgeSource")).getParent();
|
||||
String factory = Files.readString(nativegen.resolve("NativeStructureFactory.java")).replace("\r\n", "\n");
|
||||
String injector = Files.readString(nativegen.resolve("NativeStructureStartInjector.java")).replace("\r\n", "\n");
|
||||
String recovery = Files.readString(nativegen.resolve("NativeStructureOwnershipRecovery.java")).replace("\r\n", "\n");
|
||||
|
||||
+3
-26
@@ -45,7 +45,7 @@ public class IrisChunkGeneratorMonumentLocateContractTest {
|
||||
int reachabilityStart = source.indexOf("private Set<String> reachableStructureKeys", filterStart);
|
||||
assertTrue(reachabilityStart > filterStart);
|
||||
String filterMethod = source.substring(filterStart, reachabilityStart);
|
||||
int policyFilter = filterMethod.indexOf("if (!decision.generate())");
|
||||
int policyFilter = filterMethod.indexOf("if (!NativeStructureGenerationPolicy.generates(engine, key))");
|
||||
int filterContinue = filterMethod.indexOf("continue;", policyFilter);
|
||||
int emptyNativePartition = filterMethod.indexOf("if (candidates.isEmpty())", filterContinue);
|
||||
int reachabilityLookup = filterMethod.indexOf("reachableStructureKeys(level)", emptyNativePartition);
|
||||
@@ -119,7 +119,7 @@ public class IrisChunkGeneratorMonumentLocateContractTest {
|
||||
|
||||
@Test
|
||||
public void nativePredictionIsReadOnlyUntilTheWinnerIsCommitted() throws IOException {
|
||||
Path nativegen = Path.of(System.getProperty("iris.nativeStructurePostProcessorSource")).getParent();
|
||||
Path nativegen = Path.of(System.getProperty("iris.nativeStructureFitBridgeSource")).getParent();
|
||||
String source = Files.readString(nativegen.resolve("NativeStructureVanillaLocator.java")).replace("\r\n", "\n");
|
||||
int predictionStart = source.indexOf("private static Candidate predictAt(");
|
||||
int candidateStart = source.indexOf("public static final class Candidate", predictionStart);
|
||||
@@ -131,33 +131,10 @@ public class IrisChunkGeneratorMonumentLocateContractTest {
|
||||
assertTrue(candidate.contains("committed.compareAndSet(false, true)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stiltSupportUsesPlacedSolidOccupancyWithoutSnapshotDifferenceRequirement() throws IOException {
|
||||
Path processor = Path.of(System.getProperty("iris.nativeStructurePostProcessorSource"));
|
||||
String source = Files.readString(processor).replace("\r\n", "\n");
|
||||
String foundation = Files.readString(
|
||||
processor.resolveSibling("NativeStructureFoundationBuilder.java")).replace("\r\n", "\n");
|
||||
int placement = source.indexOf("start.placeInChunk(world, structureManager, generator");
|
||||
int stiltPlacement = source.indexOf("placeStilts(world, area, structureId, start", placement);
|
||||
int stiltDefinition = foundation.indexOf("static void placeStilts(");
|
||||
int occupancyCheck = foundation.indexOf("if (state.isSolid())", stiltDefinition);
|
||||
int terrainFloor = foundation.indexOf("Math.max(terrainY,", stiltDefinition);
|
||||
|
||||
assertTrue(placement >= 0);
|
||||
assertTrue(stiltPlacement > placement);
|
||||
assertTrue(stiltDefinition >= 0);
|
||||
assertTrue(occupancyCheck > stiltDefinition);
|
||||
assertTrue(terrainFloor > stiltDefinition);
|
||||
assertFalse(source.contains("state.equals("));
|
||||
assertFalse(foundation.contains("state.equals("));
|
||||
assertFalse(source.contains("snapshot.states"));
|
||||
assertFalse(foundation.contains("snapshot.states"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verticalPlacementMovesPiecesMonumentChildrenJigsawJunctionsAndCachedBoundsTogether() throws IOException {
|
||||
String source = Files.readString(
|
||||
Path.of(System.getProperty("iris.nativeStructurePostProcessorSource"))
|
||||
Path.of(System.getProperty("iris.nativeStructureFitBridgeSource"))
|
||||
.resolveSibling("NativeStructureVerticalPlacer.java")).replace("\r\n", "\n");
|
||||
int placementStart = source.indexOf("public static int applyVerticalPlacement");
|
||||
int shiftStart = source.indexOf("public static int applyVerticalShift", placementStart);
|
||||
|
||||
+6
-5
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConfiguration;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.framework.NativeJigsawOverrides;
|
||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
@@ -98,7 +98,8 @@ public class NativeStructureFactoryTest {
|
||||
new Structure.StructureSettings(HolderSet.empty()));
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> NativeStructureFactory.configure(
|
||||
null, source, new IrisJigsawConfiguration(), false, 80));
|
||||
null, source, new NativeJigsawOverrides("", "", null, null, null, null,
|
||||
NativeJigsawOverrides.SOURCE, null, null, NativeJigsawOverrides.SOURCE), false, 80));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -303,11 +304,11 @@ public class NativeStructureFactoryTest {
|
||||
);
|
||||
|
||||
StructureStart boundaryResult = NativeStructureReferenceEnvelope.wrapForPublication(
|
||||
boundary, source, 0, new IrisStructureTerrain(), "test:boundary_content");
|
||||
boundary, source, 0, List.of(NativeStructureReach.PLATFORM), "test:boundary_content");
|
||||
|
||||
StructureStart result = NativeStructureReferenceEnvelope.wrapForPublication(
|
||||
oversized, source, 0,
|
||||
new IrisStructureTerrain(),
|
||||
List.of(NativeStructureReach.PLATFORM),
|
||||
"test:oversized_content");
|
||||
|
||||
assertTrue(boundaryResult.isValid());
|
||||
|
||||
+1218
File diff suppressed because it is too large.
Load diff
+23
-27
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecision;
|
||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -61,12 +61,15 @@ import static org.junit.Assert.assertTrue;
|
||||
* starts with real pieces and inline templates, and fit records written the way ownership records persist them. It
|
||||
* then runs the chunk's fit in the generator's order (terrain fitting for every start, then each start's pieces and
|
||||
* stilts, then the foundation repair) with a fixed stand-in for the platform's piece placement, and hashes every block
|
||||
* that differs from the untouched terrain.
|
||||
* that differs from the untouched terrain. The hashes were taken from the platform-side fit before it moved into the
|
||||
* structure module; they now run through the platform bridge and the built-in modules.
|
||||
*/
|
||||
public class NativeStructureFitPinTest {
|
||||
private static final long WORLD_SEED = 8675309L;
|
||||
private static final int SEA_LEVEL = 61;
|
||||
private static final BoundingBox CHUNK_AREA = new BoundingBox(0, -63, 0, 15, 318, 15);
|
||||
private static final int WORLD_MIN_Y = -64;
|
||||
private static final int WORLD_HEIGHT = 384;
|
||||
private static final BoundingBox CHUNK_AREA = new BoundingBox(0, WORLD_MIN_Y + 1, 0, 15, WORLD_MIN_Y + WORLD_HEIGHT - 2, 15);
|
||||
private static final String NO_STILTS = "null";
|
||||
private static final String SOURCE_TERRAIN = "{}";
|
||||
|
||||
@@ -117,35 +120,27 @@ public class NativeStructureFitPinTest {
|
||||
return terrain.changedBlocksHash(CHUNK_AREA);
|
||||
}
|
||||
|
||||
/** The chunk's fit in the order the generators run it; the platform's placement is {@link #placePieces}. */
|
||||
/**
|
||||
* The chunk's fit in the order the generators run it, through the platform bridge and the built-in modules: the
|
||||
* fit before any piece, then each start's pieces ({@link #placePieces}) and its fit after them.
|
||||
*/
|
||||
private static void fitChunk(WorldGenLevel world, Scenario scenario) {
|
||||
IntBinaryOperator surface = TerrainWorld::surfaceY;
|
||||
List<NativeStructureTerrainIntegrator.TerrainTarget> targets = new ArrayList<>();
|
||||
List<IrisNativeStructureDecision> decisions = new ArrayList<>();
|
||||
List<NativeStructureFitBridge.FitTarget> targets = new ArrayList<>();
|
||||
for (FitTarget target : scenario.targets()) {
|
||||
IrisNativeStructureDecision decision = new NativeStructureOwnershipRecord.DecisionSnapshot(
|
||||
target.stiltJson(), target.terrainJson()).restore();
|
||||
decisions.add(decision);
|
||||
targets.add(new NativeStructureTerrainIntegrator.TerrainTarget(target.structureId(), target.start(),
|
||||
NativeStructureTerrainIntegrator.resolveNativeTerrain(target.start(), decision.terrain())));
|
||||
targets.add(new NativeStructureFitBridge.FitTarget(target.structureId(), target.start(),
|
||||
new NativeStartMemo(target.terrainJson(), target.stiltJson())));
|
||||
}
|
||||
NativeStructureSurfaceFitter.VacuumFoundationPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, CHUNK_AREA, targets, surface);
|
||||
NativeStructurePostProcessor.prepareTerrain(world, CHUNK_AREA, targets, NativeStructureFitPinTest::noPalette);
|
||||
NativeStructureFitting.Session fit = BuiltInFitting.FITTING.beforePieces(
|
||||
NativeStructureFitBridge.chunk(world, CHUNK_AREA, targets, TerrainWorld::surfaceY));
|
||||
for (int index = 0; index < targets.size(); index++) {
|
||||
FitTarget target = scenario.targets().get(index);
|
||||
placePieces(world, target);
|
||||
if (decisions.get(index).stilt() != null) {
|
||||
NativeStructureFoundationBuilder.placeStilts(world, CHUNK_AREA, target.structureId(), target.start(),
|
||||
decisions.get(index).stilt(), NativeStructureFitPinTest::noPalette, surface,
|
||||
!NativeStructureVegetationClearer.isUndergroundStep(target.start().getStructure().step()));
|
||||
}
|
||||
placePieces(world, scenario.targets().get(index));
|
||||
fit.afterPieces(index);
|
||||
}
|
||||
NativeStructureSurfaceFitter.repairVacuumFoundations(world, CHUNK_AREA, plan);
|
||||
}
|
||||
|
||||
private static BlockState noPalette(Object palette, Object rng, int x, int y, int z) {
|
||||
throw new AssertionError("The pinned scenarios use the default fill blocks, never a palette");
|
||||
/** The built-in modules load once for every scenario. */
|
||||
private static final class BuiltInFitting {
|
||||
private static final NativeStructureFitting FITTING = NativeStructureFitting.builtInModules();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -541,7 +536,8 @@ public class NativeStructureFitPinTest {
|
||||
yield true;
|
||||
}
|
||||
case "getSeed" -> WORLD_SEED;
|
||||
case "getHeight" -> heightmapY((int) arguments[1], (int) arguments[2]);
|
||||
case "getMinY" -> WORLD_MIN_Y;
|
||||
case "getHeight" -> arguments == null ? WORLD_HEIGHT : heightmapY((int) arguments[1], (int) arguments[2]);
|
||||
case "getLevel" -> null;
|
||||
case "holderLookup" -> BuiltInRegistries.BLOCK;
|
||||
case "hashCode" -> System.identityHashCode(proxy);
|
||||
|
||||
+50
-46
@@ -1,8 +1,6 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureYBand;
|
||||
import com.google.gson.Gson;
|
||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
@@ -21,6 +19,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
@@ -30,15 +29,18 @@ import static org.junit.Assert.assertEquals;
|
||||
/**
|
||||
* Pins where the platform's own starts end up vertically for each adjustment the dimension can give them (shift,
|
||||
* band, keeping the platform's height, burial under the terrain), and which chunks a start reaches for each terrain
|
||||
* fit, so both can move without changing what a world generates.
|
||||
* fit. The values were taken before the fit moved into the structure module; since then the module answers the shift
|
||||
* and the reach ({@code StartLayoutsPinTest} in core pins those answers for the same starts) and the platform side,
|
||||
* pinned here, aligns, moves and references the starts with them.
|
||||
*/
|
||||
public class NativeStructureLayoutPinTest {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final int SEA_LEVEL = 61;
|
||||
private static final int WORLD_MIN_Y = -64;
|
||||
private static final int WORLD_MAX_Y_EXCLUSIVE = 320;
|
||||
private static final IntBinaryOperator SURFACE = (x, z) -> 62 + Math.floorMod(x * 7 + z * 3, 11) - 5;
|
||||
private static final int[][] CHUNKS = {{0, 0}, {3, -5}, {-11, 7}};
|
||||
private static final Map<String, Integer> ADJUSTMENT_SHIFTS = adjustmentShifts();
|
||||
private static final Map<String, NativeStructureReach> TERRAIN_REACHES = terrainReaches();
|
||||
|
||||
private static final List<String> PINNED_SHIFTS = List.of(
|
||||
"none minecraft:stronghold 0,0 offset 0 minY 50",
|
||||
@@ -118,63 +120,68 @@ public class NativeStructureLayoutPinTest {
|
||||
Bootstrap.bootStrap();
|
||||
}
|
||||
|
||||
/**
|
||||
* The module's shift for a stronghold is the move it makes; for a desert temple, which the platform aligns to the
|
||||
* terrain itself, it is the adjustment's own shift on top of that alignment.
|
||||
*/
|
||||
@Test
|
||||
public void platformStartsMoveWhereTheirAdjustmentSays() {
|
||||
List<String> actual = new ArrayList<>();
|
||||
for (Adjustment adjustment : adjustments()) {
|
||||
for (int[] chunkXZ : CHUNKS) {
|
||||
ChunkPos chunk = new ChunkPos(chunkXZ[0], chunkXZ[1]);
|
||||
for (String structureId : List.of("minecraft:stronghold", "minecraft:desert_pyramid")) {
|
||||
StructureStart start = start(chunk, structureId.equals("minecraft:stronghold") ? 50 : 64,
|
||||
TerrainAdjustment.NONE);
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(start, structureId,
|
||||
adjustment.yShift(), SEA_LEVEL, WORLD_MIN_Y, WORLD_MAX_Y_EXCLUSIVE, adjustment.underground(),
|
||||
adjustment.keepsSourceY(), band(adjustment.bandJson()), SURFACE);
|
||||
actual.add(adjustment.name() + " " + structureId + " " + chunk.x() + "," + chunk.z()
|
||||
+ " offset " + offset + " minY " + start.getBoundingBox().minY());
|
||||
}
|
||||
}
|
||||
for (String pinned : PINNED_SHIFTS) {
|
||||
String[] parts = pinned.split(" ");
|
||||
String structureId = parts[1];
|
||||
String[] chunkXZ = parts[2].split(",");
|
||||
ChunkPos chunk = new ChunkPos(Integer.parseInt(chunkXZ[0]), Integer.parseInt(chunkXZ[1]));
|
||||
boolean stronghold = structureId.equals("minecraft:stronghold");
|
||||
int moduleShift = stronghold ? Integer.parseInt(parts[4]) : ADJUSTMENT_SHIFTS.get(parts[0]);
|
||||
StructureStart start = start(chunk, stronghold ? 50 : 64, TerrainAdjustment.NONE);
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(start, structureId, moduleShift,
|
||||
SEA_LEVEL, WORLD_MIN_Y, WORLD_MAX_Y_EXCLUSIVE, SURFACE);
|
||||
actual.add(parts[0] + " " + structureId + " " + parts[2] + " offset " + offset
|
||||
+ " minY " + start.getBoundingBox().minY());
|
||||
}
|
||||
assertEquals("Pinned shifts changed:\n" + String.join("\n", quoted(actual)), PINNED_SHIFTS, actual);
|
||||
assertEquals(PINNED_SHIFTS, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startsReachTheChunksTheirTerrainFitSays() {
|
||||
List<String> actual = new ArrayList<>();
|
||||
for (String terrainJson : List.of("{}", "{\"mode\":\"PRESERVE\"}", "{\"mode\":\"VACUUM\"}",
|
||||
"{\"mode\":\"ENCASE\",\"horizontalPadding\":4}", "{\"mode\":\"BORE\",\"horizontalPadding\":20}",
|
||||
"{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":112}", "{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":0}")) {
|
||||
for (Map.Entry<String, NativeStructureReach> fit : TERRAIN_REACHES.entrySet()) {
|
||||
for (TerrainAdjustment adjustment : List.of(TerrainAdjustment.NONE, TerrainAdjustment.BEARD_THIN, TerrainAdjustment.BURY)) {
|
||||
StructureStart start = start(new ChunkPos(2, -3), 40, adjustment);
|
||||
BoundingBox bounds = NativeStructureReferenceEnvelope.referenceBounds(start, start.getStructure(),
|
||||
NativeStructureTerrainIntegrator.resolveNativeTerrain(start,
|
||||
new NativeStructureOwnershipRecord.DecisionSnapshot("null", terrainJson).restore().terrain()),
|
||||
"minecraft:village_plains");
|
||||
actual.add(terrainJson + " " + adjustment + " " + bounds.minX() + "," + bounds.minY() + "," + bounds.minZ()
|
||||
List.of(fit.getValue()), "minecraft:village_plains");
|
||||
actual.add(fit.getKey() + " " + adjustment + " " + bounds.minX() + "," + bounds.minY() + "," + bounds.minZ()
|
||||
+ " " + bounds.maxX() + "," + bounds.maxY() + "," + bounds.maxZ());
|
||||
}
|
||||
}
|
||||
assertEquals("Pinned reaches changed:\n" + String.join("\n", quoted(actual)), PINNED_REACHES, actual);
|
||||
assertEquals(PINNED_REACHES, actual);
|
||||
}
|
||||
|
||||
private static List<String> quoted(List<String> lines) {
|
||||
return lines.stream().map(line -> " \"" + line.replace("\"", "\\\"") + "\",").toList();
|
||||
private static Map<String, Integer> adjustmentShifts() {
|
||||
Map<String, Integer> shifts = new LinkedHashMap<>();
|
||||
shifts.put("none", 0);
|
||||
shifts.put("shift", 5);
|
||||
shifts.put("burial", -7);
|
||||
shifts.put("burial-unshifted", 0);
|
||||
shifts.put("kept", 3);
|
||||
shifts.put("band", 0);
|
||||
shifts.put("narrow-band", 4);
|
||||
shifts.put("kept-over-band", 2);
|
||||
return shifts;
|
||||
}
|
||||
|
||||
private static List<Adjustment> adjustments() {
|
||||
return List.of(
|
||||
new Adjustment("none", 0, null, false, false),
|
||||
new Adjustment("shift", 5, null, false, false),
|
||||
new Adjustment("burial", -7, null, false, true),
|
||||
new Adjustment("burial-unshifted", 0, null, false, true),
|
||||
new Adjustment("kept", 3, null, true, true),
|
||||
new Adjustment("band", 0, "{\"min\":-50,\"max\":20}", false, true),
|
||||
new Adjustment("narrow-band", 4, "{\"min\":10,\"max\":12}", false, false),
|
||||
new Adjustment("kept-over-band", 2, "{\"min\":-40,\"max\":80}", true, false));
|
||||
}
|
||||
|
||||
private static IrisStructureYBand band(String json) {
|
||||
return json == null ? null : GSON.fromJson(json, IrisStructureYBand.class);
|
||||
/** What the structure module answers for each terrain fit (pinned in core by {@code StartLayoutsPinTest}). */
|
||||
private static Map<String, NativeStructureReach> terrainReaches() {
|
||||
Map<String, NativeStructureReach> reaches = new LinkedHashMap<>();
|
||||
reaches.put("{}", NativeStructureReach.PLATFORM);
|
||||
reaches.put("{\"mode\":\"PRESERVE\"}", new NativeStructureReach(false, 0));
|
||||
reaches.put("{\"mode\":\"VACUUM\"}", new NativeStructureReach(false, 12));
|
||||
reaches.put("{\"mode\":\"ENCASE\",\"horizontalPadding\":4}", new NativeStructureReach(false, 4));
|
||||
reaches.put("{\"mode\":\"BORE\",\"horizontalPadding\":20}", new NativeStructureReach(false, 20));
|
||||
reaches.put("{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":112}", new NativeStructureReach(false, 112));
|
||||
reaches.put("{\"mode\":\"FORCE_CARVE\",\"horizontalPadding\":0}", new NativeStructureReach(false, 0));
|
||||
return reaches;
|
||||
}
|
||||
|
||||
private static StructureStart start(ChunkPos chunk, int minY, TerrainAdjustment adjustment) {
|
||||
@@ -184,7 +191,4 @@ public class NativeStructureLayoutPinTest {
|
||||
piece.move(0, minY - piece.getBoundingBox().minY(), 0);
|
||||
return new StructureStart(structure, chunk, 0, new PiecesContainer(List.of(piece)));
|
||||
}
|
||||
|
||||
private record Adjustment(String name, int yShift, String bandJson, boolean keepsSourceY, boolean underground) {
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -4,8 +4,8 @@ import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrainMode;
|
||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -63,9 +63,7 @@ public class NativeStructureOwnershipFingerprintTest {
|
||||
NativeStructureVerticalPlacer.alignOceanMonumentToSeaLevel(
|
||||
generated, 0, 80, -64, 320);
|
||||
int alignedLocatorY = NativeStructureOwnershipFingerprint.locatorY(generated);
|
||||
IrisStructureTerrain terrain = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.FORCE_CARVE)
|
||||
.setHorizontalPadding(24);
|
||||
List<NativeStructureReach> terrain = List.of(new NativeStructureReach(false, 24));
|
||||
StructureStart wrapped = NativeStructureReferenceEnvelope.wrap(
|
||||
generated,
|
||||
structure,
|
||||
@@ -127,9 +125,7 @@ public class NativeStructureOwnershipFingerprintTest {
|
||||
StructureStart generated = monumentStart(structure, origin, seed);
|
||||
NativeStructureVerticalPlacer.alignOceanMonumentToSeaLevel(
|
||||
generated, 0, 80, -64, 320);
|
||||
IrisStructureTerrain terrain = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.FORCE_CARVE)
|
||||
.setHorizontalPadding(24);
|
||||
List<NativeStructureReach> terrain = List.of(new NativeStructureReach(false, 24));
|
||||
StructureStart wrapped = NativeStructureReferenceEnvelope.wrap(
|
||||
generated,
|
||||
structure,
|
||||
@@ -247,7 +243,7 @@ public class NativeStructureOwnershipFingerprintTest {
|
||||
private static NativeStructureStartPlan plan(ChunkPos origin, int baseY) {
|
||||
return new NativeStructureStartPlan("minecraft:monument", origin.x(), origin.z(), baseY, false, false,
|
||||
StructurePlacementGrid.placementIdentity(new IrisStructurePlacement().setPlacementId("monument-test")),
|
||||
null, null, new IrisStructureTerrain());
|
||||
null, new NativeStartMemo("{\"mode\":\"SOURCE\"}", "null"));
|
||||
}
|
||||
|
||||
private static NativeStructureOwnershipRecord ownership(
|
||||
@@ -257,7 +253,7 @@ public class NativeStructureOwnershipFingerprintTest {
|
||||
start,
|
||||
plan(origin, NativeStructureReferenceEnvelope.contentBounds(start).minY()),
|
||||
NativeStructureReferenceEnvelope.referenceBounds(
|
||||
start, structure, new IrisStructureTerrain())
|
||||
start, structure, List.of(NativeStructureReach.PLATFORM))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+47
-32
@@ -3,9 +3,9 @@ package art.arcane.iris.nativegen;
|
||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrainMode;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderSet;
|
||||
@@ -61,7 +61,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
NativeStructureOwnershipRecord recovered =
|
||||
NativeStructureOwnershipRecovery.proveCandidate(
|
||||
"minecraft:monument", structure, reloaded,
|
||||
plan, expected, false);
|
||||
plan, expected, false, reaches(plan));
|
||||
|
||||
assertNotNull(recovered);
|
||||
assertEquals(plan.placementIdentity(),
|
||||
@@ -69,9 +69,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
assertEquals(expectedLocatorY, recovered.locatorY());
|
||||
assertNotEquals(NativeStructureOwnershipFingerprint.locatorY(reloaded),
|
||||
recovered.locatorY());
|
||||
assertEquals(IrisStructureTerrainMode.FORCE_CARVE,
|
||||
recovered.restoredDecision().terrain().resolvedMode());
|
||||
assertEquals(24, recovered.restoredDecision().terrain().getHorizontalPadding());
|
||||
assertEquals(plan.memo(), recovered.restoredMemo());
|
||||
assertTrue(recovered.referenceMinChunkX()
|
||||
< NativeStructureReferenceEnvelope.contentBounds(reloaded).minX() >> 4);
|
||||
}
|
||||
@@ -87,7 +85,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
NativeStructureOwnershipRecord recovered =
|
||||
NativeStructureOwnershipRecovery.proveCandidate(
|
||||
"minecraft:monument", structure, natural,
|
||||
plan, natural, true);
|
||||
plan, natural, true, reaches(plan));
|
||||
|
||||
assertNull(recovered);
|
||||
}
|
||||
@@ -112,10 +110,10 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
changedIdentity.placementIdentity());
|
||||
assertNull(NativeStructureOwnershipRecovery.proveCandidate(
|
||||
"minecraft:monument", structure, expected,
|
||||
changedIdentity, expected, false));
|
||||
changedIdentity, expected, false, reaches(changedIdentity)));
|
||||
assertNull(NativeStructureOwnershipRecovery.proveCandidate(
|
||||
"minecraft:monument", structure, changedGeometry,
|
||||
plan(origin, "geometry-check", 0), expected, false));
|
||||
plan(origin, "geometry-check", 0), expected, false, reaches(plan(origin, "geometry-check", 0))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,7 +125,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
NativeStructureOwnershipRecord recovered =
|
||||
NativeStructureOwnershipRecovery.proveCandidate(
|
||||
"minecraft:monument", structure, expected,
|
||||
plan(origin, "fingerprint-check", 16), expected, false);
|
||||
plan(origin, "fingerprint-check", 16), expected, false, reaches(plan(origin, "fingerprint-check", 16)));
|
||||
assertNotNull(recovered);
|
||||
|
||||
StructureStart moved = monumentStart(structure, origin, seed);
|
||||
@@ -146,14 +144,14 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
OceanMonumentStructure structure = structure();
|
||||
StructureStart start = monumentStart(structure, origin, seed);
|
||||
NativeStructureStartPlan plan = plan(
|
||||
origin, "vacuum-envelope-refresh", IrisStructureTerrainMode.VACUUM, 0);
|
||||
origin, "vacuum-envelope-refresh", "VACUUM", 0);
|
||||
BoundingBox content = NativeStructureReferenceEnvelope.contentBounds(start);
|
||||
NativeStructureOwnershipRecord stale = NativeStructureOwnershipFingerprint.capture(
|
||||
structureKey, start, plan, content);
|
||||
|
||||
NativeStructureOwnershipRecord refreshed =
|
||||
NativeStructureOwnershipRecovery.refreshReferenceEnvelope(
|
||||
structureKey, structure, start, stale);
|
||||
structureKey, structure, start, stale, reaches(plan));
|
||||
|
||||
assertNotNull(refreshed);
|
||||
assertNotEquals(stale, refreshed);
|
||||
@@ -163,18 +161,16 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
assertEquals(stale.baseY(), refreshed.baseY());
|
||||
assertEquals(stale.locatorY(), refreshed.locatorY());
|
||||
assertEquals(stale.contentFingerprint(), refreshed.contentFingerprint());
|
||||
assertEquals(stale.decision(), refreshed.decision());
|
||||
assertEquals(IrisStructureTerrainMode.VACUUM,
|
||||
refreshed.restoredDecision().terrain().resolvedMode());
|
||||
assertEquals(stale.memo(), refreshed.memo());
|
||||
BoundingBox expected = NativeStructureReferenceEnvelope.referenceBounds(
|
||||
start, structure, plan.terrain(), structureKey);
|
||||
start, structure, reaches(plan), structureKey);
|
||||
assertEquals(expected.minX() >> 4, refreshed.referenceMinChunkX());
|
||||
assertEquals(expected.maxX() >> 4, refreshed.referenceMaxChunkX());
|
||||
assertEquals(expected.minZ() >> 4, refreshed.referenceMinChunkZ());
|
||||
assertEquals(expected.maxZ() >> 4, refreshed.referenceMaxChunkZ());
|
||||
assertTrue(hasExpandedCoverage(stale, refreshed));
|
||||
assertSame(refreshed, NativeStructureOwnershipRecovery.refreshReferenceEnvelope(
|
||||
structureKey, structure, start, refreshed));
|
||||
structureKey, structure, start, refreshed, reaches(plan)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,7 +181,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
OceanMonumentStructure structure = structure();
|
||||
StructureStart expected = monumentStart(structure, origin, seed);
|
||||
NativeStructureStartPlan plan = plan(
|
||||
origin, "vacuum-content-check", IrisStructureTerrainMode.VACUUM, 0);
|
||||
origin, "vacuum-content-check", "VACUUM", 0);
|
||||
NativeStructureOwnershipRecord stale = NativeStructureOwnershipFingerprint.capture(
|
||||
structureKey, expected, plan,
|
||||
NativeStructureReferenceEnvelope.contentBounds(expected));
|
||||
@@ -195,7 +191,7 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
}
|
||||
|
||||
assertNull(NativeStructureOwnershipRecovery.refreshReferenceEnvelope(
|
||||
structureKey, structure, moved, stale));
|
||||
structureKey, structure, moved, stale, reaches(plan)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,12 +203,27 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
StructureStart start = monumentStart(structure, origin, seed);
|
||||
NativeStructureStartPlan plan = plan(origin, "current-force-carve", 24);
|
||||
BoundingBox envelope = NativeStructureReferenceEnvelope.referenceBounds(
|
||||
start, structure, plan.terrain(), structureKey);
|
||||
start, structure, reaches(plan), structureKey);
|
||||
NativeStructureOwnershipRecord ownership = NativeStructureOwnershipFingerprint.capture(
|
||||
structureKey, start, plan, envelope);
|
||||
|
||||
assertSame(ownership, NativeStructureOwnershipRecovery.refreshReferenceEnvelope(
|
||||
structureKey, structure, start, ownership));
|
||||
structureKey, structure, start, ownership, reaches(plan)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRecordedEnvelopeWiderThanTodaysReachNeverShrinks() {
|
||||
String structureKey = "minecraft:monument";
|
||||
long seed = 927451L;
|
||||
ChunkPos origin = new ChunkPos(3, 8);
|
||||
OceanMonumentStructure structure = structure();
|
||||
StructureStart start = monumentStart(structure, origin, seed);
|
||||
NativeStructureStartPlan plan = plan(origin, "wide-force-carve", 24);
|
||||
NativeStructureOwnershipRecord ownership = NativeStructureOwnershipFingerprint.capture(structureKey, start, plan,
|
||||
NativeStructureReferenceEnvelope.referenceBounds(start, structure, reaches(plan), structureKey));
|
||||
|
||||
assertSame(ownership, NativeStructureOwnershipRecovery.refreshReferenceEnvelope(
|
||||
structureKey, structure, start, ownership, List.of(NativeStructureReach.PLATFORM)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -230,16 +241,16 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
piece.move(shiftX, 0, 0);
|
||||
}
|
||||
NativeStructureStartPlan plan = plan(
|
||||
origin, "clipped-vacuum", IrisStructureTerrainMode.VACUUM, 0);
|
||||
origin, "clipped-vacuum", "VACUUM", 0);
|
||||
BoundingBox envelope = NativeStructureReferenceEnvelope.referenceBounds(
|
||||
start, structure, plan.terrain(), structureKey);
|
||||
start, structure, reaches(plan), structureKey);
|
||||
NativeStructureOwnershipRecord ownership = NativeStructureOwnershipFingerprint.capture(
|
||||
structureKey, start, plan, envelope);
|
||||
|
||||
assertEquals(origin.x() + NativeStructureOwnershipRecord.MAX_REFERENCE_DISTANCE_CHUNKS,
|
||||
ownership.referenceMaxChunkX());
|
||||
assertSame(ownership, NativeStructureOwnershipRecovery.refreshReferenceEnvelope(
|
||||
structureKey, structure, start, ownership));
|
||||
structureKey, structure, start, ownership, reaches(plan)));
|
||||
}
|
||||
|
||||
private static OceanMonumentStructure structure() {
|
||||
@@ -267,17 +278,15 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
private static NativeStructureStartPlan plan(ChunkPos origin,
|
||||
String placementId,
|
||||
int horizontalPadding) {
|
||||
return plan(origin, placementId,
|
||||
IrisStructureTerrainMode.FORCE_CARVE, horizontalPadding);
|
||||
return plan(origin, placementId, "FORCE_CARVE", horizontalPadding);
|
||||
}
|
||||
|
||||
/** A start the structure module placed with a terrain fit of {@code terrainMode}, as its memo records it. */
|
||||
private static NativeStructureStartPlan plan(ChunkPos origin,
|
||||
String placementId,
|
||||
IrisStructureTerrainMode terrainMode,
|
||||
String terrainMode,
|
||||
int horizontalPadding) {
|
||||
IrisStructureTerrain terrain = new IrisStructureTerrain()
|
||||
.setMode(terrainMode)
|
||||
.setHorizontalPadding(horizontalPadding);
|
||||
String terrain = "{\"mode\":\"" + terrainMode + "\",\"horizontalPadding\":" + horizontalPadding + "}";
|
||||
return new NativeStructureStartPlan(
|
||||
"minecraft:monument",
|
||||
origin.x(),
|
||||
@@ -288,11 +297,17 @@ public class NativeStructureOwnershipRecoveryTest {
|
||||
false,
|
||||
StructurePlacementGrid.placementIdentity(new IrisStructurePlacement().setPlacementId(placementId)),
|
||||
null,
|
||||
null,
|
||||
terrain
|
||||
new NativeStartMemo(terrain, "null")
|
||||
);
|
||||
}
|
||||
|
||||
/** The reach the structure module gives the plan's terrain fit: VACUUM its 12-block falloff, else the padding. */
|
||||
private static List<NativeStructureReach> reaches(NativeStructureStartPlan plan) {
|
||||
String terrain = plan.memo().terrain();
|
||||
int padding = Integer.parseInt(terrain.replaceAll(".*\"horizontalPadding\":(\\d+).*", "$1"));
|
||||
return List.of(new NativeStructureReach(false, terrain.contains("VACUUM") ? 12 : padding));
|
||||
}
|
||||
|
||||
private static boolean hasExpandedCoverage(
|
||||
NativeStructureOwnershipRecord stale,
|
||||
NativeStructureOwnershipRecord refreshed) {
|
||||
|
||||
-547
@@ -1,547 +0,0 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrainMode;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureYBand;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.TerrainAdjustment;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.PiecesContainer;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.DesertPyramidPiece;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.DesertPyramidStructure;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.LiquidSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class NativeStructurePostProcessorEncaseTest {
|
||||
private static final long TEST_SEED = 1234L;
|
||||
|
||||
@BeforeClass
|
||||
public static void bootstrapMinecraft() {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encaseFillsAirAndLiquidWithoutOverwritingExistingTerrain() {
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox bounds = start.getPieces().getFirst().getBoundingBox();
|
||||
BoundingBox area = new BoundingBox(
|
||||
bounds.minX() - 1, bounds.minY() - 1, bounds.minZ() - 1,
|
||||
bounds.maxX() + 1, bounds.maxY() + 1, bounds.maxZ() + 1);
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
put(blocks, bounds.minX(), bounds.minY(), bounds.minZ(), Blocks.DIRT.defaultBlockState());
|
||||
put(blocks, bounds.maxX(), bounds.minY(), bounds.maxZ(), Blocks.WATER.defaultBlockState());
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "minecraft:stronghold", start,
|
||||
new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.ENCASE)
|
||||
.setHorizontalPadding(1)
|
||||
.setCeilingPadding(1)
|
||||
.setFloorPadding(1),
|
||||
null);
|
||||
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.maxX(), bounds.minY(), bounds.maxZ()));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 1, bounds.minY() - 1, bounds.minZ() - 1));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.maxX() + 1, bounds.maxY() + 1, bounds.maxZ() + 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultEncasePaletteSplitsStoneAboveZeroAndDeepslateBelow() {
|
||||
StructureStart start = start(TerrainAdjustment.BURY, -1);
|
||||
BoundingBox bounds = start.getPieces().getFirst().getBoundingBox();
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), bounds, "minecraft:stronghold", start,
|
||||
new IrisStructureTerrain().setMode(IrisStructureTerrainMode.ENCASE),
|
||||
null);
|
||||
|
||||
assertEquals(-1, bounds.minY());
|
||||
assertEquals(Blocks.DEEPSLATE.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), -1, bounds.minZ()));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), 0, bounds.minZ()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultEncaseMaterialFollowsVanillaDimensionTerrain() {
|
||||
assertEquals(Blocks.NETHERRACK.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.defaultEncaseBlock(Level.NETHER, 64));
|
||||
assertEquals(Blocks.END_STONE.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.defaultEncaseBlock(Level.END, 64));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.defaultEncaseBlock(Level.OVERWORLD, 64));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceEncaseMaterialFollowsNearbyIrisTerrain() {
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
BlockPos fill = new BlockPos(4, 64, 8);
|
||||
put(blocks, fill.getX() + 3, fill.getY(), fill.getZ(), Blocks.TUFF.defaultBlockState());
|
||||
|
||||
assertEquals(Blocks.TUFF.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.sourceEncaseBlock(world(blocks), fill));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceMaterialSnapshotIgnoresPreviouslyDecoratedAdjacentChunks() {
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
BlockPos fill = new BlockPos(0, 64, 8);
|
||||
put(blocks, -1, 64, 8, Blocks.OAK_PLANKS.defaultBlockState());
|
||||
put(blocks, 3, 64, 8, Blocks.TUFF.defaultBlockState());
|
||||
WorldGenLevel world = world(blocks);
|
||||
NativeStructureTerrainIntegrator.SourceTerrainSnapshot sourceTerrain =
|
||||
sourceSnapshot(world, new BoundingBox(0, 64, 0, 15, 64, 15));
|
||||
|
||||
assertEquals(Blocks.TUFF.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.sourceEncaseBlock(
|
||||
world, fill, sourceTerrain));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceMaterialSnapshotIsStableAcrossEarlierFillsInTheSameChunk() {
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
BlockPos fill = new BlockPos(0, 64, 8);
|
||||
put(blocks, 3, 64, 8, Blocks.TUFF.defaultBlockState());
|
||||
WorldGenLevel world = world(blocks);
|
||||
NativeStructureTerrainIntegrator.SourceTerrainSnapshot sourceTerrain =
|
||||
sourceSnapshot(world, new BoundingBox(0, 64, 0, 15, 64, 15));
|
||||
put(blocks, 1, 64, 8, Blocks.OAK_PLANKS.defaultBlockState());
|
||||
|
||||
assertEquals(Blocks.TUFF.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.sourceEncaseBlock(
|
||||
world, fill, sourceTerrain));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceMaterialRejectsStructureBlocksAndOresBeforeDimensionFallback() {
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
BlockPos fill = new BlockPos(4, -20, 8);
|
||||
put(blocks, 3, -20, 8, Blocks.OAK_PLANKS.defaultBlockState());
|
||||
put(blocks, 5, -20, 8, Blocks.STONE_BRICKS.defaultBlockState());
|
||||
put(blocks, 4, -20, 7, Blocks.IRON_ORE.defaultBlockState());
|
||||
|
||||
assertEquals(Blocks.DEEPSLATE.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.sourceEncaseBlock(world(blocks), fill));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceMaterialSnapshotOnlyAllocatesActualFillLayers() {
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox area = new BoundingBox(0, -2032, 0, 15, 2030, 15);
|
||||
NativeStructureTerrainIntegrator.SourceTerrainSnapshot sourceTerrain =
|
||||
NativeStructureTerrainIntegrator.captureSourceTerrain(
|
||||
world(new HashMap<>()), area,
|
||||
List.of(new NativeStructureTerrainIntegrator.TerrainTarget(
|
||||
"test:bounded-snapshot", start,
|
||||
new IrisStructureTerrain().setMode(IrisStructureTerrainMode.SOURCE))));
|
||||
|
||||
assertNotNull(sourceTerrain);
|
||||
assertEquals(23 * 16 * 16, sourceTerrain.sampledCells());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customDimensionKeyUsesRegisteredVanillaDimensionType() {
|
||||
ResourceKey<Level> customDimension = ResourceKey.create(
|
||||
Registries.DIMENSION, Identifier.parse("iris:custom_nether"));
|
||||
|
||||
assertEquals(Blocks.NETHERRACK.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.defaultEncaseBlock(
|
||||
customDimension, BuiltinDimensionTypes.NETHER, null, 64));
|
||||
assertEquals(Blocks.END_STONE.defaultBlockState(),
|
||||
NativeStructureTerrainIntegrator.defaultEncaseBlock(
|
||||
customDimension, BuiltinDimensionTypes.END, null, 64));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configuredEncasePaletteReplacesTheDefaultMaterial() {
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox bounds = start.getPieces().getFirst().getBoundingBox();
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
IrisMaterialPalette palette = new IrisMaterialPalette().qclear().qadd("minecraft:tuff");
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), bounds, "minecraft:stronghold", start,
|
||||
new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.ENCASE)
|
||||
.setEncasePalette(palette),
|
||||
NativeStructurePostProcessorEncaseTest::tuffBlock);
|
||||
|
||||
assertEquals(Blocks.TUFF.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encaseFillRunsBeforeNativePlacement() throws IOException {
|
||||
String source = Files.readString(Path.of(System.getProperty("iris.nmsChunkGeneratorSource"))).replace("\r\n", "\n");
|
||||
int prepareTerrain = source.indexOf("NativeStructurePostProcessor.prepareTerrain(");
|
||||
int placementLoop = source.indexOf("for (NativePlacementGroup group : placementGroups)", prepareTerrain);
|
||||
int placement = source.indexOf("placeVanillaStructure(world, structureManager, random", placementLoop);
|
||||
|
||||
assertTrue(prepareTerrain >= 0);
|
||||
assertTrue(placementLoop > prepareTerrain);
|
||||
assertTrue(placement > placementLoop);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void omittedTerrainConfigurationRetainsSourceSemantics() {
|
||||
for (TerrainAdjustment adjustment : TerrainAdjustment.values()) {
|
||||
IrisStructureTerrain resolved = NativeStructureTerrainIntegrator.resolveNativeTerrain(
|
||||
start(adjustment, 64), null);
|
||||
|
||||
assertEquals(IrisStructureTerrainMode.SOURCE, resolved.resolvedMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceBuryUsesTheVanillaSixByTwelveInfluenceEnvelope() {
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox bounds = start.getPieces().getFirst().getBoundingBox();
|
||||
int groundY = bounds.minY();
|
||||
BoundingBox area = new BoundingBox(
|
||||
bounds.minX() - 7, groundY - 13, bounds.minZ(),
|
||||
bounds.maxX(), groundY + 13, bounds.maxZ());
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "test:bury", start,
|
||||
new IrisStructureTerrain().setMode(IrisStructureTerrainMode.SOURCE), null);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 5, groundY, bounds.minZ()));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), groundY + 11, bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 6, groundY, bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), groundY + 12, bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 7, groundY, bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), groundY + 13, bounds.minZ()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceEncapsulateWrapsTheFullPieceBounds() {
|
||||
StructureStart start = start(TerrainAdjustment.ENCAPSULATE, 64);
|
||||
BoundingBox bounds = start.getPieces().getFirst().getBoundingBox();
|
||||
BoundingBox area = new BoundingBox(
|
||||
bounds.minX() - 13, bounds.minY(), bounds.minZ(),
|
||||
bounds.maxX(), bounds.maxY() + 13, bounds.maxZ());
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "test:encapsulate", start,
|
||||
new IrisStructureTerrain().setMode(IrisStructureTerrainMode.SOURCE), null);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 11, bounds.minY(), bounds.minZ()));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.maxY() + 11, bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 12, bounds.minY(), bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.maxY() + 12, bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 13, bounds.minY(), bounds.minZ()));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.maxY() + 13, bounds.minZ()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceTerrainDensityOnlyUsesRigidPoolPieces() {
|
||||
PoolElementStructurePiece terrainMatching = poolPiece(StructureTemplatePool.Projection.TERRAIN_MATCHING);
|
||||
PoolElementStructurePiece rigid = poolPiece(StructureTemplatePool.Projection.RIGID);
|
||||
|
||||
assertFalse(NativeStructureTerrainIntegrator.isSourceRigidPiece(terrainMatching));
|
||||
assertTrue(NativeStructureTerrainIntegrator.isSourceRigidPiece(rigid));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceJunctionTerrainUsesTheStrictLowerTwelveBlockEnvelope() {
|
||||
assertTrue(NativeStructureTerrainIntegrator.insideSourceJunctionEnvelope(0, -1, 0));
|
||||
assertTrue(NativeStructureTerrainIntegrator.insideSourceJunctionEnvelope(0, -11, 0));
|
||||
assertFalse(NativeStructureTerrainIntegrator.insideSourceJunctionEnvelope(0, 0, 0));
|
||||
assertFalse(NativeStructureTerrainIntegrator.insideSourceJunctionEnvelope(0, -12, 0));
|
||||
assertFalse(NativeStructureTerrainIntegrator.insideSourceJunctionEnvelope(12, -1, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitTerrainConfigurationWinsOverAutoEncase() {
|
||||
IrisStructureTerrain configured = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.PRESERVE);
|
||||
|
||||
assertSame(configured, NativeStructureTerrainIntegrator.resolveNativeTerrain(
|
||||
start(TerrainAdjustment.BURY, 64), configured));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void legacyTemplateAirIsClearedAfterEveryTerrainFillPath() {
|
||||
IrisStructureTerrain source = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.SOURCE);
|
||||
IrisStructureTerrain preserve = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.PRESERVE);
|
||||
IrisStructureTerrain encase = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.ENCASE);
|
||||
|
||||
assertTrue(NativeStructureTerrainIntegrator.clearsLegacyTemplateAir(
|
||||
start(TerrainAdjustment.BURY, 64), source));
|
||||
assertTrue(NativeStructureTerrainIntegrator.clearsLegacyTemplateAir(
|
||||
start(TerrainAdjustment.BEARD_BOX, 64), source));
|
||||
assertTrue(NativeStructureTerrainIntegrator.clearsLegacyTemplateAir(
|
||||
start(TerrainAdjustment.NONE, 64), encase));
|
||||
assertFalse(NativeStructureTerrainIntegrator.clearsLegacyTemplateAir(
|
||||
start(TerrainAdjustment.NONE, 64), source));
|
||||
assertFalse(NativeStructureTerrainIntegrator.clearsLegacyTemplateAir(
|
||||
start(TerrainAdjustment.BURY, 64), preserve));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encaseReservesTheNeighborChunkEnvelope() {
|
||||
StructureStart generated = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox sourceBounds = generated.getBoundingBox();
|
||||
BoundingBox content = NativeStructureReferenceEnvelope.contentBounds(generated);
|
||||
IrisStructureTerrain terrain = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.ENCASE)
|
||||
.setHorizontalPadding(4);
|
||||
|
||||
StructureStart wrapped = NativeStructureReferenceEnvelope.wrap(
|
||||
generated,
|
||||
generated.getStructure(),
|
||||
0,
|
||||
terrain);
|
||||
BoundingBox referenceBounds = NativeStructureReferenceEnvelope.referenceBounds(
|
||||
wrapped, wrapped.getStructure(), terrain);
|
||||
|
||||
assertEquals(sourceBounds, wrapped.getBoundingBox());
|
||||
assertEquals(content.minX() - 4, referenceBounds.minX());
|
||||
assertEquals(content.maxX() + 4, referenceBounds.maxX());
|
||||
assertEquals(content.minZ() - 4, referenceBounds.minZ());
|
||||
assertEquals(content.maxZ() + 4, referenceBounds.maxZ());
|
||||
assertEquals(generated.getPieces().size(), wrapped.getPieces().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void referenceEnvelopeRejectsChunkCoordinateOverflow() {
|
||||
StructureStart generated = start(TerrainAdjustment.NONE, 64);
|
||||
StructureStart extreme = new StructureStart(
|
||||
generated.getStructure(), new ChunkPos(Integer.MAX_VALUE, 0), 0,
|
||||
new PiecesContainer(generated.getPieces()));
|
||||
|
||||
assertThrows(IllegalStateException.class, () ->
|
||||
NativeStructureReferenceEnvelope.referenceBounds(
|
||||
extreme, extreme.getStructure(), new IrisStructureTerrain()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitTerrainEnvelopeDoesNotInheritSourceAdjustment() {
|
||||
StructureStart generated = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox content = NativeStructureReferenceEnvelope.contentBounds(generated);
|
||||
IrisStructureTerrain terrain = new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.ENCASE)
|
||||
.setHorizontalPadding(112);
|
||||
|
||||
StructureStart wrapped = NativeStructureReferenceEnvelope.wrap(
|
||||
generated, generated.getStructure(), 0, terrain);
|
||||
BoundingBox referenceBounds = NativeStructureReferenceEnvelope.referenceBounds(
|
||||
wrapped, wrapped.getStructure(), terrain);
|
||||
|
||||
assertEquals(content.minX() - 112, referenceBounds.minX());
|
||||
assertEquals(content.maxX() + 112, referenceBounds.maxX());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void yBandRelocatesTheStartMidpointDeterministically() {
|
||||
IrisStructureYBand band = new IrisStructureYBand().setMin(-120).setMax(-20);
|
||||
StructureStart first = start(TerrainAdjustment.BURY, 64);
|
||||
StructureStart second = start(TerrainAdjustment.BURY, 64);
|
||||
|
||||
NativeStructureVerticalPlacer.applyVerticalShift(
|
||||
first, -64, -256, 320, true, false, band, (x, z) -> 40);
|
||||
NativeStructureVerticalPlacer.applyVerticalShift(
|
||||
second, -64, -256, 320, true, false, band, (x, z) -> 40);
|
||||
|
||||
BoundingBox bounds = first.getBoundingBox();
|
||||
assertEquals(bounds.minY(), second.getBoundingBox().minY());
|
||||
assertTrue(bounds.minY() >= -120);
|
||||
assertTrue(bounds.maxY() <= -20);
|
||||
|
||||
int repeated = NativeStructureVerticalPlacer.applyVerticalShift(
|
||||
first, -64, -256, 320, true, false, band, (x, z) -> 40);
|
||||
assertEquals(0, repeated);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void yBandClampsWhenTheBandCannotContainTheStructure() {
|
||||
IrisStructureYBand band = new IrisStructureYBand().setMin(-50).setMax(-45);
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
|
||||
NativeStructureVerticalPlacer.applyVerticalShift(
|
||||
start, 0, -256, 320, true, false, band, (x, z) -> 40);
|
||||
|
||||
BoundingBox bounds = start.getBoundingBox();
|
||||
int midpoint = bounds.minY() + (bounds.maxY() - bounds.minY()) / 2;
|
||||
assertTrue(midpoint >= -50);
|
||||
assertTrue(midpoint <= -45);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void yBandReplacesBothTheBlindShiftAndBurial() {
|
||||
IrisStructureYBand band = new IrisStructureYBand().setMin(-64).setMax(-64);
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
BoundingBox bounds = start.getBoundingBox();
|
||||
int height = bounds.maxY() - bounds.minY();
|
||||
|
||||
NativeStructureVerticalPlacer.applyVerticalShift(
|
||||
start, -200, -256, 320, true, false, band, (x, z) -> 40);
|
||||
|
||||
assertEquals(-64 - height / 2, start.getBoundingBox().minY());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preserveSourceYWinsOverTheConfiguredBand() {
|
||||
IrisStructureYBand band = new IrisStructureYBand().setMin(-120).setMax(-20);
|
||||
StructureStart start = start(TerrainAdjustment.BURY, 64);
|
||||
int minY = start.getBoundingBox().minY();
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalShift(
|
||||
start, 0, -256, 320, true, true, band, (x, z) -> 40);
|
||||
|
||||
assertEquals(0, offset);
|
||||
assertEquals(minY, start.getBoundingBox().minY());
|
||||
}
|
||||
|
||||
private static BlockState tuffBlock(IrisMaterialPalette palette, RNG rng, int x, int y, int z) {
|
||||
assertNotNull(palette);
|
||||
assertNotNull(rng);
|
||||
return Blocks.TUFF.defaultBlockState();
|
||||
}
|
||||
|
||||
private static StructureStart start(TerrainAdjustment adjustment, int minY) {
|
||||
Structure structure = new DesertPyramidStructure(new Structure.StructureSettings(
|
||||
HolderSet.empty(), Map.of(), GenerationStep.Decoration.STRONGHOLDS, adjustment));
|
||||
StructurePiece piece = new DesertPyramidPiece(RandomSource.create(7L), 0, 0);
|
||||
piece.move(0, minY - piece.getBoundingBox().minY(), 0);
|
||||
return new StructureStart(
|
||||
structure, new ChunkPos(0, 0), 0, new PiecesContainer(List.of(piece)));
|
||||
}
|
||||
|
||||
private static PoolElementStructurePiece poolPiece(StructureTemplatePool.Projection projection) {
|
||||
BlockPos position = new BlockPos(0, 64, 0);
|
||||
StructurePoolElement element = StructurePoolElement.single(
|
||||
"minecraft:empty",
|
||||
Holder.direct(new StructureProcessorList(List.of(
|
||||
BlockIgnoreProcessor.STRUCTURE_AND_AIR))),
|
||||
LiquidSettings.APPLY_WATERLOGGING
|
||||
).apply(projection);
|
||||
return new PoolElementStructurePiece(
|
||||
null,
|
||||
element,
|
||||
position,
|
||||
0,
|
||||
Rotation.NONE,
|
||||
new BoundingBox(position),
|
||||
LiquidSettings.APPLY_WATERLOGGING);
|
||||
}
|
||||
|
||||
private static WorldGenLevel world(Map<BlockPos, BlockState> blocks) {
|
||||
InvocationHandler handler = (proxy, method, arguments) -> {
|
||||
String methodName = method.getName();
|
||||
if (methodName.equals("getBlockState")) {
|
||||
BlockPos position = (BlockPos) arguments[0];
|
||||
return state(blocks, position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
if (methodName.equals("setBlock")) {
|
||||
BlockPos position = (BlockPos) arguments[0];
|
||||
BlockState blockState = (BlockState) arguments[1];
|
||||
put(blocks, position.getX(), position.getY(), position.getZ(), blockState);
|
||||
return true;
|
||||
}
|
||||
if (methodName.equals("getSeed")) {
|
||||
return TEST_SEED;
|
||||
}
|
||||
if (methodName.equals("getLevel")) {
|
||||
return null;
|
||||
}
|
||||
if (methodName.equals("hashCode")) {
|
||||
return System.identityHashCode(proxy);
|
||||
}
|
||||
if (methodName.equals("equals")) {
|
||||
return proxy == arguments[0];
|
||||
}
|
||||
if (methodName.equals("toString")) {
|
||||
return "encase-test-world";
|
||||
}
|
||||
throw new UnsupportedOperationException(method.toString());
|
||||
};
|
||||
return (WorldGenLevel) Proxy.newProxyInstance(
|
||||
WorldGenLevel.class.getClassLoader(), new Class<?>[]{WorldGenLevel.class}, handler);
|
||||
}
|
||||
|
||||
private static NativeStructureTerrainIntegrator.SourceTerrainSnapshot sourceSnapshot(
|
||||
WorldGenLevel world, BoundingBox area) {
|
||||
BitSet requiredLayers = new BitSet(area.getYSpan());
|
||||
requiredLayers.set(0, area.getYSpan());
|
||||
return NativeStructureTerrainIntegrator.SourceTerrainSnapshot.capture(
|
||||
world, area, requiredLayers);
|
||||
}
|
||||
|
||||
private static void put(Map<BlockPos, BlockState> blocks,
|
||||
int x, int y, int z, BlockState state) {
|
||||
blocks.put(new BlockPos(x, y, z), state);
|
||||
}
|
||||
|
||||
private static BlockState state(Map<BlockPos, BlockState> blocks, int x, int y, int z) {
|
||||
return blocks.getOrDefault(new BlockPos(x, y, z), Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
}
|
||||
+12
-17
@@ -1,7 +1,6 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrainMode;
|
||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderSet;
|
||||
@@ -41,7 +40,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
StructureStart start = monumentStart(1337L);
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:monument", 0, 63, -64, 320, false, false, null, (x, z) -> 0);
|
||||
start, "minecraft:monument", 0, 63, -64, 320, (x, z) -> 0);
|
||||
|
||||
assertEquals(0, offset);
|
||||
assertEquals(39, start.getBoundingBox().minY());
|
||||
@@ -57,7 +56,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
BoundingBox cachedBounds = start.getBoundingBox();
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:monument", 0, 50, -256, 512, false, false, null, (x, z) -> 0);
|
||||
start, "minecraft:monument", 0, 50, -256, 512, (x, z) -> 0);
|
||||
|
||||
assertEquals(-13, offset);
|
||||
assertSame(cachedBounds, start.getBoundingBox());
|
||||
@@ -71,7 +70,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
}
|
||||
|
||||
int repeatedOffset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:monument", 0, 50, -256, 512, false, false, null, (x, z) -> 0);
|
||||
start, "minecraft:monument", 0, 50, -256, 512, (x, z) -> 0);
|
||||
assertEquals(0, repeatedOffset);
|
||||
}
|
||||
|
||||
@@ -80,7 +79,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
StructureStart start = monumentStart(1337L);
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:monument", 3, 50, -256, 512, false, false, null, (x, z) -> 0);
|
||||
start, "minecraft:monument", 3, 50, -256, 512, (x, z) -> 0);
|
||||
|
||||
assertEquals(-10, offset);
|
||||
assertEquals(29, start.getBoundingBox().minY());
|
||||
@@ -94,13 +93,10 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
start,
|
||||
start.getStructure(),
|
||||
0,
|
||||
new IrisStructureTerrain()
|
||||
.setMode(IrisStructureTerrainMode.FORCE_CARVE)
|
||||
.setHorizontalPadding(4));
|
||||
List.of(new NativeStructureReach(false, 4)));
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
wrapped, "minecraft:monument", 0, 63, -64, 320,
|
||||
false, false, null, (x, z) -> 0);
|
||||
wrapped, "minecraft:monument", 0, 63, -64, 320, (x, z) -> 0);
|
||||
|
||||
assertEquals(0, offset);
|
||||
assertEquals(1, wrapped.getPieces().size());
|
||||
@@ -112,7 +108,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
ChunkPos chunkPos = new ChunkPos(0, 0);
|
||||
StructureStart initial = monumentStart(seed);
|
||||
NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
initial, "minecraft:monument", 0, 50, -256, 512, false, false, null, (x, z) -> 0);
|
||||
initial, "minecraft:monument", 0, 50, -256, 512, (x, z) -> 0);
|
||||
|
||||
PiecesContainer regenerated = OceanMonumentStructure.regeneratePiecesAfterLoad(
|
||||
chunkPos, seed, new PiecesContainer(initial.getPieces()));
|
||||
@@ -121,7 +117,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
|
||||
assertEquals(39, reloaded.getBoundingBox().minY());
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
reloaded, "minecraft:monument", 0, 50, -256, 512, false, false, null, (x, z) -> 0);
|
||||
reloaded, "minecraft:monument", 0, 50, -256, 512, (x, z) -> 0);
|
||||
assertEquals(-13, offset);
|
||||
assertEquals(26, reloaded.getBoundingBox().minY());
|
||||
assertEquals(48, reloaded.getBoundingBox().maxY());
|
||||
@@ -133,8 +129,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
ChunkPos chunkPos = new ChunkPos(0, 0);
|
||||
StructureStart initial = monumentStart(seed);
|
||||
NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
initial, "minecraft:monument", 0, 50, -256, 512,
|
||||
false, false, null, (x, z) -> 0);
|
||||
initial, "minecraft:monument", 0, 50, -256, 512, (x, z) -> 0);
|
||||
PiecesContainer regenerated = OceanMonumentStructure.regeneratePiecesAfterLoad(
|
||||
chunkPos, seed, new PiecesContainer(initial.getPieces()));
|
||||
StructureStart reloaded = new StructureStart(
|
||||
@@ -147,7 +142,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
futures.add(executor.submit(() -> {
|
||||
release.await();
|
||||
NativeStructureVerticalPlacer.ensureMonumentSeaLevelAlignment(
|
||||
reloaded, "minecraft:monument", 0, 50, -256, 512);
|
||||
reloaded, "minecraft:monument", () -> 0, 50, -256, 512);
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
@@ -168,7 +163,7 @@ public class NativeStructurePostProcessorMonumentTest {
|
||||
StructureStart start = monumentStart(1337L);
|
||||
try {
|
||||
NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:monument", 0, -50, -64, 320, false, false, null, (x, z) -> 0);
|
||||
start, "minecraft:monument", 0, -50, -64, 320, (x, z) -> 0);
|
||||
} catch (IllegalStateException error) {
|
||||
assertTrue(error.getMessage().contains("cannot align"));
|
||||
return;
|
||||
|
||||
+12
-14
@@ -11,6 +11,7 @@ import net.minecraft.world.level.levelgen.structure.ScatteredFeaturePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.TerrainAdjustment;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.PiecesContainer;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.DesertPyramidPiece;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.DesertPyramidStructure;
|
||||
@@ -46,8 +47,7 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
BoundingBox footprint = piece.getBoundingBox();
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, false, false, null,
|
||||
(x, z) -> x == footprint.maxX() && z == footprint.maxZ() ? 64 : 92);
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, (x, z) -> x == footprint.maxX() && z == footprint.maxZ() ? 64 : 92);
|
||||
|
||||
assertEquals(1, offset);
|
||||
assertSame(cachedBounds, start.getBoundingBox());
|
||||
@@ -64,8 +64,7 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
BoundingBox footprint = piece.getBoundingBox();
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:jungle_pyramid", 4, 63, -64, 320, false, false, null,
|
||||
(x, z) -> x == footprint.minX() && z == footprint.minZ() ? 88 : 70);
|
||||
start, "minecraft:jungle_pyramid", 4, 63, -64, 320, (x, z) -> x == footprint.minX() && z == footprint.minZ() ? 88 : 70);
|
||||
|
||||
assertEquals(11, offset);
|
||||
assertEquals(75, piece.getBoundingBox().minY());
|
||||
@@ -79,9 +78,9 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
StructureStart start = desertStart(piece);
|
||||
|
||||
int initialOffset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, false, false, null, (x, z) -> 80);
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, (x, z) -> 80);
|
||||
int repeatedOffset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, false, false, null, (x, z) -> 80);
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, (x, z) -> 80);
|
||||
|
||||
assertEquals(17, initialOffset);
|
||||
assertEquals(0, repeatedOffset);
|
||||
@@ -94,7 +93,7 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
StructureStart start = desertStart(piece);
|
||||
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, false, false, null, (x, z) -> 318);
|
||||
start, "minecraft:desert_pyramid", 0, 63, -64, 320, (x, z) -> 318);
|
||||
|
||||
assertEquals(241, offset);
|
||||
assertEquals(305, piece.getBoundingBox().minY());
|
||||
@@ -110,14 +109,13 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
StructureStart jungleStart = jungleStart(jungle);
|
||||
StructureStart swampStart = swampStart(swamp);
|
||||
|
||||
assertFalse(NativeStructureSurfaceFitter.requiresSurfaceTerrain(desertStart));
|
||||
assertFalse(NativeStructureSurfaceFitter.requiresSurfaceTerrain(jungleStart));
|
||||
assertFalse(NativeStructureSurfaceFitter.requiresSurfaceTerrain(swampStart));
|
||||
assertEquals(TerrainAdjustment.NONE, desertStart.getStructure().terrainAdaptation());
|
||||
assertEquals(TerrainAdjustment.NONE, jungleStart.getStructure().terrainAdaptation());
|
||||
assertEquals(TerrainAdjustment.NONE, swampStart.getStructure().terrainAdaptation());
|
||||
|
||||
AtomicInteger terrainQueries = new AtomicInteger();
|
||||
int offset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
swampStart, "minecraft:swamp_hut", 0, 63, -64, 320, false, false, null,
|
||||
(x, z) -> terrainQueries.incrementAndGet());
|
||||
swampStart, "minecraft:swamp_hut", 0, 63, -64, 320, (x, z) -> terrainQueries.incrementAndGet());
|
||||
assertEquals(0, offset);
|
||||
assertEquals(0, terrainQueries.get());
|
||||
assertEquals(64, swamp.getBoundingBox().minY());
|
||||
@@ -142,7 +140,7 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
int pyramidMinY = pyramidOverride.getBoundingBox().minY();
|
||||
int pyramidOffset = NativeStructureVerticalPlacer.applyVerticalPlacement(
|
||||
pyramidOverride, "minecraft:desert_pyramid", 5,
|
||||
63, -64, 320, false, false, null, (x, z) -> 200);
|
||||
63, -64, 320, (x, z) -> 200);
|
||||
|
||||
assertEquals(5, pyramidOffset);
|
||||
assertEquals(pyramidMinY + 5, pyramidOverride.getBoundingBox().minY());
|
||||
@@ -151,7 +149,7 @@ public class NativeStructurePostProcessorScatteredFeatureTest {
|
||||
new SwampHutPiece(RandomSource.create(47L), 0, 0));
|
||||
int monumentMinY = monumentOverride.getBoundingBox().minY();
|
||||
NativeStructureVerticalPlacer.ensureMonumentSeaLevelAlignment(
|
||||
monumentOverride, "minecraft:monument", 0, 40, -64, 320);
|
||||
monumentOverride, "minecraft:monument", () -> 0, 40, -64, 320);
|
||||
|
||||
assertEquals(monumentMinY, monumentOverride.getBoundingBox().minY());
|
||||
}
|
||||
|
||||
-2375
File diff suppressed because it is too large.
Load diff
-15
@@ -173,21 +173,6 @@ public class NativeStructurePostProcessorVegetationTest {
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundStructuresUseTheLowestTerrainColumn() {
|
||||
BoundingBox bounds = new BoundingBox(0, 60, 0, 1, 80, 0);
|
||||
int offset = NativeStructureVerticalPlacer.resolveBuriedOffset(
|
||||
bounds, 0, -64, 320, (x, z) -> x == 1 ? 76 : 100);
|
||||
assertEquals(-5, offset);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundBurialClampsToTheWorldFloorInsteadOfFailing() {
|
||||
BoundingBox bounds = new BoundingBox(0, 60, 0, 1, 80, 0);
|
||||
assertEquals(-2, NativeStructureVerticalPlacer.resolveBuriedOffset(
|
||||
bounds, 0, 58, 320, (x, z) -> x == 1 ? 76 : 100));
|
||||
}
|
||||
|
||||
private static void clearVegetation(ProtoChunk chunk, StructureStart start) {
|
||||
NativeStructureVegetationClearer.clearIntersectingVegetation(
|
||||
world(chunk), chunk, AREA, List.of(start));
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ public class NativeStructureVolumeIndexTest {
|
||||
public void vanillaVolumesAreGatedOnPackPolicy() throws Exception {
|
||||
String source = Files.readString(Path.of(System.getProperty("iris.nativeStructureVolumeIndexSource")));
|
||||
|
||||
assertTrue(source.contains("NativeStructureGenerationPolicy.resolve("));
|
||||
assertTrue(source.contains("if (!decision.generate())"));
|
||||
assertTrue(source.contains("if (!NativeStructureGenerationPolicy.generates(engine, structureId))"));
|
||||
assertTrue(source.contains("NativeStructureLayouts.shift(engine"));
|
||||
assertTrue(source.contains("isStructureChunk("));
|
||||
}
|
||||
|
||||
|
||||
+19
-20
@@ -30,9 +30,8 @@ import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
||||
import art.arcane.iris.engine.framework.StructureReachability;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecision;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.engine.platform.EngineBukkitOps;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
@@ -144,20 +143,20 @@ public class CommandFind implements DirectorExecutor {
|
||||
String structureKey = structure == null ? "" : structure.trim();
|
||||
Structure nativeStructure = resolveNativeStructure(structureKey);
|
||||
boolean registered = nativeStructure != null;
|
||||
IrisNativeStructureDecision decision = registered
|
||||
? NativeStructureGenerationPolicy.resolve(e, structureKey, false)
|
||||
NativeStructureGenerationStatus status = registered
|
||||
? NativeStructureGenerationPolicy.resolve(e, structureKey)
|
||||
: null;
|
||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(e, structureKey);
|
||||
boolean locatableNativePlacement = IrisStructureLocator.hasLocatableNativePlacement(e, structureKey);
|
||||
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(e, structureKey);
|
||||
World targetWorld = target.getWorld();
|
||||
boolean nativeGenerationEnabled = targetWorld.canGenerateStructures();
|
||||
boolean requiresReachability = registered && decision.generate()
|
||||
&& decision.status() != NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
||||
boolean requiresReachability = registered && status == NativeStructureGenerationStatus.GENERATE_NATIVE
|
||||
&& status != NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
||||
&& nativeGenerationEnabled;
|
||||
boolean reachable = !requiresReachability || StructureReachability.isReachable(e, structureKey);
|
||||
StructureLookupRoute route = selectStructureLookupRoute(
|
||||
registered, decision, nativePlacement, locatableNativePlacement,
|
||||
registered, status, nativePlacement, locatableNativePlacement,
|
||||
locatableEditablePlacement, nativeGenerationEnabled, reachable);
|
||||
|
||||
if (route == StructureLookupRoute.UNKNOWN) {
|
||||
@@ -166,7 +165,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
}
|
||||
if (route == StructureLookupRoute.POLICY_DISABLED) {
|
||||
commandSender.sendMessage(C.RED + NativeStructureGenerationPolicy.generationStatusMessage(
|
||||
structureKey, decision.status()));
|
||||
structureKey, status));
|
||||
return;
|
||||
}
|
||||
if (route == StructureLookupRoute.NO_ACTIVE_PLACEMENT) {
|
||||
@@ -273,24 +272,24 @@ public class CommandFind implements DirectorExecutor {
|
||||
for (Map.Entry<String, String> entry : registeredKeys.entrySet()) {
|
||||
String normalizedKey = entry.getKey();
|
||||
String key = entry.getValue();
|
||||
IrisNativeStructureDecision decision = NativeStructureGenerationPolicy.resolve(engine, key, false);
|
||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
||||
boolean locatableNativePlacement = IrisStructureLocator.hasLocatableNativePlacement(engine, key);
|
||||
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(engine, key);
|
||||
StructureLookupRoute route = selectStructureLookupRoute(
|
||||
true, decision, nativePlacement, locatableNativePlacement,
|
||||
true, status, nativePlacement, locatableNativePlacement,
|
||||
locatableEditablePlacement, nativeGenerationEnabled,
|
||||
reachableKeys.contains(normalizedKey));
|
||||
if (route == StructureLookupRoute.IRIS || route == StructureLookupRoute.NATIVE) {
|
||||
continue;
|
||||
}
|
||||
List<String> requiredBiomes = needsNativeReachabilityReason(route, decision)
|
||||
List<String> requiredBiomes = needsNativeReachabilityReason(route, status)
|
||||
? structureHooks.structureBiomeKeys(key)
|
||||
: List.of();
|
||||
exclusions.add(new StructureExclusion(
|
||||
StructureExclusionKind.EXCLUDED, key, null,
|
||||
describeStructureExclusion(
|
||||
route, key, decision.status(), nativePlacement,
|
||||
route, key, status, nativePlacement,
|
||||
requiredBiomes, possibleBiomeKeys)));
|
||||
registeredExcluded++;
|
||||
}
|
||||
@@ -418,9 +417,9 @@ public class CommandFind implements DirectorExecutor {
|
||||
}
|
||||
|
||||
private static boolean needsNativeReachabilityReason(
|
||||
StructureLookupRoute route, IrisNativeStructureDecision decision) {
|
||||
StructureLookupRoute route, NativeStructureGenerationStatus status) {
|
||||
return route == StructureLookupRoute.UNREACHABLE
|
||||
|| route == StructureLookupRoute.NO_ACTIVE_PLACEMENT && decision.generate();
|
||||
|| route == StructureLookupRoute.NO_ACTIVE_PLACEMENT && status == NativeStructureGenerationStatus.GENERATE_NATIVE;
|
||||
}
|
||||
|
||||
static String describeStructureExclusion(
|
||||
@@ -529,7 +528,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
}
|
||||
|
||||
static StructureLookupRoute selectStructureLookupRoute(
|
||||
boolean registered, IrisNativeStructureDecision decision, boolean nativePlacement,
|
||||
boolean registered, NativeStructureGenerationStatus status, boolean nativePlacement,
|
||||
boolean locatableNativePlacement, boolean locatableEditablePlacement,
|
||||
boolean nativeGenerationEnabled, boolean reachable) {
|
||||
if (!registered) {
|
||||
@@ -537,14 +536,14 @@ public class CommandFind implements DirectorExecutor {
|
||||
? StructureLookupRoute.IRIS
|
||||
: StructureLookupRoute.UNKNOWN;
|
||||
}
|
||||
if (decision == null) {
|
||||
throw new IllegalArgumentException("Registered structure lookup requires a generation decision");
|
||||
if (status == null) {
|
||||
throw new IllegalArgumentException("Registered structure lookup requires a generation status");
|
||||
}
|
||||
if (!decision.generate()
|
||||
&& decision.status() != NativeStructureGenerationStatus.REPLACED_BY_IRIS) {
|
||||
if (status != NativeStructureGenerationStatus.GENERATE_NATIVE
|
||||
&& status != NativeStructureGenerationStatus.REPLACED_BY_IRIS) {
|
||||
return StructureLookupRoute.POLICY_DISABLED;
|
||||
}
|
||||
if (decision.status() == NativeStructureGenerationStatus.REPLACED_BY_IRIS) {
|
||||
if (status == NativeStructureGenerationStatus.REPLACED_BY_IRIS) {
|
||||
if (!nativePlacement) {
|
||||
return locatableEditablePlacement
|
||||
? StructureLookupRoute.IRIS
|
||||
|
||||
+7
-8
@@ -36,10 +36,9 @@ import art.arcane.iris.engine.framework.StructureReachability;
|
||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecision;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.util.common.director.DirectorExecutor;
|
||||
import art.arcane.iris.util.common.format.C;
|
||||
@@ -173,13 +172,13 @@ public class CommandStructure implements DirectorExecutor {
|
||||
private void runVerification(Engine engine, KList<String> structureKeys, int centerX, int centerZ,
|
||||
int searchRadius, VolmitSender commandSender, Player target) {
|
||||
KList<String> messages = new KList<>();
|
||||
Map<String, IrisNativeStructureDecision> decisions = new HashMap<>(structureKeys.size());
|
||||
Map<String, NativeStructureGenerationStatus> statuses = new HashMap<>(structureKeys.size());
|
||||
boolean requiresNativeReachability = false;
|
||||
for (String keyName : structureKeys) {
|
||||
IrisNativeStructureDecision decision = NativeStructureGenerationPolicy.resolve(engine, keyName, false);
|
||||
decisions.put(keyName, decision);
|
||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, keyName);
|
||||
statuses.put(keyName, status);
|
||||
requiresNativeReachability |= !IrisStructureLocator.isPlaced(engine, keyName)
|
||||
&& decision.generate();
|
||||
&& status == NativeStructureGenerationStatus.GENERATE_NATIVE;
|
||||
}
|
||||
Set<String> reachable = Set.of();
|
||||
if (requiresNativeReachability) {
|
||||
@@ -199,7 +198,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
int searchLimited = 0;
|
||||
int errors = 0;
|
||||
for (String keyName : structureKeys) {
|
||||
IrisNativeStructureDecision decision = decisions.get(keyName);
|
||||
NativeStructureGenerationStatus status = statuses.get(keyName);
|
||||
if (IrisStructureLocator.isPlaced(engine, keyName)) {
|
||||
try {
|
||||
IrisStructureLocator.LocateResult result =
|
||||
@@ -225,7 +224,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!decision.generate()) {
|
||||
if (status != NativeStructureGenerationStatus.GENERATE_NATIVE) {
|
||||
disabled++;
|
||||
messages.add(C.GRAY + "[disabled] " + C.WHITE + keyName);
|
||||
continue;
|
||||
|
||||
+11
-17
@@ -1,8 +1,7 @@
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecision;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -64,11 +63,11 @@ public class IrisStructureLocateCommandContractTest {
|
||||
false, null, false, false, false, true, true));
|
||||
assertEquals(CommandFind.StructureLookupRoute.NO_ACTIVE_PLACEMENT,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.REPLACED_BY_IRIS),
|
||||
true, NativeStructureGenerationStatus.REPLACED_BY_IRIS,
|
||||
false, false, false, true, true));
|
||||
assertEquals(CommandFind.StructureLookupRoute.NO_ACTIVE_PLACEMENT,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.GENERATE_NATIVE),
|
||||
true, NativeStructureGenerationStatus.GENERATE_NATIVE,
|
||||
true, false, false, true, false));
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
false, null, false, false, true, false, false));
|
||||
assertEquals(CommandFind.StructureLookupRoute.IRIS,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.REPLACED_BY_IRIS),
|
||||
true, NativeStructureGenerationStatus.REPLACED_BY_IRIS,
|
||||
false, false, true, false, false));
|
||||
}
|
||||
|
||||
@@ -87,23 +86,23 @@ public class IrisStructureLocateCommandContractTest {
|
||||
public void findRequiresWorldGenerationAndReachabilityForNativeRoutes() {
|
||||
assertEquals(CommandFind.StructureLookupRoute.WORLD_DISABLED,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.REPLACED_BY_IRIS),
|
||||
true, NativeStructureGenerationStatus.REPLACED_BY_IRIS,
|
||||
true, true, false, false, true));
|
||||
assertEquals(CommandFind.StructureLookupRoute.WORLD_DISABLED,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.GENERATE_NATIVE),
|
||||
true, NativeStructureGenerationStatus.GENERATE_NATIVE,
|
||||
false, false, false, false, true));
|
||||
assertEquals(CommandFind.StructureLookupRoute.UNREACHABLE,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.GENERATE_NATIVE),
|
||||
true, NativeStructureGenerationStatus.GENERATE_NATIVE,
|
||||
false, false, false, true, false));
|
||||
assertEquals(CommandFind.StructureLookupRoute.NATIVE,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.GENERATE_NATIVE),
|
||||
true, NativeStructureGenerationStatus.GENERATE_NATIVE,
|
||||
true, true, false, true, false));
|
||||
assertEquals(CommandFind.StructureLookupRoute.NATIVE,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.GENERATE_NATIVE),
|
||||
true, NativeStructureGenerationStatus.GENERATE_NATIVE,
|
||||
true, false, false, true, true));
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
public void findHonorsPackDisableBeforePlacementRouting() {
|
||||
assertEquals(CommandFind.StructureLookupRoute.POLICY_DISABLED,
|
||||
CommandFind.selectStructureLookupRoute(
|
||||
true, decision(NativeStructureGenerationStatus.DISABLED_BY_PACK),
|
||||
true, NativeStructureGenerationStatus.DISABLED_BY_PACK,
|
||||
false, false, true, true, true));
|
||||
}
|
||||
|
||||
@@ -281,7 +280,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
int methodStart = source.indexOf("private void runVerification(");
|
||||
int methodEnd = source.indexOf("private void sendVerificationMessages(", methodStart);
|
||||
String method = source.substring(methodStart, methodEnd);
|
||||
int policyResolution = method.indexOf("NativeStructureGenerationPolicy.resolve(engine, keyName, false)");
|
||||
int policyResolution = method.indexOf("NativeStructureGenerationPolicy.resolve(engine, keyName)");
|
||||
int nativeRequirement = method.indexOf(
|
||||
"requiresNativeReachability |= !IrisStructureLocator.isPlaced", policyResolution);
|
||||
int reachabilityGuard = method.indexOf("if (requiresNativeReachability)", nativeRequirement);
|
||||
@@ -292,9 +291,4 @@ public class IrisStructureLocateCommandContractTest {
|
||||
assertTrue(reachabilityGuard > nativeRequirement);
|
||||
assertTrue(reachabilityLookup > reachabilityGuard);
|
||||
}
|
||||
|
||||
private static IrisNativeStructureDecision decision(NativeStructureGenerationStatus status) {
|
||||
return new IrisNativeStructureDecision(
|
||||
status, 0, null, false, null, null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user