Core asks for native structure starts and locates through the structure services

ModuleServices gains placedStructures, placesStructure, startedStructures, startsStructure, canLocateStart and
locateStart (a SEARCH_LIMIT_REACHED outcome instead of an exception); StructureHandler, the Bukkit and modded locate
commands and suggestions, the native structure stages, NMS IrisChunkGenerator and NativeStructureLocatePersistence
use them instead of IrisStructureLocator. StructureReachability keeps its keys per world; the hotloader no longer
invalidates locator caches. StructureCaveAnchorResolverTest binds a platform itself (it relied on test order).
This commit is contained in:
piexel committed 2026-10-12 02:06:14 +02:00
1 parent 0cfcada4f2
commit 7d9fd3faa6
24 files changed
+385 -126

No files matched your search

@@ -24,6 +24,7 @@ import com.volmit.host.FeatureCatalog;
import com.volmit.host.ServiceRegistration;
import com.volmit.entity.EntitySpec;
import com.volmit.item.ItemDrop;
import com.volmit.resource.ResourceId;
import com.volmit.service.AmbientEffects;
import com.volmit.service.BlockDrops;
import com.volmit.service.CaveBiomes;
@@ -34,6 +35,7 @@ import com.volmit.service.ObjectsAt;
import com.volmit.service.SaplingGrowth;
import com.volmit.service.StructureLocator;
import com.volmit.service.VanillaFeatures;
import com.volmit.service.VanillaStructures;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.ArrayList;
@@ -42,6 +44,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
/**
* What Iris core asks the pack's modules through their services ({@link com.volmit.service.Service}) instead of reading
@@ -236,26 +239,90 @@ public final class ModuleServices {
/** Whether a module of the world can locate structure {@code key}, matched without regard to case. */
public static boolean canLocateStructure(Engine engine, String key) {
return structureLocatorOf(engine, key).isPresent();
return structureLocatorOf(engine, key, StructureLocator::locatable).isPresent();
}
/**
* Every key under which the world's modules find what they place, locatable or not: their own structures and the
* platform structures they start or stand in for.
*/
public static Set<String> placedStructures(Engine engine) {
Set<String> keys = new LinkedHashSet<>();
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
keys.addAll(provider.service().placed(provider.world()));
}
return keys;
}
/** Whether a module of the world places structure {@code key}, located or not, matched without regard to case. */
public static boolean placesStructure(Engine engine, String key) {
return structureLocatorOf(engine, key, StructureLocator::placed).isPresent();
}
/**
* Searches for the start of structure {@code key} nearest to {@code fromX}, {@code fromZ} with the first module that
* can locate it, in the world's own coordinates; not found when none can.
* places it, in the world's own coordinates; not found when none does.
*/
public static StructureSearch locateStructure(Engine engine, String key, int fromX, int fromZ, int maxRadiusChunks) {
LocateResult result = structureLocatorOf(engine, key)
LocateResult result = structureLocatorOf(engine, key, StructureLocator::placed)
.map(provider -> provider.service().locate(provider.world(), key, fromX, fromZ, maxRadiusChunks))
.orElse(LocateResult.NOT_FOUND);
return StructureSearch.of(result, engine);
}
/** The platform structures the world's modules start themselves, as lower-case registry keys. */
public static Set<String> startedStructures(Engine engine) {
return platformStructures(engine, VanillaStructures::startedStructures);
}
/** Whether a module of the world starts the platform structure {@code key} itself. */
public static boolean startsStructure(Engine engine, String key) {
return key != null && startedStructures(engine).contains(normalized(key));
}
/** Whether a module of the world can find the starts it makes of the platform structure {@code key}. */
public static boolean canLocateStart(Engine engine, String key) {
return key != null && platformStructures(engine, VanillaStructures::locatableStarts).contains(normalized(key));
}
/**
* Searches ring by ring, up to {@code maxRings} rings, for the start the first module that can find them makes of the
* platform structure {@code key} nearest to {@code fromX}, {@code fromZ}, trying only chunks {@code candidates}
* accepts, in the world's own coordinates. A {@link StructureSearchLimitException} from {@code candidates} ends the
* search as {@link StructureSearch.Outcome#SEARCH_LIMIT_REACHED}.
*/
public static StructureSearch locateStart(Engine engine, String key, int fromX, int fromZ, int maxRings,
CandidateChunks candidates) {
Optional<ResourceId> structure = registryId(key);
if (structure.isEmpty()) {
return StructureSearch.NOT_FOUND;
}
for (Provider<VanillaStructures> provider : providers(engine, VanillaStructures.class)) {
if (!provider.service().locatableStarts(provider.world()).contains(structure.get())) {
continue;
}
try {
return StructureSearch.of(provider.service().locateStart(provider.world(), structure.get(), fromX, fromZ,
maxRings, candidates::accepts), engine);
} catch (StructureSearchLimitException limit) {
return StructureSearch.SEARCH_LIMIT_REACHED;
}
}
return StructureSearch.NOT_FOUND;
}
/** The chunks a search for a module's start of a platform structure may answer with. */
@FunctionalInterface
public interface CandidateChunks {
boolean accepts(int chunkX, int chunkZ);
}
/** How a structure search ended. A found start is at {@code x}, {@code y}, {@code z}: world coordinates, Y the world's own. */
public record StructureSearch(Outcome outcome, int x, int y, int z) {
public enum Outcome { FOUND, NOT_FOUND, SEARCH_LIMIT_REACHED }
private static final StructureSearch NOT_FOUND = new StructureSearch(Outcome.NOT_FOUND, 0, 0, 0);
private static final StructureSearch SEARCH_LIMIT_REACHED = new StructureSearch(Outcome.SEARCH_LIMIT_REACHED, 0, 0, 0);
public static final StructureSearch NOT_FOUND = new StructureSearch(Outcome.NOT_FOUND, 0, 0, 0);
public static final StructureSearch SEARCH_LIMIT_REACHED = new StructureSearch(Outcome.SEARCH_LIMIT_REACHED, 0, 0, 0);
public boolean found() {
return outcome == Outcome.FOUND;
@@ -272,20 +339,41 @@ public final class ModuleServices {
}
}
/** The first provider, in the catalog's order, whose locatable structures hold {@code key}. */
private static Optional<Provider<StructureLocator>> structureLocatorOf(Engine engine, String key) {
/** The first provider, in the catalog's order, whose structures of the kind {@code keys} lists hold {@code key}. */
private static Optional<Provider<StructureLocator>> structureLocatorOf(Engine engine, String key,
BiFunction<StructureLocator, PackWorld, Set<String>> keys) {
if (key == null || key.isBlank()) {
return Optional.empty();
}
String wanted = normalized(key);
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
if (provider.service().locatable(provider.world()).stream().map(ModuleServices::normalized).anyMatch(wanted::equals)) {
if (keys.apply(provider.service(), provider.world()).stream().map(ModuleServices::normalized).anyMatch(wanted::equals)) {
return Optional.of(provider);
}
}
return Optional.empty();
}
/** The platform structures every provider lists with {@code structures}, as lower-case registry keys. */
private static Set<String> platformStructures(Engine engine, BiFunction<VanillaStructures, PackWorld, Set<ResourceId>> structures) {
Set<String> keys = new LinkedHashSet<>();
for (Provider<VanillaStructures> provider : providers(engine, VanillaStructures.class)) {
structures.apply(provider.service(), provider.world()).forEach(id -> keys.add(id.toString()));
}
return keys;
}
private static Optional<ResourceId> registryId(String key) {
if (key == null || key.isBlank()) {
return Optional.empty();
}
try {
return Optional.of(ResourceId.parse(normalized(key.trim())));
} catch (IllegalArgumentException notAnId) {
return Optional.empty();
}
}
private static String normalized(String key) {
return key.toLowerCase(Locale.ROOT);
}
@@ -0,0 +1,29 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
/**
* Thrown by a host's {@link ModuleServices.CandidateChunks} to end a search for a module's start of a platform structure
* when the host's own checks ran out of budget; {@link ModuleServices#locateStart} reports it as a reached search limit.
*/
public final class StructureSearchLimitException extends RuntimeException {
public StructureSearchLimitException() {
super(null, null, false, false);
}
}
@@ -24,8 +24,6 @@ import art.arcane.iris.engine.EngineRuntime.BiomeMaxes;
import art.arcane.iris.engine.EngineRuntimeBuilder.RuntimeAssembly;
import art.arcane.iris.engine.IrisEngine.LifecycleState;
import art.arcane.iris.engine.framework.EngineTarget;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.framework.StructureReachability;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.IrisServices;
@@ -117,8 +115,6 @@ final class EngineHotloader {
}
engine.getPlatformHooks().validateDimensionHotload(engine, replacement);
replacementData.registerEngine(engine);
IrisStructureLocator.invalidate(engine);
StructureReachability.invalidate(engine);
EngineTarget replacementTarget = new EngineTarget(engine.getWorld(), replacement, replacementData);
EngineRuntime nextRuntime = engine.runtimeBuilder.buildRuntime(replacementTarget);
engine.runtimeBuilder.publishRuntime(nextRuntime, previousRuntime);
@@ -151,8 +147,6 @@ final class EngineHotloader {
e.addSuppressed(replacementDataFailure);
}
}
IrisStructureLocator.invalidate(engine);
StructureReachability.invalidate(engine);
if (engine.lifecycleState != LifecycleState.FAILED) {
Throwable rollbackFailure = runCleanup(null, engine.getMantle()::hotload);
if (rollbackFailure == null) {
@@ -0,0 +1,124 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.engine.framework;
import art.arcane.iris.engine.object.world.IrisWorld;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.volmlib.util.collection.KList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
/**
* Determines which vanilla/datapack structures can ever generate in a world, using the same biome
* gate vanilla applies: a structure is reachable when its biome filter intersects the set of vanilla
* biomes the pack actually produces (its {@code possibleBiomes}). Structures whose required biomes are
* never produced cannot generate and must not be scanned for by {@code /locate} or {@code /iris find}
* (an unbounded scan for an absent biome is what stalls the server).
*
* <p>The reachable set is fixed per world: it is kept in the world's state, so a hotload's new world builds it again.
* It is the platform's answer, so Iris core asks it, not a module.
*/
public final class StructureReachability {
private StructureReachability() {
}
public static Set<String> reachableKeys(Engine engine) {
Engine activeEngine = Objects.requireNonNull(engine, "Structure reachability requires an engine");
if (activeEngine.getData() == null) {
throw new IllegalStateException("Structure reachability requires a bound pack data loader");
}
return activeEngine.getGeneration().state(ReachableKeys.class, ReachableKeys::of).keys();
}
public static boolean isReachable(Engine engine, String structureKey) {
String normalizedStructureKey = normalizeStructureKey(structureKey);
return reachableKeys(engine).contains(normalizedStructureKey);
}
private static Set<String> build(Engine engine) {
IrisWorld world = engine.getWorld();
if (world == null) {
throw new IllegalStateException("Structure reachability requires a bound Iris world");
}
if (world.platformWorld() == null) {
throw new IllegalStateException("Structure reachability requires a bound platform world");
}
Set<String> reachable = new LinkedHashSet<>();
for (String key : IrisPlatforms.get().structureHooks().reachableStructureKeys(world.platformWorld())) {
if (key == null || key.isBlank()) {
throw new IllegalStateException("Platform structure reachability returned a blank registry key");
}
reachable.add(key.toLowerCase(Locale.ROOT));
}
return Collections.unmodifiableSet(reachable);
}
/**
* The vanilla biome keys (e.g. {@code minecraft:taiga}) from a structure's filter that the pack
* does not produce. An empty list means the structure is reachable. Used by the structure verify
* diagnostic to explain why a structure cannot generate.
*/
public static KList<String> missingBiomeKeys(Engine engine, String structureKey) {
KList<String> missing = new KList<>();
Engine activeEngine = Objects.requireNonNull(engine, "Structure biome diagnostics require an engine");
String normalizedStructureKey = normalizeStructureKey(structureKey);
IrisWorld world = activeEngine.getWorld();
if (world == null) {
throw new IllegalStateException("Structure biome diagnostics require a bound Iris world");
}
if (world.platformWorld() == null) {
throw new IllegalStateException("Structure biome diagnostics require a bound platform world");
}
Set<String> possible = new LinkedHashSet<>();
for (String key : IrisPlatforms.get().structureHooks().possibleBiomeKeys(world.platformWorld())) {
if (key == null || key.isBlank()) {
throw new IllegalStateException("Platform structure biome query returned a blank possible-biome key");
}
possible.add(key.toLowerCase(Locale.ROOT));
}
for (String biomeKey : IrisPlatforms.get().structureHooks().structureBiomeKeys(normalizedStructureKey)) {
if (biomeKey == null || biomeKey.isBlank()) {
throw new IllegalStateException("Platform structure biome query returned a blank required-biome key for "
+ normalizedStructureKey);
}
if (!possible.contains(biomeKey.toLowerCase(Locale.ROOT))) {
missing.add(biomeKey);
}
}
return missing;
}
/** The world's reachable structure keys, in lower case. */
private record ReachableKeys(Set<String> keys) {
static ReachableKeys of(Engine engine) {
return new ReachableKeys(build(engine));
}
}
private static String normalizeStructureKey(String structureKey) {
if (structureKey == null || structureKey.isBlank()) {
throw new IllegalArgumentException("Registered structure key must not be blank");
}
return structureKey.trim().toLowerCase(Locale.ROOT);
}
}
@@ -20,7 +20,6 @@ package art.arcane.iris.util.common.director.specialhandlers;
import art.arcane.iris.core.modules.ModuleServices;
import art.arcane.iris.engine.framework.Engine;
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.framework.NativeStructureGenerationStatus;
@@ -62,7 +61,7 @@ public class StructureHandler implements DirectorParameterHandler<String> {
String normalizedKey = normalizeKey(key);
if (!normalizedKey.isEmpty()
&& !registeredKeys.containsKey(normalizedKey)
&& !IrisStructureLocator.hasNativePlacement(activeEngine, key)) {
&& !ModuleServices.startsStructure(activeEngine, key)) {
suggestions.putIfAbsent(normalizedKey, key.trim());
}
}
@@ -116,9 +115,9 @@ public class StructureHandler implements DirectorParameterHandler<String> {
private static boolean isEligibleRegisteredKey(Engine engine, String key, String normalizedKey,
Set<String> reachableKeys, boolean nativeGenerationEnabled) {
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
boolean locatableNativePlacement = nativePlacement
&& IrisStructureLocator.hasLocatableNativePlacement(engine, key);
&& ModuleServices.canLocateStart(engine, key);
boolean locatableEditableReplacement = !nativePlacement
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
&& ModuleServices.canLocateStructure(engine, key);
@@ -60,8 +60,7 @@ public class BuiltInServicesTest {
@Test
public void theModulesThatNeedToHearAboutWorldsHearThem() {
assertEquals(List.of("iris:decorant", "iris:objects", "iris:structure", "iris:terrain"), BUILT_INS.lifecycles().stream()
assertEquals(List.of("iris:decorant", "iris:objects", "iris:terrain"), BUILT_INS.lifecycles().stream()
.map(LifecycleRegistration::module).map(module -> module.info().id().toString()).toList());
assertTrue(BUILT_INS.lifecycles().stream().anyMatch(registration -> registration.lifecycle() instanceof StructureModule));
}
}
@@ -53,6 +53,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -77,6 +78,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void isPlacedIsFalseForNullOrEmptyKey() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
assertFalse(IrisStructureLocator.isPlaced(engine, null));
assertFalse(IrisStructureLocator.isPlaced(engine, ""));
}
@@ -126,6 +128,7 @@ public class IrisStructureLocatorContractTest {
placements.add(editable);
placements.add(nativePlacement);
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
when(engine.getMinHeight()).thenReturn(-64);
@@ -154,6 +157,7 @@ public class IrisStructureLocatorContractTest {
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
IrisData data = mock(IrisData.class);
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
IrisDimension dimension = mock(IrisDimension.class);
IrisStructurePlacement placement = new IrisStructurePlacement()
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
@@ -175,6 +179,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void suppressesVanillaIsFalseForNullOrEmptyKey() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
assertFalse(IrisStructureLocator.suppressesVanilla(engine, null));
assertFalse(IrisStructureLocator.suppressesVanilla(engine, ""));
}
@@ -198,13 +203,15 @@ public class IrisStructureLocatorContractTest {
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
assertTrue(IrisStructureLocator.isPlaced(engine, "minecraft:ancient_city"));
assertFalse(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
placement.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
IrisStructureLocator.invalidate(engine);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
assertTrue(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
}
@@ -228,6 +235,8 @@ public class IrisStructureLocatorContractTest {
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
@@ -290,6 +299,7 @@ public class IrisStructureLocatorContractTest {
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
@@ -313,6 +323,7 @@ public class IrisStructureLocatorContractTest {
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
@@ -332,6 +343,7 @@ public class IrisStructureLocatorContractTest {
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
@@ -384,6 +396,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void locateReturnsNotFoundForNullOrEmptyKey() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND,
IrisStructureLocator.locate(engine, null, 0, 0, 100).status());
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND,
@@ -478,6 +491,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void searchableDensityRequiresPositiveProbabilityAndWorldHeightOverlap() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getMinHeight()).thenReturn(-64);
when(engine.getHeight()).thenReturn(384);
IrisStructurePlacement placement = new IrisStructurePlacement();
@@ -497,21 +511,16 @@ public class IrisStructureLocatorContractTest {
}
@Test
public void invalidateIsNullSafe() {
IrisStructureLocator.invalidate(null);
}
@Test
public void placementIndexIsScopedAndInvalidatedPerEngine() {
public void placementIndexIsKeptPerWorld() {
IrisData sharedData = mock(IrisData.class);
Engine firstEngine = emptyEngine(sharedData);
Engine secondEngine = emptyEngine(sharedData);
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstEngine);
Set<String> secondIndex = IrisStructureLocator.placedKeys(secondEngine);
assertNotSame(firstIndex, secondIndex);
assertSame(firstIndex, IrisStructureLocator.placedKeys(firstEngine));
assertNotSame(firstIndex, IrisStructureLocator.placedKeys(secondEngine));
IrisStructureLocator.invalidate(firstEngine);
assertNotSame(firstIndex, IrisStructureLocator.placedKeys(firstEngine));
when(firstEngine.getGeneration()).thenReturn(new EngineGeneration(firstEngine));
assertNotSame("a new world builds its own index", firstIndex, IrisStructureLocator.placedKeys(firstEngine));
}
@Test
@@ -604,6 +613,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void caveSearchabilityReservesVerticalBoundaryCells() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getMinHeight()).thenReturn(-64);
when(engine.getHeight()).thenReturn(384);
IrisStructurePlacement placement = new IrisStructurePlacement()
@@ -625,6 +635,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void undergroundAssemblyIsShiftedBelowEveryTerrainColumn() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getMinHeight()).thenReturn(-64);
when(engine.getHeight(anyInt(), anyInt(), eq(true)))
.thenAnswer(invocation -> invocation.<Integer>getArgument(0) == 1 ? 140 : 164);
@@ -647,6 +658,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void undergroundBurialIncludesForceCarveCeiling() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getMinHeight()).thenReturn(-64);
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
IrisStructurePlacement placement = new IrisStructurePlacement();
@@ -676,6 +688,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void zeroForceCarvePaddingDoesNotExpandTheBurialEnvelope() {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getMinHeight()).thenReturn(-64);
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
IrisStructurePlacement placement = new IrisStructurePlacement()
@@ -781,6 +794,7 @@ public class IrisStructureLocatorContractTest {
private Engine emptyEngine(IrisData data) {
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
IrisDimension dimension = mock(IrisDimension.class);
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
@@ -807,6 +821,8 @@ public class IrisStructureLocatorContractTest {
placement.setMaxHeight(placementMax);
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
IrisDimension dimension = mock(IrisDimension.class);
KList<IrisStructurePlacement> placements = new KList<>();
placements.add(placement);
@@ -171,6 +171,7 @@ public class IrisStructurePlacementRingLocatorTest {
IrisData data = mock(IrisData.class);
IrisDimension dimension = mock(IrisDimension.class);
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
KList<IrisStructurePlacement> configured = new KList<>();
for (IrisStructurePlacement placement : placements) {
configured.add(placement);
@@ -236,6 +236,7 @@ public class NativeStructureGenerationPolicyTest {
KList<IrisStructurePlacement> dimensionPlacements, List<IrisModule> packModules) throws IOException {
IrisData data = mock(IrisData.class);
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
IrisDimension dimension = mock(IrisDimension.class);
IrisRegion region = mock(IrisRegion.class);
when(region.getStructures()).thenReturn(regionPlacements);
@@ -57,6 +57,7 @@ public class NativeStructureVolumeSuppressionTest {
StructureSettings settings = new StructureSettings(List.of("minecraft:village"), List.of(), 0, true, List.of(), List.of());
IrisDimension dimension = mock(IrisDimension.class);
Engine engine = mock(Engine.class);
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
IrisData data = mock(IrisData.class);
packs.add(BuiltInPack.serveWithResources(data, folder, List.of()));
when(engine.getData()).thenReturn(data);
@@ -1,10 +1,16 @@
package art.arcane.iris.engine.framework;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.spi.PlatformRegistries;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.matter.MatterCavern;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
@@ -19,6 +25,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -27,6 +34,22 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class StructureCaveAnchorResolverTest {
@Before
public void bindPlatform() {
IrisPlatforms.unbind();
PlatformBlockState block = mock(PlatformBlockState.class);
PlatformRegistries registries = mock(PlatformRegistries.class);
when(registries.block(anyString())).thenReturn(block);
IrisPlatform platform = mock(IrisPlatform.class);
when(platform.registries()).thenReturn(registries);
IrisPlatforms.bind(platform);
}
@After
public void unbindPlatform() {
IrisPlatforms.unbind();
}
@Test
public void floorRequiresSolidBoundaryAndUpwardClearance() {
IntPredicate carved = carvedAt(10, 11, 12, 13);
@@ -87,12 +87,6 @@ public class StructureReachabilityContractTest {
() -> StructureReachability.missingBiomeKeys(engine, "minecraft:village_taiga"));
}
@Test
public void invalidateIsNullSafe() {
StructureReachability.invalidate(null);
StructureReachability.invalidate(mock(Engine.class));
}
@Test
public void failedReachabilityBuildIsNotCachedAsEmpty() {
Engine engine = mock(Engine.class);
@@ -102,6 +96,7 @@ public class StructureReachabilityContractTest {
PlatformStructureHooks hooks = mock(PlatformStructureHooks.class);
IllegalStateException cause = new IllegalStateException("registry unavailable");
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
when(engine.getWorld()).thenReturn(world);
when(world.platformWorld()).thenReturn(platformWorld);
when(platform.structureHooks()).thenReturn(hooks);
@@ -115,7 +110,6 @@ public class StructureReachabilityContractTest {
assertThrows(IllegalStateException.class, () -> StructureReachability.reachableKeys(engine));
assertTrue(StructureReachability.reachableKeys(engine).contains("minecraft:monument"));
} finally {
StructureReachability.invalidate(engine);
IrisPlatforms.unbind();
}
}
@@ -8,9 +8,7 @@ import art.arcane.iris.engine.mantle.components.StructureModule;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.EngineGeneration;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.mantle.components.StructureModule;
import art.arcane.iris.engine.framework.StructureReachability;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
import art.arcane.iris.engine.object.structure.IrisStructure;
@@ -151,8 +149,6 @@ public class StructureHandlerTest {
verify(hooks, times(1)).structureKeys();
verify(hooks, times(1)).reachableStructureKeys(platformWorld);
} finally {
IrisStructureLocator.invalidate(engine);
StructureReachability.invalidate(engine);
IrisPlatforms.unbind();
}
}
@@ -213,8 +209,6 @@ public class StructureHandlerTest {
assertFalse(possibilities.contains("minecraft:explicit"));
assertFalse(possibilities.contains("minecraft:reachable"));
} finally {
IrisStructureLocator.invalidate(engine);
StructureReachability.invalidate(engine);
IrisPlatforms.unbind();
}
}