diff --git a/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingBoundaryRadiusTest.java b/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingBoundaryRadiusTest.java index 76692e0d1..8dcefee7c 100644 --- a/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingBoundaryRadiusTest.java +++ b/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingBoundaryRadiusTest.java @@ -18,13 +18,15 @@ package art.arcane.iris.engine.mantle.components; +import art.arcane.iris.engine.framework.EngineGeneration; +import art.arcane.iris.engine.object.TestSettings; +import art.arcane.iris.builtin.floating.FloatingChildBiome; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.core.loader.ResourceLoader; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.dimension.IrisDimension; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; import art.arcane.iris.engine.object.prefab.IrisObject; import art.arcane.iris.engine.object.prefab.IrisObjectTranslate; import art.arcane.iris.spi.IrisPlatform; @@ -93,8 +95,7 @@ public class FloatingObjectPlacingBoundaryRadiusTest { IrisObjectPlacement placement = new IrisObjectPlacement() .setPlace(new KList<>("test/floating")) .setTranslate(new IrisObjectTranslate().setX(32)); - IrisFloatingChildBiomes floatingChild = new IrisFloatingChildBiomes() - .setFloatingObjects(new KList<>(placement)); + FloatingChildBiome floatingChild = TestSettings.with(new FloatingChildBiome(), "floatingObjects", new KList<>(placement)); IrisBiome biome = new IrisBiome().setFloatingChildBiomes(new KList<>(floatingChild)); IrisDimension dimension = mock(IrisDimension.class); when(dimension.getReachableBiomes(org.mockito.ArgumentMatchers.any())).thenReturn(new KList<>(biome)); @@ -107,6 +108,7 @@ public class FloatingObjectPlacingBoundaryRadiusTest { Engine engine = mock(Engine.class); when(engine.getDimension()).thenReturn(dimension); when(engine.getData()).thenReturn(data); + when(engine.getGeneration()).thenReturn(new EngineGeneration(engine)); assertEquals(33, new FloatingObjectPlacing(engine).reach()); } diff --git a/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingInvertedPlacementTest.java b/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingInvertedPlacementTest.java index 1b8e2129c..39613661d 100644 --- a/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingInvertedPlacementTest.java +++ b/core/src/test/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacingInvertedPlacementTest.java @@ -1,8 +1,9 @@ package art.arcane.iris.engine.mantle.components; +import art.arcane.iris.builtin.floating.FloatingChildBiome; +import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample; import art.arcane.iris.engine.object.placement.FloatingObjectFootprint; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; import art.arcane.iris.engine.object.prefab.IrisObjectRotation; import org.junit.Test; @@ -48,9 +49,9 @@ public class FloatingObjectPlacingInvertedPlacementTest { ); } - private FloatingIslandSample sample(IrisFloatingChildBiomes entry) throws Exception { + private FloatingIslandSample sample(ResolvedFloatingChild entry) throws Exception { Constructor constructor = FloatingIslandSample.class.getDeclaredConstructor( - IrisFloatingChildBiomes.class, + ResolvedFloatingChild.class, int.class, int.class, int.class, @@ -110,7 +111,7 @@ public class FloatingObjectPlacingInvertedPlacementTest { @Test public void topFootprintChecksNeighborChunkTerrain() throws Exception { - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); + ResolvedFloatingChild entry = new ResolvedFloatingChild(new FloatingChildBiome()); FloatingIslandSample sample = sample(entry); long[] cells = {0L, 1L << 32}; FloatingObjectFootprint footprint = footprint(0, 0, 0, 0, cells); diff --git a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildBiomeDecodingTest.java b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildBiomeDecodingTest.java new file mode 100644 index 000000000..76ef7d2af --- /dev/null +++ b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildBiomeDecodingTest.java @@ -0,0 +1,157 @@ +/* + * 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 . + */ + +package art.arcane.iris.engine.object.terrain.floating; + +import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode; +import art.arcane.iris.builtin.floating.FloatingChildBiome; +import art.arcane.iris.builtin.floating.OverrideMode; +import art.arcane.iris.builtin.floating.TopShapeMode; +import art.arcane.iris.core.loader.IrisData; +import art.arcane.iris.engine.object.world.biome.IrisBiome; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.CALLS_REAL_METHODS; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +/** The floating child of the overworld pack's magnetics/dunes biome, read into {@link FloatingChildBiome} with the values Iris's own class read from the same JSON. */ +public class FloatingChildBiomeDecodingTest { + private static final String DUNES_CHILD = """ + {"biome": "magnetics/dunes", "rarity": 1, + "footprintStyle": {"style": "CELLULAR_IRIS", "zoom": 0.55, "fracture": {"style": "SIMPLEX", "zoom": 0.2, "multiplier": 4}}, + "footprintThreshold": 0.52, "pickerStyle": {"style": "SIMPLEX", "zoom": 4.0}, "altitudeStyle": {"style": "SIMPLEX", "zoom": 2.6}, + "minHeightAboveSurface": 90, "maxHeightAboveSurface": 130, "topShapeMode": "NOISE", "maxTopHeight": 16, + "topShapeStyle": {"style": "FRACTAL_SMOKE", "zoom": 0.45, "fracture": {"style": "SIMPLEX", "zoom": 0.22, "multiplier": 4}}, + "topShapeAmp": 0.75, "edgeTaperWidth": 14, "edgeTaperExponent": 1.45, + "edgeTaperVariationStyle": {"style": "SIMPLEX", "zoom": 0.18}, "edgeTaperVariationAmplitude": 4, + "bottomStyle": {"style": "SIMPLEX_VASCULAR", "zoom": 0.28}, "bottomDepthMin": 5, "bottomDepthMax": 48, "bottomExponent": 2.35, + "bottomPaletteMode": "CUSTOM", + "bottomPalette": [{"minHeight": 2, "maxHeight": 5, "palette": [{"block": "minecraft:sandstone"}, {"block": "minecraft:smooth_sandstone"}]}], + "maxThickness": 72, "wallWarpStyle": {"style": "SIMPLEX", "zoom": 0.24}, "wallWarpAmplitude": 5, + "carving": "carving/sand-hollows-child", "carveStyle": {"style": "SIMPLEX", "zoom": 0.2}, "carveThreshold": 0.86, + "inheritDecorators": true, "inheritObjects": false, "objectShrinkFactor": 0.55, "topObjectMode": "MERGE", + "topObjectOverrides": [{"place": ["clutter/boulder1"], "chance": 0.55, "mode": "CENTER_HEIGHT", "density": 5}, + {"place": ["clutter/shrub1"], "chance": 0.42, "density": 4}], + "bottomObjectMode": "REPLACE", + "bottomObjectOverrides": [{"place": ["clutter/bone4"], "chance": 0.04, "mode": "FAST_MIN_HEIGHT", "density": 1}]} + """; + + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + + private Gson gson; + + @Before + public void decodeLikeIrisDoes() { + IrisData data = mock(IrisData.class, CALLS_REAL_METHODS); + doReturn(folder.getRoot()).when(data).getDataFolder(); + gson = new GsonBuilder().registerTypeAdapterFactory(data).create(); + } + + @Test + public void theMagneticsDunesChildReadsEveryFieldIrisReadFromIt() { + FloatingChildBiome child = gson.fromJson(DUNES_CHILD, FloatingChildBiome.class); + + assertEquals("magnetics/dunes", child.biome()); + assertEquals("CELLULAR_IRIS", child.footprintStyle().style()); + assertEquals(0.55, child.footprintStyle().zoom(), 0); + assertEquals("SIMPLEX", child.footprintStyle().fracture().orElseThrow().style()); + assertEquals(4, child.footprintStyle().fracture().orElseThrow().multiplier(), 0); + assertEquals(0.52, child.footprintThreshold(), 0); + assertEquals(4.0, child.pickerStyle().zoom(), 0); + assertEquals(90, child.minHeightAboveSurface()); + assertEquals(TopShapeMode.NOISE, child.topShapeMode()); + assertEquals(14, child.edgeTaperWidth()); + assertEquals(1.45, child.edgeTaperExponent(), 0); + assertEquals(4, child.edgeTaperVariationAmplitude(), 0); + assertEquals(FloatingBottomPaletteMode.CUSTOM, child.bottomPaletteMode()); + assertEquals(1, child.bottomPalette().size()); + assertEquals(5, child.bottomPalette().get(0).getMaxHeight()); + assertEquals("SIMPLEX", child.wallWarpStyle().orElseThrow().style()); + assertEquals(5, child.wallWarpAmplitude(), 0); + assertEquals("carving/sand-hollows-child", child.carving()); + assertEquals(0.86, child.carveThreshold(), 0); + assertFalse(child.inheritObjects()); + assertEquals(0.55, child.objectShrinkFactor(), 0); + assertEquals(OverrideMode.MERGE, child.topObjectMode()); + assertEquals(2, child.topObjectOverrides().size()); + assertEquals(5, child.topObjectOverrides().get(0).getDensity()); + assertEquals(OverrideMode.REPLACE, child.bottomObjectMode()); + assertEquals("clutter/bone4", child.bottomObjectOverrides().get(0).getPlace().get(0)); + } + + @Test + public void anEmptyChildHasIrisDefaults() { + FloatingChildBiome child = gson.fromJson("{}", FloatingChildBiome.class); + + assertEquals("", child.biome()); + assertEquals(1, child.rarity()); + assertEquals("SIMPLEX", child.footprintStyle().style()); + assertEquals(0.18, child.edgeTaperVariationStyle().zoom(), 0); + assertEquals(0.5, child.footprintThreshold(), 0); + assertEquals(10, child.edgeTaperWidth()); + assertEquals(160, child.minHeightAboveSurface()); + assertEquals(210, child.maxHeightAboveSurface()); + assertEquals(TopShapeMode.BIOME, child.topShapeMode()); + assertEquals(FloatingBottomPaletteMode.DEPTH, child.bottomPaletteMode()); + assertTrue(child.wallWarpStyle().isEmpty()); + assertTrue(child.carveStyle().isEmpty()); + assertTrue(child.minAbsoluteY().isEmpty()); + assertTrue(child.localFluidHeight().isEmpty()); + assertEquals("minecraft:water", child.fluidBlock()); + assertTrue(child.inheritDecorators() && child.inheritObjects()); + assertEquals(OverrideMode.INHERIT_ONLY, child.topObjectMode()); + assertEquals(96, child.maxThickness()); + assertEquals(1.0, child.carveThreshold(), 0); + assertTrue(child.topObjectOverrides().isEmpty()); + assertNull(child.color().isEmpty() ? null : child.color()); + } + + @Test + public void aBiomeHoldsItsChildrenAsSettings() { + IrisBiome biome = gson.fromJson("{\"floatingChildBiomes\": [" + DUNES_CHILD + ", {}]}", IrisBiome.class); + + assertEquals(2, biome.getFloatingChildBiomes().size()); + assertEquals("magnetics/dunes", biome.getFloatingChildBiomes().get(0).biome()); + assertNotNull(biome.getFloatingChildBiomes().get(1)); + } + + @Test + public void theEdgeTaperProfileKeepsTheSettingsWidthExponentAndVariation() { + FloatingChildBiome child = gson.fromJson(DUNES_CHILD, FloatingChildBiome.class); + ResolvedFloatingChild resolved = new ResolvedFloatingChild(child); + + FloatingIslandEdgeProfile profile = resolved.getEdgeTaperProfile(77L, mock(IrisData.class)); + + assertEquals(14, profile.width()); + assertEquals(1.45, profile.exponent(), 0); + assertEquals(4, profile.variationAmplitude(), 0); + assertEquals(2, resolved.getRarity() + 1); + } +} diff --git a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandBoundarySamplerTest.java b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandBoundarySamplerTest.java index d823a7967..996a82d01 100644 --- a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandBoundarySamplerTest.java +++ b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandBoundarySamplerTest.java @@ -18,10 +18,11 @@ package art.arcane.iris.engine.object.terrain.floating; +import art.arcane.iris.builtin.floating.FloatingChildBiome; +import art.arcane.iris.engine.object.TestSettings; +import art.arcane.iris.builtin.floating.TopShapeMode; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; -import art.arcane.iris.engine.object.terrain.floating.TopShapeMode; import art.arcane.iris.engine.object.world.IrisWorld; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.core.loader.IrisData; @@ -403,9 +404,9 @@ public class FloatingIslandBoundarySamplerTest { @Test public void ownershipFade_tapersAcrossPickerBoundary() { - IrisFloatingChildBiomes left = new IrisFloatingChildBiomes().setRarity(1); - IrisFloatingChildBiomes right = new IrisFloatingChildBiomes().setRarity(1); - KList entries = new KList<>(); + ResolvedFloatingChild left = new ResolvedFloatingChild(new FloatingChildBiome()); + ResolvedFloatingChild right = new ResolvedFloatingChild(new FloatingChildBiome()); + KList entries = new KList<>(); entries.add(left); entries.add(right); CNG picker = new CNG(new RNG(18)) { @@ -432,9 +433,9 @@ public class FloatingIslandBoundarySamplerTest { @Test public void ownershipFade_rejectsThinPickerRegion() { - IrisFloatingChildBiomes left = new IrisFloatingChildBiomes().setRarity(1); - IrisFloatingChildBiomes right = new IrisFloatingChildBiomes().setRarity(1); - KList entries = new KList<>(); + ResolvedFloatingChild left = new ResolvedFloatingChild(new FloatingChildBiome()); + ResolvedFloatingChild right = new ResolvedFloatingChild(new FloatingChildBiome()); + KList entries = new KList<>(); entries.add(left); entries.add(right); CNG picker = new CNG(new RNG(24)) { @@ -462,9 +463,9 @@ public class FloatingIslandBoundarySamplerTest { leftParent.setLoadKey("left"); IrisBiome rightParent = new IrisBiome(); rightParent.setLoadKey("right"); - IrisFloatingChildBiomes leftChild = new IrisFloatingChildBiomes().setRarity(1); - IrisFloatingChildBiomes rightChild = new IrisFloatingChildBiomes().setRarity(1); - KList entries = new KList<>(); + ResolvedFloatingChild leftChild = new ResolvedFloatingChild(new FloatingChildBiome()); + ResolvedFloatingChild rightChild = new ResolvedFloatingChild(new FloatingChildBiome()); + KList entries = new KList<>(); entries.add(leftChild); entries.add(rightChild); CNG picker = new CNG(new RNG(29)) { @@ -494,9 +495,9 @@ public class FloatingIslandBoundarySamplerTest { public void sampler_fieldsPublishSafelyAcrossConcurrentReaders() throws Exception { IrisBiome parent = new IrisBiome(); parent.setLoadKey("parent"); - IrisFloatingChildBiomes left = new IrisFloatingChildBiomes().setRarity(1); - IrisFloatingChildBiomes right = new IrisFloatingChildBiomes().setRarity(1); - KList entries = new KList<>(); + ResolvedFloatingChild left = new ResolvedFloatingChild(new FloatingChildBiome()); + ResolvedFloatingChild right = new ResolvedFloatingChild(new FloatingChildBiome()); + KList entries = new KList<>(); entries.add(left); entries.add(right); CNG constant = new CNG(new RNG(26)) { @@ -555,46 +556,32 @@ public class FloatingIslandBoundarySamplerTest { return 1.0D; } }; - IrisFloatingChildBiomes entry = mock(IrisFloatingChildBiomes.class); + ResolvedFloatingChild entry = mock(ResolvedFloatingChild.class); IrisBiome parent = mock(IrisBiome.class); IrisData data = mock(IrisData.class); Engine engine = mock(Engine.class); IrisWorld world = IrisWorld.builder().minHeight(0).maxHeight(320).build(); - KList entries = new KList<>(); + KList entries = new KList<>(); entries.add(entry); - when(parent.getFloatingChildBiomes()).thenReturn(entries); when(parent.isMergeFloatingChildBiomes()).thenReturn(false); when(entry.getFootprintCng(anyLong(), same(data))).thenReturn(footprint); - when(entry.getFootprintThreshold()).thenReturn(0.5D); when(entry.getAltitudeCng(anyLong(), same(data))).thenReturn(constant); - when(entry.getMinHeightAboveSurface()).thenReturn(160); - when(entry.getMaxHeightAboveSurface()).thenReturn(160); when(entry.getRealBiome(parent, data)).thenReturn(parent); - when(entry.getTopShapeMode()).thenReturn(TopShapeMode.NOISE); when(entry.getTopShapeCng(anyLong(), same(data))).thenReturn(constant); - when(entry.getTopShapeAmp()).thenReturn(1.0D); - when(entry.getMaxTopHeight()).thenReturn(18); when(entry.getBottomCng(anyLong(), same(data))).thenReturn(constant); - when(entry.getBottomExponent()).thenReturn(1.0D); - when(entry.getBottomDepthMin()).thenReturn(20); - when(entry.getBottomDepthMax()).thenReturn(20); - when(entry.getMaxThickness()).thenReturn(64); - when(entry.getMinAbsoluteY()).thenReturn(null); - when(entry.getMaxAbsoluteY()).thenReturn(null); when(entry.getWallWarpCng(anyLong(), same(data))).thenReturn(null); - when(entry.getWallWarpAmplitude()).thenReturn(0.0D); when(entry.getCarvingProfileSampler(engine, data)).thenReturn(null); when(entry.hasCarvingReference()).thenReturn(false); when(entry.getCarveCng(anyLong(), same(data))).thenReturn(constant); - when(entry.getCarveThreshold()).thenReturn(0.5D); + when(entry.settings()).thenReturn(TestSettings.with(new FloatingChildBiome(), "footprintThreshold", 0.5D, "minHeightAboveSurface", 160, "maxHeightAboveSurface", 160, "topShapeMode", TopShapeMode.NOISE, "topShapeAmp", 1.0D, "maxTopHeight", 18, "bottomExponent", 1.0D, "bottomDepthMin", 20, "bottomDepthMax", 20, "maxThickness", 64, "wallWarpAmplitude", 0.0D, "carveThreshold", 0.5D)); when(engine.getWorld()).thenReturn(world); FloatingIslandBoundarySampler sampler = new FloatingIslandBoundarySampler((x, z) -> parent); int[] expectedBottom = {159, 158, 156, 153, 150, 147, 144, 142, 141, 140}; int[] expectedTop = {161, 162, 164, 166, 169, 172, 174, 176, 177, 178}; - assertNull(FloatingIslandSample.sample(parent, 0, 0, 320, 31L, data, engine, sampler)); + assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 31L, data, engine, sampler)); for (int i = 0; i < expectedBottom.length; i++) { - FloatingIslandSample sample = FloatingIslandSample.sample(parent, i + 1, 0, 320, 31L, data, engine, sampler); + FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, i + 1, 0, 320, 31L, data, engine, sampler); assertNotNull("distance " + (i + 2) + " rejected with code " + FloatingIslandSample.getLastReject(), sample); assertEquals(expectedBottom[i], sample.bottomY()); assertEquals(expectedTop[i], sample.topY()); @@ -634,49 +621,34 @@ public class FloatingIslandBoundarySamplerTest { return 1.0D; } }; - IrisFloatingChildBiomes lower = mock(IrisFloatingChildBiomes.class); - IrisFloatingChildBiomes upper = mock(IrisFloatingChildBiomes.class); + ResolvedFloatingChild lower = mock(ResolvedFloatingChild.class); + ResolvedFloatingChild upper = mock(ResolvedFloatingChild.class); IrisBiome parent = mock(IrisBiome.class); IrisData data = mock(IrisData.class); Engine engine = mock(Engine.class); IrisWorld world = IrisWorld.builder().minHeight(0).maxHeight(320).build(); - KList entries = new KList<>(); + KList entries = new KList<>(); entries.add(lower); entries.add(upper); - when(parent.getFloatingChildBiomes()).thenReturn(entries); when(parent.isMergeFloatingChildBiomes()).thenReturn(true); - for (IrisFloatingChildBiomes entry : entries) { + for (ResolvedFloatingChild entry : entries) { when(entry.getFootprintCng(anyLong(), same(data))).thenReturn(footprint); - when(entry.getFootprintThreshold()).thenReturn(0.5D); when(entry.getAltitudeCng(anyLong(), same(data))).thenReturn(constant); when(entry.getRealBiome(parent, data)).thenReturn(parent); - when(entry.getTopShapeMode()).thenReturn(TopShapeMode.NOISE); when(entry.getTopShapeCng(anyLong(), same(data))).thenReturn(constant); - when(entry.getTopShapeAmp()).thenReturn(1.0D); - when(entry.getMaxTopHeight()).thenReturn(18); when(entry.getBottomCng(anyLong(), same(data))).thenReturn(constant); - when(entry.getBottomExponent()).thenReturn(1.0D); - when(entry.getBottomDepthMin()).thenReturn(20); - when(entry.getBottomDepthMax()).thenReturn(20); - when(entry.getMaxThickness()).thenReturn(64); - when(entry.getMinAbsoluteY()).thenReturn(null); - when(entry.getMaxAbsoluteY()).thenReturn(null); when(entry.getWallWarpCng(anyLong(), same(data))).thenReturn(null); - when(entry.getWallWarpAmplitude()).thenReturn(0.0D); when(entry.getCarvingProfileSampler(engine, data)).thenReturn(null); when(entry.hasCarvingReference()).thenReturn(false); when(entry.getCarveCng(anyLong(), same(data))).thenReturn(null); - when(entry.getCarveThreshold()).thenReturn(1.0D); + when(entry.settings()).thenReturn(TestSettings.with(new FloatingChildBiome(), "footprintThreshold", 0.5D, "topShapeMode", TopShapeMode.NOISE, "topShapeAmp", 1.0D, "maxTopHeight", 18, "bottomExponent", 1.0D, "bottomDepthMin", 20, "bottomDepthMax", 20, "maxThickness", 64, "wallWarpAmplitude", 0.0D, "carveThreshold", 1.0D, + "minHeightAboveSurface", entry == lower ? 160 : 180, "maxHeightAboveSurface", entry == lower ? 160 : 180)); } - when(lower.getMinHeightAboveSurface()).thenReturn(160); - when(lower.getMaxHeightAboveSurface()).thenReturn(160); - when(upper.getMinHeightAboveSurface()).thenReturn(180); - when(upper.getMaxHeightAboveSurface()).thenReturn(180); when(engine.getWorld()).thenReturn(world); FloatingIslandBoundarySampler sampler = new FloatingIslandBoundarySampler((x, z) -> parent); - assertNull(FloatingIslandSample.sample(parent, 0, 0, 320, 35L, data, engine, sampler)); - FloatingIslandSample sample = FloatingIslandSample.sample(parent, 1, 0, 320, 35L, data, engine, sampler); + assertNull(FloatingIslandSample.sample(parent, entries, 0, 0, 320, 35L, data, engine, sampler)); + FloatingIslandSample sample = FloatingIslandSample.sample(parent, entries, 1, 0, 320, 35L, data, engine, sampler); assertNotNull(sample); assertTrue(sample.hasMergedEntries()); diff --git a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSampleBottomYTest.java b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSampleBottomYTest.java index cb138a1c6..b1c13762b 100644 --- a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSampleBottomYTest.java +++ b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSampleBottomYTest.java @@ -1,7 +1,8 @@ package art.arcane.iris.engine.object.terrain.floating; +import art.arcane.iris.engine.object.TestSettings; +import art.arcane.iris.builtin.floating.FloatingChildBiome; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; import art.arcane.iris.util.project.noise.CNG; import art.arcane.iris.util.project.noise.NoiseGenerator; import art.arcane.volmlib.util.math.RNG; @@ -62,10 +63,10 @@ public class FloatingIslandSampleBottomYTest { @Test public void mergedEntryMask_preservesTopAndBottomOwners() { - IrisFloatingChildBiomes bottom = new IrisFloatingChildBiomes(); - IrisFloatingChildBiomes top = new IrisFloatingChildBiomes(); + ResolvedFloatingChild bottom = new ResolvedFloatingChild(new FloatingChildBiome()); + ResolvedFloatingChild top = new ResolvedFloatingChild(new FloatingChildBiome()); boolean[] mask = {true, true, false, true}; - IrisFloatingChildBiomes[] entryMask = {bottom, bottom, null, top}; + ResolvedFloatingChild[] entryMask = {bottom, bottom, null, top}; FloatingIslandSample sample = FloatingIslandSample.constructForTest(top, 80, mask.length, 3, 3, mask, entryMask); assertSame(top, sample.entry); @@ -327,8 +328,7 @@ public class FloatingIslandSampleBottomYTest { @Test public void directCarveEnabled_respectsCarvingReferenceOverride() { - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setCarving("carving/mushroom"); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "carving", "carving/mushroom")); CNG carve = new CNG(new RNG(9)); assertFalse(FloatingIslandSample.directCarveEnabled(entry, null, carve, 0.5)); diff --git a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/IrisFloatingChildBiomesCarvingResolutionTest.java b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChildCarvingResolutionTest.java similarity index 91% rename from core/src/test/java/art/arcane/iris/engine/object/terrain/floating/IrisFloatingChildBiomesCarvingResolutionTest.java rename to core/src/test/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChildCarvingResolutionTest.java index 3b545b22d..72cac9e5b 100644 --- a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/IrisFloatingChildBiomesCarvingResolutionTest.java +++ b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChildCarvingResolutionTest.java @@ -1,6 +1,5 @@ package art.arcane.iris.engine.object.terrain.floating; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry; @@ -28,7 +27,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -public class IrisFloatingChildBiomesCarvingResolutionTest { +public class ResolvedFloatingChildCarvingResolutionTest { @BeforeClass public static void setupBukkit() { if (Bukkit.getServer() != null) { @@ -60,7 +59,7 @@ public class IrisFloatingChildBiomesCarvingResolutionTest { IrisBiome biome = mock(IrisBiome.class); Fixture fixture = createFixture(Map.of(), Map.of("carving/mushroom", biome)); - IrisBiome resolved = IrisFloatingChildBiomes.resolveCarvingBiome("carving/mushroom", fixture.engine, fixture.data); + IrisBiome resolved = ResolvedFloatingChild.resolveCarvingBiome("carving/mushroom", fixture.engine, fixture.data); assertSame(biome, resolved); } @@ -82,7 +81,7 @@ public class IrisFloatingChildBiomesCarvingResolutionTest { Fixture fixture = createFixture(entries, biomes); - IrisBiome resolved = IrisFloatingChildBiomes.resolveCarvingBiome("global-deepdark-band", fixture.engine, fixture.data); + IrisBiome resolved = ResolvedFloatingChild.resolveCarvingBiome("global-deepdark-band", fixture.engine, fixture.data); assertSame(entryBiome, resolved); } diff --git a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/IrisFloatingChildBiomesResolverTest.java b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChildTest.java similarity index 67% rename from core/src/test/java/art/arcane/iris/engine/object/terrain/floating/IrisFloatingChildBiomesResolverTest.java rename to core/src/test/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChildTest.java index f6d7373ae..e6e3df35d 100644 --- a/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/IrisFloatingChildBiomesResolverTest.java +++ b/core/src/test/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChildTest.java @@ -1,24 +1,23 @@ package art.arcane.iris.engine.object.terrain.floating; +import art.arcane.iris.builtin.floating.FloatingChildBiome; +import art.arcane.iris.engine.object.TestSettings; +import art.arcane.iris.builtin.floating.OverrideMode; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; -import art.arcane.iris.engine.object.terrain.floating.OverrideMode; import art.arcane.volmlib.util.collection.KList; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class IrisFloatingChildBiomesResolverTest { +public class ResolvedFloatingChildTest { @Test public void resolveTopObjects_inheritOnly_withInheritTrue_returnsSurfaceObjects() { IrisObjectPlacement placement = new IrisObjectPlacement(); KList surface = new KList<>(); surface.add(placement); - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setInheritObjects(true); - entry.setTopObjectMode(OverrideMode.INHERIT_ONLY); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.INHERIT_ONLY)); KList result = entry.resolveTopObjectsFromSurface(surface); @@ -34,10 +33,7 @@ public class IrisFloatingChildBiomesResolverTest { KList overrides = new KList<>(); overrides.add(overridePlacement); - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setInheritObjects(true); - entry.setTopObjectMode(OverrideMode.REPLACE); - entry.setTopObjectOverrides(overrides); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.REPLACE, "topObjectOverrides", overrides)); KList result = entry.resolveTopObjectsFromSurface(surface); @@ -54,10 +50,7 @@ public class IrisFloatingChildBiomesResolverTest { KList overrides = new KList<>(); overrides.add(overridePlacement); - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setInheritObjects(true); - entry.setTopObjectMode(OverrideMode.MERGE); - entry.setTopObjectOverrides(overrides); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.MERGE, "topObjectOverrides", overrides)); KList result = entry.resolveTopObjectsFromSurface(surface); @@ -68,8 +61,7 @@ public class IrisFloatingChildBiomesResolverTest { @Test public void resolveTopObjects_inheritOnly_emptySurface_returnsEmpty() { - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setTopObjectMode(OverrideMode.INHERIT_ONLY); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "topObjectMode", OverrideMode.INHERIT_ONLY)); KList result = entry.resolveTopObjectsFromSurface(new KList<>()); @@ -78,8 +70,7 @@ public class IrisFloatingChildBiomesResolverTest { @Test public void resolveBottomObjects_inheritOnly_returnsEmptyList() { - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setBottomObjectMode(OverrideMode.INHERIT_ONLY); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "bottomObjectMode", OverrideMode.INHERIT_ONLY)); KList result = entry.resolveBottomObjects(null); @@ -92,9 +83,7 @@ public class IrisFloatingChildBiomesResolverTest { KList overrides = new KList<>(); overrides.add(overridePlacement); - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setBottomObjectMode(OverrideMode.REPLACE); - entry.setBottomObjectOverrides(overrides); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "bottomObjectMode", OverrideMode.REPLACE, "bottomObjectOverrides", overrides)); KList result = entry.resolveBottomObjects(null); @@ -104,9 +93,7 @@ public class IrisFloatingChildBiomesResolverTest { @Test public void resolveTopObjects_inheritTrue_nullTargetProduces_emptySurface() { - IrisFloatingChildBiomes entry = new IrisFloatingChildBiomes(); - entry.setInheritObjects(true); - entry.setTopObjectMode(OverrideMode.INHERIT_ONLY); + ResolvedFloatingChild entry = new ResolvedFloatingChild(TestSettings.with(new FloatingChildBiome(), "inheritObjects", true, "topObjectMode", OverrideMode.INHERIT_ONLY)); KList result = entry.resolveTopObjects(null); diff --git a/core/src/test/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionReachableBiomesTest.java b/core/src/test/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionReachableBiomesTest.java index 2b755a969..20472e03c 100644 --- a/core/src/test/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionReachableBiomesTest.java +++ b/core/src/test/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionReachableBiomesTest.java @@ -1,6 +1,7 @@ package art.arcane.iris.engine.object.world.dimension; -import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes; +import art.arcane.iris.builtin.floating.FloatingChildBiome; +import art.arcane.iris.engine.object.TestSettings; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry; @@ -141,11 +142,11 @@ public class IrisDimensionReachableBiomesTest { return biome; } - private IrisFloatingChildBiomes floating(String biomeKey) { - return new IrisFloatingChildBiomes().setBiome(biomeKey); + private FloatingChildBiome floating(String biomeKey) { + return TestSettings.with(new FloatingChildBiome(), "biome", biomeKey); } - private IrisFloatingChildBiomes floating(String biomeKey, String carvingKey) { - return floating(biomeKey).setCarving(carvingKey); + private FloatingChildBiome floating(String biomeKey, String carvingKey) { + return TestSettings.with(new FloatingChildBiome(), "biome", biomeKey, "carving", carvingKey); } }