mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
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:
1 parent
0cfcada4f2
commit
7d9fd3faa6
24 files changed
+385
-126
No files matched your search
@@ -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));
|
||||
}
|
||||
}
|
||||
+27
-11
@@ -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);
|
||||
|
||||
+1
@@ -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);
|
||||
|
||||
+1
@@ -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);
|
||||
|
||||
+1
@@ -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);
|
||||
|
||||
+24
-1
@@ -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);
|
||||
|
||||
+1
-7
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
-6
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user