Merge branch 'wave3/c' into feat/irisapi-host

# Conflicts:
#	core/src/test/java/art/arcane/iris/core/modules/DecorantSettingsDecodingTest.java
#	core/src/test/java/art/arcane/iris/engine/actuator/TerrainModuleTest.java
#	core/src/test/java/art/arcane/iris/engine/object/world/biome/IrisBiomeInferenceIsolationTest.java
This commit is contained in:
piexel committed 2026-10-10 13:05:52 +02:00
commit 94f7551fa0
33 files changed
+2469 -320

No files matched your search

@@ -11,7 +11,6 @@ import art.arcane.iris.engine.framework.GenerationSessionException;
import art.arcane.iris.engine.framework.GenerationSessionLease;
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.IrisDimensionCarvingResolver;
import art.arcane.iris.util.project.context.IrisContext;
import art.arcane.volmlib.util.collection.KMap;
import art.arcane.volmlib.util.math.RNG;
@@ -440,16 +439,6 @@ public class CustomBiomeSource extends BiomeSource {
int y,
int z,
Climate.Sampler sampler
) {
return getVisibleNoiseBiomeWithActiveGenerationLease(x, y, z, sampler, null);
}
Holder<Biome> getVisibleNoiseBiomeWithActiveGenerationLease(
int x,
int y,
int z,
Climate.Sampler sampler,
IrisDimensionCarvingResolver.State resolverState
) {
long cacheKey = packNoiseKey(x, y, z);
Holder<Biome> cachedHolder = noiseBiomeCache.get(cacheKey);
@@ -457,7 +446,7 @@ public class CustomBiomeSource extends BiomeSource {
return cachedHolder;
}
Holder<Biome> resolvedHolder = resolveVisibleBiomeHolder(x, y, z, resolverState);
Holder<Biome> resolvedHolder = resolveVisibleBiomeHolder(x, y, z);
Holder<Biome> existingHolder = noiseBiomeCache.putIfAbsent(cacheKey, resolvedHolder);
if (existingHolder != null) {
return existingHolder;
@@ -530,13 +519,8 @@ public class CustomBiomeSource extends BiomeSource {
return holder;
}
private Holder<Biome> resolveVisibleBiomeHolder(
int x,
int y,
int z,
IrisDimensionCarvingResolver.State resolverState
) {
BiomeResolution resolution = resolveBiomeResolution(x, y, z, resolverState);
private Holder<Biome> resolveVisibleBiomeHolder(int x, int y, int z) {
BiomeResolution resolution = resolveBiomeResolution(x, y, z);
if (resolution == null) {
return getFallbackBiome();
}
@@ -569,15 +553,6 @@ public class CustomBiomeSource extends BiomeSource {
}
private BiomeResolution resolveBiomeResolution(int x, int y, int z) {
return resolveBiomeResolution(x, y, z, null);
}
private BiomeResolution resolveBiomeResolution(
int x,
int y,
int z,
IrisDimensionCarvingResolver.State resolverState
) {
if (engine == null || engine.isClosed()) {
return null;
}
@@ -599,7 +574,7 @@ public class CustomBiomeSource extends BiomeSource {
int surfaceInternalY = engine.getComplex().getHeightStream().get(blockX, blockZ).intValue();
underground = internalY <= surfaceInternalY - 8;
irisBiome = underground
? engine.getCaveBiome(blockX, internalY, blockZ, resolverState)
? engine.getCaveBiome(blockX, internalY, blockZ)
: engine.getComplex().getTrueBiomeStream().get(blockX, blockZ);
} else {
irisBiome = engine.getComplex().getTrueBiomeStream().get(blockX, blockZ);
@@ -12,7 +12,6 @@ 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.nativegen.NativeStructureFitBridge;
import art.arcane.iris.nativegen.NativeStructureGenerationException;
import art.arcane.iris.nativegen.NativeStructureStartInjector;
@@ -634,10 +633,9 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
GenerationSessionLease lease = requireGenerationLease("bukkit_nms_create_biomes");
IrisContext.Scope ignored = IrisContext.open(engine, lease.sessionId(), null)) {
customBiomeSource.prepareVisibleBiomeBatch();
IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State();
ichunkaccess.fillBiomesFromNoise(
(x, y, z, sampler) -> customBiomeSource.getVisibleNoiseBiomeWithActiveGenerationLease(
x, y, z, sampler, resolverState),
x, y, z, sampler),
randomstate.sampler());
return CompletableFuture.completedFuture(ichunkaccess);
}
@@ -1,6 +1,5 @@
package art.arcane.iris.core.nms.v26_2_R1;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
import org.junit.Test;
import java.io.IOException;
@@ -257,8 +256,7 @@ public class IrisChunkGeneratorFailureContractTest {
assertTrue(createBiomes.contains("requireGenerationStage(\"bukkit_nms_create_biomes\")"));
assertTrue(createBiomes.contains("customBiomeSource.prepareVisibleBiomeBatch()"));
assertTrue(createBiomes.contains("new IrisDimensionCarvingResolver.State()"));
assertTrue(createBiomes.contains("sampler, resolverState"));
assertTrue(createBiomes.contains("getVisibleNoiseBiomeWithActiveGenerationLease("));
assertTrue(buildSurface.contains("delegate.buildSurface("));
assertTrue(carvers.contains("delegate.applyCarvers("));
assertTrue(noise.contains("requireNoiseGenerationStage("));
@@ -24,6 +24,7 @@ import com.volmit.host.FeatureCatalog;
import com.volmit.entity.EntitySpec;
import com.volmit.item.ItemDrop;
import com.volmit.service.BlockDrops;
import com.volmit.service.CaveBiomes;
import com.volmit.service.EntitySpawns;
import com.volmit.service.LocateResult;
import com.volmit.service.Loot;
@@ -47,6 +48,19 @@ public final class ModuleServices {
private ModuleServices() {
}
/** The pack biome key the module that decides cave biomes puts at the position, whatever the regions say; empty where it overrides nothing. {@code y} is the height above the dimension's bottom. */
public static Optional<String> overriddenCaveBiome(Engine engine, int x, int y, int z) {
return catalog(engine.getData()).service(CaveBiomes.class)
.flatMap(provider -> provider.overriddenBiome(engine.getGeneration().world(), x, y, z));
}
/** How many blocks below the surface the caves of the pack biome {@code biomeKey} begin; 0 where nothing limits them. */
public static int caveMinDepthBelowSurface(Engine engine, String biomeKey) {
return catalog(engine.getData()).service(CaveBiomes.class)
.map(provider -> provider.minDepthBelowSurface(engine.getGeneration().world(), biomeKey))
.orElse(0);
}
/** The objects every module would place in the chunk at {@code chunkX}, {@code chunkZ}, guessed without generating it. */
public static Set<String> objectsAt(Engine engine, int chunkX, int chunkZ) {
PackWorld world = engine.getGeneration().world();
@@ -19,12 +19,17 @@
package art.arcane.iris.core.modules;
import com.volmit.IrisFeature;
import com.volmit.config.LinkedBiomes;
import com.volmit.host.ConfiguredSettings;
import com.volmit.resource.ResourceId;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
/**
* Module settings one dimension, region, biome or object placement declares, at most one value per settings
@@ -55,6 +60,32 @@ public final class ModuleSettings {
return values.isEmpty();
}
/** The biomes these settings add to the biome tree of the owner's regions ({@link LinkedBiomes#treeBiomes}), in a fixed order. */
public Set<String> treeBiomes() {
return linkedBiomes(LinkedBiomes::treeBiomes);
}
/**
* The biomes these settings use besides ({@link LinkedBiomes#usedBiomes}), in a fixed order.
*
* @param dimension the settings of the dimension the owner is part of
*/
public Set<String> usedBiomes(ModuleSettings dimension) {
return linkedBiomes(linked -> linked.usedBiomes(dimension.values()));
}
private Set<String> linkedBiomes(Function<LinkedBiomes, Set<String>> pick) {
if (values.isEmpty()) {
return Set.of();
}
Set<String> biomes = new LinkedHashSet<>();
values.values().stream()
.filter(LinkedBiomes.class::isInstance)
.sorted(Comparator.comparing(value -> value.getClass().getName()))
.forEach(value -> biomes.addAll(pick.apply((LinkedBiomes) value)));
return biomes;
}
/** These settings as one placement's own, declared by {@code source}. */
public ConfiguredSettings placement(ResourceId source) {
return isEmpty() ? ConfiguredSettings.none() : ConfiguredSettings.placement(source, values.values().toArray(IrisFeature[]::new));
@@ -28,6 +28,7 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.IrisRegistrant;
import art.arcane.iris.core.nms.container.BlockPos;
import art.arcane.iris.core.nms.container.Pair;
import art.arcane.iris.core.modules.ModuleServices;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.data.chunk.TerrainChunk;
@@ -35,8 +36,6 @@ import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.value.IrisColor;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
import art.arcane.iris.engine.object.runtime.IrisEngineData;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.value.IrisPosition;
@@ -72,6 +71,7 @@ import org.jetbrains.annotations.Nullable;
import java.awt.Color;
import java.util.Locale;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@@ -274,20 +274,11 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
@BlockCoordinates
default IrisBiome getCaveBiome(int x, int y, int z) {
return getCaveBiome(x, y, z, null);
}
@BlockCoordinates
default IrisBiome getCaveBiome(int x, int y, int z, IrisDimensionCarvingResolver.State state) {
IrisBiome surfaceBiome = getSurfaceBiome(x, z);
int worldY = y + getWorld().minHeight();
IrisDimensionCarvingEntry rootCarvingEntry = IrisDimensionCarvingResolver.resolveRootEntry(this, worldY, state);
if (rootCarvingEntry != null) {
IrisDimensionCarvingEntry resolvedCarvingEntry = IrisDimensionCarvingResolver.resolveFromRoot(this, rootCarvingEntry, x, z, state);
IrisBiome resolvedCarvingBiome = IrisDimensionCarvingResolver.resolveEntryBiome(this, resolvedCarvingEntry, state);
if (resolvedCarvingBiome != null) {
return resolvedCarvingBiome;
}
Optional<String> overriddenKey = ModuleServices.overriddenCaveBiome(this, x, y, z);
IrisBiome overriddenBiome = overriddenKey.map(key -> getData().getBiomeLoader().load(key)).orElse(null);
if (overriddenBiome != null) {
return overriddenBiome;
}
IrisBiome caveBiome = getCaveBiome(x, z);
@@ -301,7 +292,7 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
return surfaceBiome;
}
int minDepth = Math.max(0, caveBiome.getCaveMinDepthBelowSurface());
int minDepth = Math.max(0, ModuleServices.caveMinDepthBelowSurface(this, caveBiome.getLoadKey()));
if (depthBelowSurface < minDepth) {
return surfaceBiome;
}
@@ -0,0 +1,204 @@
/*
* 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;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.carve.CarvingBiomeSettings;
import art.arcane.iris.builtin.carve.CarvingEnabledSettings;
import art.arcane.iris.builtin.carve.CarvingEntry;
import art.arcane.iris.builtin.carve.CarvingSettings;
import art.arcane.iris.builtin.carve.CaveDepthSettings;
import art.arcane.iris.builtin.carve.CaveProfile;
import art.arcane.volmlib.util.json.JSONObject;
import com.google.gson.Gson;
import com.volmit.FeatureAttachment.Target;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* The cave settings packs have always written, read by the carve module under their old keys: {@code caveProfile} (an object at a
* dimension, region or biome), {@code carving} and {@code carvingEnabled} (a list and a boolean at a dimension), {@code carvingBiome} and
* {@code caveMinDepthBelowSurface} (a biome key and a number at a biome). The dimension, region and biome are files of the overworld pack
* as they were before the port.
*/
public class CarveSettingsDecodingTest {
private static final String PACK = "/art/arcane/iris/core/modules/pack-before-the-port";
@Rule
public TemporaryFolder folder = new TemporaryFolder();
private Path packFolder;
private LoadedPack pack;
private ModuleSettingsDecoder decoder;
@Before
public void loadBuiltIns() throws IOException, URISyntaxException {
packFolder = Path.of(CarveSettingsDecodingTest.class.getResource(PACK).toURI());
pack = LoadedPack.load(packFolder, ModuleHost.of(IrisModuleHost.builtInModules())
.reservingFields(ModuleTargets.reservedFields())
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
}
@After
public void closePack() {
pack.close();
}
@Test
public void theOverworldReadsItsCaveProfileItsCarvingBandsAndCarvingEnabled() throws IOException {
ModuleSettings settings = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
CaveProfile profile = settings.find(CaveProfile.class).orElseThrow();
assertTrue(profile.enabled());
assertEquals(6, profile.verticalRange().min(), 0);
assertEquals(700, profile.verticalRange().max(), 0);
assertEquals("PERLIN_IRIS", profile.baseDensityStyle().style());
assertEquals(0.72, profile.baseDensityStyle().zoom(), 0);
assertEquals("FRACTAL_WATER", profile.warpStyle().style());
assertEquals(-0.14, profile.densityThreshold().min(), 0);
assertEquals(3, profile.sampleStep());
assertEquals(5, profile.surfaceClearance());
assertEquals(14, profile.objectMinDepthBelowSurface());
assertEquals(ObjectPlaceMode.ORGANIC_STILT, profile.defaultObjectPlaceMode().orElseThrow());
assertEquals(2, profile.modules().size());
assertTrue(profile.modules().get(1).invert());
assertEquals(240, profile.modules().get(1).verticalRange().max(), 0);
List<CarvingEntry> bands = settings.find(CarvingSettings.class).orElseThrow().entries();
assertEquals(1, bands.size());
assertEquals("global-deepdark-band", bands.getFirst().id());
assertTrue(bands.getFirst().enabled());
assertEquals("carving/standard-deepdark", bands.getFirst().biome());
assertEquals(-250, bands.getFirst().worldYRange().min(), 0);
assertEquals(-175, bands.getFirst().worldYRange().max(), 0);
assertEquals("a band that writes no children keeps Iris's defaults", 3, bands.getFirst().childRecursionDepth());
assertEquals(1.5, bands.getFirst().childShrinkFactor(), 0);
assertEquals("CELLULAR_IRIS_DOUBLE", bands.getFirst().childStyle().style());
assertTrue(settings.find(CarvingEnabledSettings.class).orElseThrow().enabled());
}
@Test
public void aRegionReadsItsCaveProfile() throws IOException {
JSONObject region = file("regions/forests.json");
CaveProfile profile = decoder.decode(Target.REGION, region, "region forests").find(CaveProfile.class).orElseThrow();
assertTrue(profile.enabled());
assertEquals(6, profile.verticalRange().min(), 0);
assertEquals(120, profile.verticalRange().max(), 0);
assertEquals(1, profile.baseWeight(), 0);
assertEquals(3, profile.sampleStep());
}
@Test
public void aBiomeReadsItsCaveProfileAndItsMinimumDepth() throws IOException {
JSONObject biome = file("biomes/carving/amethyst.json");
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome carving/amethyst");
CaveProfile profile = settings.find(CaveProfile.class).orElseThrow();
assertTrue(profile.enabled());
assertEquals(620, profile.verticalRange().max(), 0);
assertEquals(0.91, profile.baseWeight(), 0);
assertEquals(2, profile.sampleStep());
assertEquals(biome.getInt("caveMinDepthBelowSurface"), settings.find(CaveDepthSettings.class).orElseThrow().depth());
assertEquals(10, settings.find(CaveDepthSettings.class).orElseThrow().depth());
assertTrue("the biome writes no carvingBiome", settings.find(CarvingBiomeSettings.class).isEmpty());
}
@Test
public void aCaveProfileMayBeWrittenAsASnippetReference() {
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"caveProfile\": \"snippet/cave-profile/shallow\"}"), "biome test");
CaveProfile profile = settings.find(CaveProfile.class).orElseThrow();
assertTrue(profile.enabled());
assertEquals(100, profile.verticalRange().max(), 0);
assertEquals(2, profile.sampleStep());
}
@Test
public void carvingBandsReadChildrenAndTheirOptions() {
JSONObject json = new JSONObject("""
{"carving": [
{"id": "deep", "biome": "carving/deep", "worldYRange": {"min": -64, "max": 0}, "childShrinkFactor": 2, "childRecursionDepth": 5,
"children": ["lush", " moss "], "childStyle": {"style": "SIMPLEX", "zoom": 3}},
{"id": "off", "enabled": false, "biome": "carving/off"},
{}
], "carvingEnabled": false}
""");
ModuleSettings settings = decoder.decode(Target.DIMENSION, json, "dimension test");
List<CarvingEntry> bands = settings.find(CarvingSettings.class).orElseThrow().entries();
assertEquals(3, bands.size());
assertEquals(List.of("lush", " moss "), bands.getFirst().children());
assertEquals(2, bands.getFirst().childShrinkFactor(), 0);
assertEquals(5, bands.getFirst().childRecursionDepth());
assertEquals("SIMPLEX", bands.getFirst().childStyle().style());
assertFalse(bands.get(1).enabled());
assertEquals("an empty band keeps Iris's defaults", -64, bands.get(2).worldYRange().min(), 0);
assertEquals(320, bands.get(2).worldYRange().max(), 0);
assertTrue(bands.get(2).enabled());
assertFalse(settings.find(CarvingEnabledSettings.class).orElseThrow().enabled());
CarvingSettings carving = settings.find(CarvingSettings.class).orElseThrow();
assertEquals("a band id stands for its biome", "carving/off", carving.biomeOf("off"));
assertEquals("anything else stands for itself", "carving/mushroom", carving.biomeOf("carving/mushroom"));
}
@Test
public void carvingBiomeIsABiomeKeyAndRegistersItWithTheBiomeTree() {
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"carvingBiome\": \"carving/mushroom\"}"), "biome test");
assertEquals("carving/mushroom", settings.find(CarvingBiomeSettings.class).orElseThrow().biome());
assertEquals(Set.of("carving/mushroom"), settings.treeBiomes());
assertEquals(Set.of(), settings.usedBiomes(ModuleSettings.NONE));
}
@Test
public void everyKeyIsOnlyReadAtTheLevelsTheOldFieldExistedAt() {
assertTrue(decoder.keys(Target.DIMENSION).containsAll(List.of("caveProfile", "carving", "carvingEnabled")));
assertTrue(decoder.keys(Target.REGION).contains("caveProfile"));
assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("caveProfile", "carvingBiome", "caveMinDepthBelowSurface")));
assertFalse(decoder.keys(Target.REGION).contains("carving"));
assertFalse(decoder.keys(Target.DIMENSION).contains("carvingBiome"));
assertFalse(decoder.keys(Target.DIMENSION).contains("caveMinDepthBelowSurface"));
}
private JSONObject file(String name) throws IOException {
return new JSONObject(Files.readString(packFolder.resolve(name)));
}
}
@@ -138,6 +138,7 @@ public class DecorantSettingsDecodingTest {
assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, byId, "biome meadow"));
assertTrue(decoder.keys(Target.BIOME).containsAll(Set.of("decorators", "deposits")));
assertFalse(decoder.keys(Target.BIOME).contains("iris:decorant"));
}
@Test
@@ -147,7 +147,8 @@ public class DepositSettingsDecodingTest {
JSONObject byId = new JSONObject("{\"iris:deposit\": [{\"maxHeight\": 16}]}");
assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, byId, "region forests"));
assertEquals(Set.of("deposits"), decoder.keys(Target.REGION));
assertTrue(decoder.keys(Target.REGION).contains("deposits"));
assertFalse(decoder.keys(Target.REGION).contains("iris:deposit"));
}
@Test
@@ -0,0 +1,151 @@
/*
* 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;
import art.arcane.iris.builtin.carve.CarvingEntry;
import art.arcane.iris.builtin.carve.CarvingSettings;
import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.builtin.floating.FloatingChildSettings;
import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
import art.arcane.iris.builtin.floating.TopShapeMode;
import art.arcane.volmlib.util.json.JSONObject;
import com.google.gson.Gson;
import com.volmit.FeatureAttachment.Target;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* The floating island settings packs have always written, read by the floating module under their old keys: {@code floatingChildBiomes}
* (a list) and {@code mergeFloatingChildBiomes} (a boolean), both at a biome. The biome is a file of the overworld pack as it was before
* the port.
*/
public class FloatingSettingsDecodingTest {
private static final String PACK = "/art/arcane/iris/core/modules/pack-before-the-port";
@Rule
public TemporaryFolder folder = new TemporaryFolder();
private Path packFolder;
private LoadedPack pack;
private ModuleSettingsDecoder decoder;
@Before
public void loadBuiltIns() throws IOException, URISyntaxException {
packFolder = Path.of(FloatingSettingsDecodingTest.class.getResource(PACK).toURI());
pack = LoadedPack.load(packFolder, ModuleHost.of(IrisModuleHost.builtInModules())
.reservingFields(ModuleTargets.reservedFields())
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
}
@After
public void closePack() {
pack.close();
}
@Test
public void aBiomeReadsItsFloatingChildrenAndTheMergeFlag() throws IOException {
JSONObject biome = file("biomes/magnetics/plains.json");
ModuleSettings settings = decoder.decode(Target.BIOME, biome, "biome magnetics/plains");
List<FloatingChildBiome> children = settings.find(FloatingChildSettings.class).orElseThrow().children();
assertEquals(biome.getJSONArray("floatingChildBiomes").length(), children.size());
assertEquals(2, children.size());
FloatingChildBiome mushroom = children.getFirst();
assertEquals("mushroom/forest", mushroom.biome());
assertEquals("carving/mushroom", mushroom.carving());
assertEquals(1, mushroom.rarity());
assertEquals(115, mushroom.minHeightAboveSurface());
assertEquals(155, mushroom.maxHeightAboveSurface());
assertEquals(TopShapeMode.NOISE, mushroom.topShapeMode());
assertEquals("GLOB_IRIS_THICK", mushroom.footprintStyle().style());
assertEquals(0.47, mushroom.footprintThreshold(), 0);
assertEquals(FloatingBottomPaletteMode.CUSTOM, mushroom.bottomPaletteMode());
assertEquals(1, mushroom.bottomPalette().size());
assertEquals(0.5, mushroom.objectShrinkFactor(), 0);
assertEquals("tropical/wilds", children.get(1).biome());
assertEquals("carving/lush-child", children.get(1).carving());
assertEquals(biome.getBoolean("mergeFloatingChildBiomes"), settings.find(MergeFloatingChildrenSettings.class).orElseThrow().merge());
assertTrue(settings.find(MergeFloatingChildrenSettings.class).orElseThrow().merge());
}
@Test
public void aBiomeWithoutFloatingChildrenDeclaresNone() {
ModuleSettings settings = decoder.decode(Target.BIOME, new JSONObject("{\"mergeFloatingChildBiomes\": false, \"floatingChildBiomes\": [{}]}"), "biome test");
assertFalse(settings.find(MergeFloatingChildrenSettings.class).orElseThrow().merge());
assertEquals(1, settings.find(FloatingChildSettings.class).orElseThrow().children().size());
assertEquals("an empty child keeps Iris's defaults", 160, settings.find(FloatingChildSettings.class).orElseThrow().children().getFirst().minHeightAboveSurface());
assertTrue(decoder.decode(Target.BIOME, new JSONObject("{}"), "biome test").isEmpty());
}
@Test
public void theTargetAndTheCarvingOfEveryChildAreBiomesTheDimensionUses() throws IOException {
JSONObject biome = file("biomes/magnetics/plains.json");
ModuleSettings biomeSettings = decoder.decode(Target.BIOME, biome, "biome magnetics/plains");
ModuleSettings dimensionSettings = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
Set<String> used = biomeSettings.usedBiomes(dimensionSettings);
assertEquals(new LinkedHashSet<>(List.of("mushroom/forest", "carving/mushroom", "tropical/wilds", "carving/lush-child")), used);
assertEquals(Set.of(), biomeSettings.treeBiomes());
}
@Test
public void aCarvingNamingABandStandsForTheBandsBiome() {
FloatingChildBiome child = new Gson().fromJson("{\"biome\": \"floating/target\", \"carving\": \"deep\"}", FloatingChildBiome.class);
CarvingEntry band = new Gson().fromJson("{\"id\": \"deep\", \"enabled\": false, \"biome\": \"carving/deep\"}", CarvingEntry.class);
ModuleSettings biomeSettings = BuiltInPack.settings(new FloatingChildSettings(List.of(child)));
ModuleSettings dimensionSettings = BuiltInPack.settings(new CarvingSettings(List.of(band)));
assertEquals(new LinkedHashSet<>(List.of("floating/target", "carving/deep")), biomeSettings.usedBiomes(dimensionSettings));
assertEquals("without bands the name is taken as a biome key", new LinkedHashSet<>(List.of("floating/target", "deep")),
biomeSettings.usedBiomes(ModuleSettings.NONE));
}
@Test
public void bothKeysAreOnlyReadAtBiomes() {
assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("floatingChildBiomes", "mergeFloatingChildBiomes")));
assertFalse(decoder.keys(Target.REGION).contains("floatingChildBiomes"));
assertFalse(decoder.keys(Target.DIMENSION).contains("mergeFloatingChildBiomes"));
}
private JSONObject file(String name) throws IOException {
return new JSONObject(Files.readString(packFolder.resolve(name)));
}
}
@@ -0,0 +1,183 @@
/*
* 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;
import art.arcane.iris.builtin.deposit.DepositVariant;
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
import art.arcane.iris.builtin.deposit.OreSizeSettings;
import art.arcane.iris.builtin.terrain.HideOresSettings;
import art.arcane.iris.builtin.terrain.OreGenerator;
import art.arcane.iris.builtin.terrain.OreSettings;
import art.arcane.volmlib.util.json.JSONObject;
import com.google.gson.Gson;
import com.volmit.FeatureAttachment.Target;
import com.volmit.block.BlockSpec;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
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.assertTrue;
/**
* The ore settings packs have always written, read by the terrain and deposit modules under their old keys: {@code ores} (a
* list at a dimension, region or biome), {@code hideOresForHiddenOre} (a boolean at a dimension), {@code depositVariants} (a list)
* and the two ore deposit multipliers (numbers at a biome). The dimension is the overworld file as it was before the port.
*/
public class OreSettingsDecodingTest {
private static final String PACK = "/art/arcane/iris/core/modules/pack-before-the-port";
@Rule
public TemporaryFolder folder = new TemporaryFolder();
private Path packFolder;
private LoadedPack pack;
private ModuleSettingsDecoder decoder;
@Before
public void loadBuiltIns() throws IOException, URISyntaxException {
packFolder = Path.of(OreSettingsDecodingTest.class.getResource(PACK).toURI());
pack = LoadedPack.load(packFolder, ModuleHost.of(IrisModuleHost.builtInModules())
.reservingFields(ModuleTargets.reservedFields())
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
}
@After
public void closePack() {
pack.close();
}
@Test
public void theOverworldReadsItsOresInTheOrderTheFileListsThem() throws IOException {
JSONObject dimension = new JSONObject(Files.readString(packFolder.resolve("dimensions/overworld.json")));
List<OreGenerator> ores = decoder.decode(Target.DIMENSION, dimension, "dimension overworld")
.find(OreSettings.class).orElseThrow().generators();
assertEquals(dimension.getJSONArray("ores").length(), ores.size());
assertEquals(11, ores.size());
OreGenerator firstBedrock = ores.getFirst();
assertEquals(1, firstBedrock.threshold(), 0);
assertEquals(0, firstBedrock.range().min(), 0);
assertEquals(0, firstBedrock.range().max(), 0);
assertEquals(List.of(BlockSpec.of("minecraft:bedrock")), firstBedrock.palette().palette());
assertEquals("FLAT", firstBedrock.chanceStyle().style());
assertFalse(firstBedrock.generateSurface());
OreGenerator secondBedrock = ores.get(1);
assertEquals(0.625, secondBedrock.threshold(), 0);
assertEquals("a snippet reference reads the snippet's style", "STATIC", secondBedrock.chanceStyle().style());
OreGenerator lastDeepslate = ores.getLast();
assertEquals(0.125, lastDeepslate.threshold(), 0);
assertEquals(64, lastDeepslate.range().min(), 0);
assertEquals(List.of(BlockSpec.of("minecraft:deepslate")), lastDeepslate.palette().palette());
}
@Test
public void oresOfARegionAndABiomeReadSurfaceFlagsStylesAndPalettes() {
JSONObject ores = new JSONObject("""
{"ores": [
{"generateSurface": true, "threshold": 0.3, "range": {"min": 50, "max": 90},
"chanceStyle": {"style": "SIMPLEX", "zoom": 4},
"palette": {"zoom": 2, "palette": [{"block": "minecraft:gold_ore"}, {"block": "minecraft:gold_block", "weight": 3}]}},
{}
]}
""");
for (Target target : List.of(Target.REGION, Target.BIOME)) {
List<OreGenerator> read = decoder.decode(target, ores, "test").find(OreSettings.class).orElseThrow().generators();
assertEquals(2, read.size());
assertTrue(read.getFirst().generateSurface());
assertEquals(0.3, read.getFirst().threshold(), 0);
assertEquals("SIMPLEX", read.getFirst().chanceStyle().style());
assertEquals(4, read.getFirst().chanceStyle().zoom(), 0);
assertEquals(2, read.getFirst().palette().zoom(), 0);
assertEquals(List.of(BlockSpec.of("minecraft:gold_ore"), BlockSpec.of("minecraft:gold_block").withWeight(3)), read.getFirst().palette().palette());
assertEquals("an empty generator keeps Iris's defaults", 0.5, read.get(1).threshold(), 0);
assertEquals(List.of(), read.get(1).palette().palette());
}
}
@Test
public void hideOresForHiddenOreIsABooleanOnTheDimension() {
ModuleSettings hidden = decoder.decode(Target.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": true}"), "dimension test");
ModuleSettings shown = decoder.decode(Target.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": false}"), "dimension test");
assertTrue(hidden.find(HideOresSettings.class).orElseThrow().hide());
assertFalse(shown.find(HideOresSettings.class).orElseThrow().hide());
assertTrue("a dimension that does not write it declares nothing", decoder.decode(Target.DIMENSION, new JSONObject("{}"), "dimension test").isEmpty());
}
@Test
public void depositVariantsAreAListAtEveryLevel() {
JSONObject json = new JSONObject("""
{"depositVariants": [
{"minHeight": -64, "maxHeight": 0, "remap": {"minecraft:iron_ore": "minecraft:deepslate_iron_ore", "minecraft:coal_ore": "minecraft:deepslate_coal_ore"}},
{"maxHeight": 10}
]}
""");
for (Target target : List.of(Target.DIMENSION, Target.REGION, Target.BIOME)) {
List<DepositVariant> variants = decoder.decode(target, json, "test").find(DepositVariantSettings.class).orElseThrow().variants();
assertEquals(2, variants.size());
assertEquals(-64, variants.getFirst().minHeight());
assertEquals(0, variants.getFirst().maxHeight());
assertEquals(Map.of("minecraft:iron_ore", "minecraft:deepslate_iron_ore", "minecraft:coal_ore", "minecraft:deepslate_coal_ore"),
variants.getFirst().remap());
assertEquals(0, variants.get(1).minHeight());
assertEquals(10, variants.get(1).maxHeight());
assertEquals(Map.of(), variants.get(1).remap());
}
}
@Test
public void theTwoOreDepositMultipliersAreNumbersOnTheBiome() {
ModuleSettings tuned = decoder.decode(Target.BIOME, new JSONObject("{\"oreDepositFrequencyMultiplier\": 0.4, \"oreDepositSizeMultiplier\": 2}"), "biome test");
ModuleSettings plain = decoder.decode(Target.BIOME, new JSONObject("{}"), "biome test");
assertEquals(0.4, tuned.find(OreFrequencySettings.class).orElseThrow().multiplier(), 0);
assertEquals(2, tuned.find(OreSizeSettings.class).orElseThrow().multiplier(), 0);
assertTrue(plain.find(OreFrequencySettings.class).isEmpty());
assertTrue(plain.find(OreSizeSettings.class).isEmpty());
}
@Test
public void everyKeyIsOnlyReadAtTheLevelsTheOldFieldExistedAt() {
assertTrue(decoder.keys(Target.DIMENSION).containsAll(List.of("ores", "hideOresForHiddenOre", "depositVariants")));
assertTrue(decoder.keys(Target.REGION).containsAll(List.of("ores", "depositVariants")));
assertFalse(decoder.keys(Target.REGION).contains("hideOresForHiddenOre"));
assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("ores", "depositVariants", "oreDepositFrequencyMultiplier", "oreDepositSizeMultiplier")));
assertFalse(decoder.keys(Target.DIMENSION).contains("oreDepositFrequencyMultiplier"));
}
}
@@ -1,26 +1,23 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** Ore generators keep the noise of the first random they are warmed with, so the order and the randoms of the warm-up are pinned. */
/** Ore generators keep the noise of the first seed they are warmed with, so the order and the seeds of the warm-up are pinned. */
public class OreWarmUpTest {
private static final long COMPONENT_SEED = 100L;
private static final long ROOT_SEED = COMPONENT_SEED + 7777L;
@@ -28,54 +25,52 @@ public class OreWarmUpTest {
private final List<String> warmed = new ArrayList<>();
@Test
public void biomesByKeyThenRegionsByKeyThenTheDimensionWarmWithConsecutiveRandomsOfTheWorld() {
public void biomesByKeyThenRegionsByKeyThenTheDimensionWarmWithConsecutiveSeedsOfTheWorld() {
SeedManager seeds = mock(SeedManager.class);
when(seeds.getComponent()).thenReturn(COMPONENT_SEED);
IrisDimension dimension = mock(IrisDimension.class);
Engine engine = mock(Engine.class);
when(engine.getSeedManager()).thenReturn(seeds);
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(dimension);
IrisBiome biomeB = biome("b", ore("b0"), null, ore("b1"));
IrisBiome biomeA = biome("a", ore("a0"));
IrisRegion regionY = region("y", ore("y0"));
IrisRegion regionX = region("x", ore("x0"), ore("x1"));
KList<IrisOreGenerator> dimensionOres = list(ore("d0"));
TerrainOres ores = mock(TerrainOres.class);
IrisBiome biomeB = biome("b", ores, "b0", "b1");
IrisBiome biomeA = biome("a", ores, "a0");
IrisRegion regionY = region("y", ores, "y0");
IrisRegion regionX = region("x", ores, "x0", "x1");
ResolvedOres dimensionOres = resolved("d0");
when(ores.of(dimension)).thenReturn(dimensionOres);
when(engine.getAllBiomes()).thenReturn(new KList<>(List.of(biomeB, biomeA)));
when(dimension.getAllRegions(engine)).thenReturn(new KList<>(List.of(regionY, regionX)));
when(dimension.getOres()).thenReturn(dimensionOres);
new OreWarmUp(engine).warm();
new OreWarmUp(engine, ores).warm();
assertEquals(List.of("a0@" + ROOT_SEED, "b0@" + (ROOT_SEED + 1), "b1@" + (ROOT_SEED + 2),
"x0@" + (ROOT_SEED + 3), "x1@" + (ROOT_SEED + 4), "y0@" + (ROOT_SEED + 5), "d0@" + (ROOT_SEED + 6)), warmed);
}
private IrisOreGenerator ore(String name) {
IrisOreGenerator ore = mock(IrisOreGenerator.class);
doAnswer(call -> warmed.add(name + "@" + call.<RNG>getArgument(0).getSeed())).when(ore).warm(any(RNG.class), any());
return ore;
private ResolvedOres resolved(String... names) {
List<ResolvedOre> ores = new ArrayList<>();
for (String name : names) {
ResolvedOre ore = mock(ResolvedOre.class);
doAnswer(call -> warmed.add(name + "@" + call.<Long>getArgument(0))).when(ore).warm(anyLong());
ores.add(ore);
}
return new ResolvedOres(ores);
}
private static IrisBiome biome(String key, IrisOreGenerator... ores) {
private IrisBiome biome(String key, TerrainOres ores, String... oreNames) {
IrisBiome biome = mock(IrisBiome.class);
when(biome.getLoadKey()).thenReturn(key);
when(biome.getOres()).thenReturn(list(ores));
ResolvedOres declared = resolved(oreNames);
when(ores.of(biome)).thenReturn(declared);
return biome;
}
private static IrisRegion region(String key, IrisOreGenerator... ores) {
private IrisRegion region(String key, TerrainOres ores, String... oreNames) {
IrisRegion region = mock(IrisRegion.class);
when(region.getLoadKey()).thenReturn(key);
when(region.getOres()).thenReturn(list(ores));
ResolvedOres declared = resolved(oreNames);
when(ores.of(region)).thenReturn(declared);
return region;
}
private static KList<IrisOreGenerator> list(IrisOreGenerator... ores) {
KList<IrisOreGenerator> list = new KList<>();
for (IrisOreGenerator ore : ores) {
list.add(ore);
}
return list;
}
}
@@ -0,0 +1,166 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.terrain.OreGenerator;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.IrisPackResources;
import art.arcane.iris.engine.UsableBlockPlatform;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.spi.PlatformBlockState;
import com.google.gson.Gson;
import com.volmit.noise.NoiseSampler;
import org.junit.After;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ResolvedOreTest {
private static final long TERRAIN_SEED = 1337L;
private static final long WARM_SEED = 99L;
/** Taken from {@code IrisOreGenerator} (now deleted) generating the same ores with the same seeds, before ores moved into the terrain module. */
private static final int TRANSCRIPT_LENGTH = 128237;
private static final int TRANSCRIPT_HASH = -1665706847;
private static final String[] ORES = {
"{\"palette\":{\"palette\":[{\"block\":\"coal_ore\"}]},\"chanceStyle\":{\"style\":\"STATIC\"},\"threshold\":0.2,\"range\":{\"min\":0,\"max\":64}}",
"{\"palette\":{\"palette\":[{\"block\":\"iron_ore\"},{\"block\":\"deepslate_iron_ore\"}]},\"chanceStyle\":{\"style\":\"SIMPLEX\",\"zoom\":4},"
+ "\"threshold\":0.5,\"range\":{\"min\":-16,\"max\":40}}",
"{\"palette\":{\"palette\":[{\"block\":\"gold_ore\"},{\"block\":\"gold_block\"},{\"block\":\"raw_gold_block\"}]},\"chanceStyle\":{\"style\":\"PERLIN\",\"zoom\":2},"
+ "\"threshold\":0.35,\"range\":{\"min\":10,\"max\":20}}",
"{\"palette\":{\"palette\":[]},\"chanceStyle\":{\"style\":\"STATIC\"},\"threshold\":1,\"range\":{\"min\":0,\"max\":100}}",
"{\"palette\":{\"palette\":[{\"block\":\"bedrock\"}]},\"chanceStyle\":{\"style\":\"FLAT\"},\"threshold\":1,\"range\":{\"min\":0,\"max\":3}}",
};
@After
public void unbindPlatform() {
UsableBlockPlatform.unbind();
}
@Test
public void everyOreGeneratesAsIrisOreGeneratorDid() {
UsableBlockPlatform.bind();
Engine engine = engine();
StringBuilder transcript = new StringBuilder();
for (String json : ORES) {
ResolvedOre ore = ResolvedOre.of(new Gson().fromJson(json, OreGenerator.class), engine);
ore.warm(WARM_SEED);
for (int x = -30; x < 30; x += 3) {
for (int z = -30; z < 30; z += 4) {
for (int y = -20; y < 70; y += 5) {
PlatformBlockState state = ore.generate(x, y, z);
transcript.append(state == null ? "-" : state.key()).append(';');
}
}
}
}
assertTrue("the palettes' blocks are placed", transcript.indexOf("minecraft:deepslate_iron_ore") >= 0
&& transcript.indexOf("minecraft:iron_ore") >= 0 && transcript.indexOf("minecraft:coal_ore") >= 0 && transcript.indexOf("minecraft:bedrock") >= 0);
assertTrue("positions without ore occur", transcript.indexOf("-") >= 0);
assertEquals(TRANSCRIPT_LENGTH, transcript.length());
assertEquals(TRANSCRIPT_HASH, transcript.toString().hashCode());
}
@Test
public void theNoiseKeepsTheFirstSeedItIsBuiltFrom() {
UsableBlockPlatform.bind();
OreGenerator settings = new Gson().fromJson(ORES[1], OreGenerator.class);
List<Long> seeds = new ArrayList<>();
ResolvedOre ore = new ResolvedOre(settings, (style, seed) -> {
seeds.add(seed);
return constant(0);
}, null, TERRAIN_SEED, List.of(UsableBlockPlatform.block("iron_ore")));
ore.warm(WARM_SEED);
ore.warm(WARM_SEED + 1);
ore.generate(0, 0, 0);
assertEquals(List.of(WARM_SEED), seeds);
}
@Test
public void anOreNothingWarmedBuildsItsNoiseFromTheTerrainSeed() {
UsableBlockPlatform.bind();
OreGenerator settings = new Gson().fromJson(ORES[1], OreGenerator.class);
List<Long> seeds = new ArrayList<>();
ResolvedOre ore = new ResolvedOre(settings, (style, seed) -> {
seeds.add(seed);
return constant(0);
}, null, TERRAIN_SEED, List.of(UsableBlockPlatform.block("iron_ore")));
ore.generate(0, 0, 0);
ore.generate(1, 1, 1);
assertEquals(List.of(TERRAIN_SEED), seeds);
}
@Test
public void nothingGeneratesOutsideTheBandOrWithAnEmptyPaletteOrAboveTheThreshold() {
UsableBlockPlatform.bind();
PlatformBlockState iron = UsableBlockPlatform.block("iron_ore");
OreGenerator settings = new Gson().fromJson(ORES[1], OreGenerator.class);
ResolvedOre atThreshold = new ResolvedOre(settings, (style, seed) -> constant(0.5), null, TERRAIN_SEED, List.of(iron));
ResolvedOre aboveThreshold = new ResolvedOre(settings, (style, seed) -> constant(0.51), null, TERRAIN_SEED, List.of(iron));
ResolvedOre noBlocks = new ResolvedOre(settings, (style, seed) -> constant(0), null, TERRAIN_SEED, List.of());
OreGenerator emptyPalette = new Gson().fromJson(ORES[3], OreGenerator.class);
ResolvedOre empty = new ResolvedOre(emptyPalette, (style, seed) -> constant(0), null, TERRAIN_SEED, List.of());
assertEquals("noise at the threshold becomes ore", iron, atThreshold.generate(0, 0, 0));
assertNull(aboveThreshold.generate(0, 0, 0));
assertNull("below the band", atThreshold.generate(0, -17, 0));
assertNull("above the band", atThreshold.generate(0, 41, 0));
assertEquals("the band's ends are in it", iron, atThreshold.generate(0, 40, 0));
assertNull(noBlocks.generate(0, 0, 0));
assertNull(empty.generate(0, 50, 0));
}
@Test
public void oresDefaultToNoBlocksSurfaceOffAndTheDocumentedBand() {
OreGenerator ore = new Gson().fromJson("{}", OreGenerator.class);
assertEquals(List.of(), ore.palette().palette());
assertEquals("STATIC", ore.chanceStyle().style());
assertEquals(false, ore.generateSurface());
assertEquals(0.5, ore.threshold(), 0);
assertEquals(30, ore.range().min(), 0);
assertEquals(80, ore.range().max(), 0);
}
private static NoiseSampler constant(double value) {
return new NoiseSampler() {
@Override
public double sample(double worldX, double worldZ) {
return value;
}
@Override
public double sample(double worldX, double y, double worldZ) {
return value;
}
};
}
private static Engine engine() {
IrisData data = mock(IrisData.class);
@SuppressWarnings("unchecked")
ResourceLoader<IrisBlockData> blocks = mock(ResourceLoader.class);
when(data.getBlockLoader()).thenReturn(blocks);
when(data.getDataFolder()).thenReturn(new File("pack"));
IrisPackResources resources = new IrisPackResources(data);
when(data.getPackResources()).thenReturn(resources);
SeedManager seeds = mock(SeedManager.class);
when(seeds.getTerrain()).thenReturn(TERRAIN_SEED);
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(data);
when(engine.getSeedManager()).thenReturn(seeds);
return engine;
}
}
@@ -17,9 +17,13 @@ import art.arcane.iris.util.project.context.ChunkedDataCache;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.builtin.terrain.HideOresSettings;
import art.arcane.iris.core.modules.BuiltInPack;
import org.junit.After;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
@@ -52,7 +56,7 @@ public class TerrainModuleTest {
public void aColumnIsBedrockThenRockThenLayersThenFluid() {
UsableBlockPlatform.bind();
IrisBiome biome = mock(IrisBiome.class);
TerrainModule.TerrainShaper shaper = new TerrainModule.TerrainShaper(engine(), palettes(), layersOf(biome));
TerrainModule.TerrainShaper shaper = new TerrainModule.TerrainShaper(engine(true), palettes(), layersOf(biome), mock(TerrainOres.class));
Hunk<PlatformBlockState> blocks = Hunk.newArrayHunk(16, 64, 16);
shaper.shape(0, 0, blocks, context(biome));
@@ -68,6 +72,47 @@ public class TerrainModuleTest {
assertNull("nothing above the fluid", blocks.get(3, FLUID_HEIGHT + 1, 4));
}
@Test
@SuppressWarnings("unchecked")
public void oresOfTheBiomeThenTheRegionThenTheDimensionReplaceTheBlocksTheirBandsReach() {
UsableBlockPlatform.bind();
Engine engine = engine(false);
IrisDimension dimension = engine.getDimension();
IrisBiome biome = mock(IrisBiome.class);
ChunkContext context = context(biome);
IrisRegion region = context.getRegion().get(0, 0);
PlatformBlockState biomeOre = mock(PlatformBlockState.class);
PlatformBlockState regionOre = mock(PlatformBlockState.class);
PlatformBlockState dimensionOre = mock(PlatformBlockState.class);
TerrainOres ores = mock(TerrainOres.class);
ResolvedOres biomeOres = oresAt(2, biomeOre);
ResolvedOres regionOres = oresAt(2, regionOre, 3, regionOre);
ResolvedOres dimensionOres = oresAt(2, dimensionOre, 3, dimensionOre, 4, dimensionOre);
when(ores.of(biome)).thenReturn(biomeOres);
when(ores.of(region)).thenReturn(regionOres);
when(ores.of(dimension)).thenReturn(dimensionOres);
Hunk<PlatformBlockState> blocks = Hunk.newArrayHunk(16, 64, 16);
new TerrainModule.TerrainShaper(engine, palettes(), layersOf(biome, new KList<>()), ores).shape(0, 0, blocks, context);
assertSame("the biome's ore comes first", biomeOre, blocks.get(3, 2, 4));
assertSame("then the region's", regionOre, blocks.get(3, 3, 4));
assertSame("then the dimension's", dimensionOre, blocks.get(3, 4, 4));
assertSame("rock where no ore reaches", rock, blocks.get(3, 5, 4));
}
/** Underground ores that give {@code block} at each listed height and nothing elsewhere. */
private static ResolvedOres oresAt(Object... heightsAndBlocks) {
ResolvedOre ore = mock(ResolvedOre.class);
when(ore.generatesSurface()).thenReturn(false);
when(ore.minY()).thenReturn(0D);
when(ore.maxY()).thenReturn(10D);
for (int index = 0; index < heightsAndBlocks.length; index += 2) {
when(ore.generate(anyInt(), eq((int) heightsAndBlocks[index]), anyInt())).thenReturn((PlatformBlockState) heightsAndBlocks[index + 1]);
}
return new ResolvedOres(List.of(ore));
}
@SuppressWarnings("unchecked")
private ChunkContext context(IrisBiome biome) {
ChunkedDataCache<IrisBiome> biomes = mock(ChunkedDataCache.class);
@@ -91,17 +136,21 @@ public class TerrainModuleTest {
private BiomeLayers layersOf(IrisBiome biome) {
KList<PlatformBlockState> layers = new KList<>();
layers.add(grass, dirt);
return layersOf(biome, layers);
}
private BiomeLayers layersOf(IrisBiome biome, KList<PlatformBlockState> layers) {
BiomeLayers biomeLayers = mock(BiomeLayers.class);
when(biomeLayers.generateLayers(eq(biome), any(), anyDouble(), anyDouble(), any(RNG.class), anyInt(), anyInt(), any(), any())).thenReturn(layers);
when(biomeLayers.generateSeaLayers(eq(biome), anyDouble(), anyDouble(), any(RNG.class), anyInt(), any())).thenReturn(new KList<>());
return biomeLayers;
}
private Engine engine() {
private Engine engine(boolean hidesOres) {
IrisDimension dimension = mock(IrisDimension.class);
when(dimension.getFluidHeight()).thenReturn(FLUID_HEIGHT);
when(dimension.isBedrock()).thenReturn(true);
when(dimension.isHideOresForHiddenOre()).thenReturn(true);
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(new HideOresSettings(hidesOres)));
IrisComplex complex = mock(IrisComplex.class);
when(complex.getImageMapRuntime()).thenReturn(mock(IrisImageMapRuntime.class));
SeedManager seeds = mock(SeedManager.class);
@@ -0,0 +1,179 @@
/*
* 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.engine.framework;
import art.arcane.iris.builtin.carve.CaveDepthSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.BuiltInPack;
import art.arcane.iris.core.modules.ModuleResourceFixture;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.decorator.DecoratorTestEngines;
import art.arcane.iris.engine.object.world.IrisWorld;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.modifier.CaveBiomeBands;
import art.arcane.iris.util.project.stream.ProceduralStream;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.service.CaveBiomes;
import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld;
import org.junit.Before;
import org.junit.Test;
import java.util.Optional;
import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* The cave biome of a position: the biome a module overrides it with, else the cave biome of the column unless the surface is nearer than that
* biome's caves begin, else the surface biome. The overrides and the depths come from the pack's {@link CaveBiomes} provider.
*/
public class EngineCaveBiomeTest {
private static final int MIN_HEIGHT = -64;
private static final int SURFACE_Y = 100;
private final IrisBiome surface = mock(IrisBiome.class);
private final IrisBiome cave = mock(IrisBiome.class);
private final IrisBiome band = mock(IrisBiome.class);
private IrisData data;
private Engine engine;
private static final class CavesModule implements IrisModule {
private final CaveBiomes provider;
private CavesModule(CaveBiomes provider) {
this.provider = provider;
}
@Override
public ModuleInfo info() {
return ModuleInfo.of("test:caves", "Caves", "test");
}
@Override
public void register(FeatureRegistry registry) {
registry.registerService(CaveBiomes.class, provider);
}
@Override
public void install(StageGraph graph) {
}
}
@Before
@SuppressWarnings("unchecked")
public void mockEngine() {
data = mock(IrisData.class);
ResourceLoader<IrisBiome> biomes = mock(ResourceLoader.class);
when(data.getBiomeLoader()).thenReturn(biomes);
when(biomes.load("band/deep")).thenReturn(band);
when(biomes.load("cave/lush")).thenReturn(cave);
when(cave.getLoadKey()).thenReturn("cave/lush");
engine = mock(Engine.class, CALLS_REAL_METHODS);
doReturn(data).when(engine).getData();
doReturn(IrisWorld.builder().minHeight(MIN_HEIGHT).maxHeight(320).build()).when(engine).getWorld();
doReturn(surface).when(engine).getSurfaceBiome(anyInt(), anyInt());
doReturn(cave).when(engine).getCaveBiome(anyInt(), anyInt());
IrisComplex complex = mock(IrisComplex.class);
@SuppressWarnings("unchecked")
ProceduralStream<Double> heights = mock(ProceduralStream.class);
when(heights.get(anyDouble(), anyDouble())).thenReturn((double) SURFACE_Y);
when(complex.getHeightStream()).thenReturn(heights);
doReturn(complex).when(engine).getComplex();
DecoratorTestEngines.withGeneration(engine);
}
private void serve(CaveBiomes provider) {
ModuleResourceFixture.serveModules(data, new CavesModule(provider));
}
private CaveBiomes caves(String overridden, int minDepth) {
return new CaveBiomes() {
@Override
public Optional<String> overriddenBiome(PackWorld world, int x, int y, int z) {
return Optional.ofNullable(overridden);
}
@Override
public int minDepthBelowSurface(PackWorld world, String biomeKey) {
return biomeKey.equals("cave/lush") ? minDepth : 0;
}
};
}
@Test
public void aBiomeTheModuleOverridesWithWinsEverywhere() {
serve(caves("band/deep", 40));
assertSame(band, engine.getCaveBiome(10, 0, 20));
assertSame(band, engine.getCaveBiome(10, SURFACE_Y + 30, 20));
}
@Test
public void anOverrideNamingNoBiomeLeavesTheColumnsCaveBiome() {
serve(caves("band/missing", 0));
assertSame(cave, engine.getCaveBiome(10, 10, 20));
}
@Test
public void theSurfaceBiomeHoldsAtAndAboveTheSurfaceAndWithinTheCaveBiomesMinimumDepth() {
serve(caves(null, 10));
assertSame("above the surface", surface, engine.getCaveBiome(10, SURFACE_Y + 1, 20));
assertSame("at the surface", surface, engine.getCaveBiome(10, SURFACE_Y, 20));
assertSame("nearer the surface than the caves begin", surface, engine.getCaveBiome(10, SURFACE_Y - 9, 20));
assertSame("where the caves begin", cave, engine.getCaveBiome(10, SURFACE_Y - 10, 20));
assertSame("deeper", cave, engine.getCaveBiome(10, 3, 20));
}
@Test
public void aColumnWithoutACaveBiomeHasTheSurfaceBiome() {
serve(caves(null, 0));
doReturn(null).when(engine).getCaveBiome(anyInt(), anyInt());
assertSame(surface, engine.getCaveBiome(10, 3, 20));
}
@Test
public void aPackWithoutACaveBiomeProviderOverridesNothingAndLimitsNoDepth() {
ModuleResourceFixture.serveModules(data);
assertSame(cave, engine.getCaveBiome(10, SURFACE_Y - 1, 20));
}
@Test
public void theCarveModulesProviderReadsTheDepthFromTheBiomesSettings() {
IrisBiome deep = mock(IrisBiome.class);
when(deep.getModuleSettings()).thenReturn(BuiltInPack.settings(new CaveDepthSettings(25)));
IrisBiome plain = mock(IrisBiome.class);
when(plain.getModuleSettings()).thenReturn(BuiltInPack.settings());
org.junit.Assert.assertEquals(25, CaveBiomeBands.minDepthBelowSurface(deep));
org.junit.Assert.assertEquals(0, CaveBiomeBands.minDepthBelowSurface(plain));
}
}
@@ -18,6 +18,8 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.core.modules.BuiltInPack;
import art.arcane.iris.builtin.floating.FloatingChildSettings;
import art.arcane.iris.engine.framework.EngineGeneration;
import art.arcane.iris.engine.object.TestSettings;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
@@ -44,6 +46,7 @@ import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
@@ -96,7 +99,8 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
.setPlace(new KList<>("test/floating"))
.setTranslate(new IrisObjectTranslate().setX(32));
FloatingChildBiome floatingChild = TestSettings.with(new FloatingChildBiome(), "floatingObjects", new KList<>(placement));
IrisBiome biome = new IrisBiome().setFloatingChildBiomes(new KList<>(floatingChild));
IrisBiome biome = new IrisBiome();
biome.setModuleSettings(BuiltInPack.settings(new FloatingChildSettings(List.of(floatingChild))));
IrisDimension dimension = mock(IrisDimension.class);
when(dimension.getReachableBiomes(org.mockito.ArgumentMatchers.any())).thenReturn(new KList<>(biome));
@@ -7,7 +7,6 @@ import art.arcane.iris.engine.decorator.DecoratorTestEngines;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
@@ -25,7 +24,6 @@ import java.util.Map;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -54,7 +52,7 @@ public class CaveApplyingBoundarySupportTest {
Engine engine = mock(Engine.class);
doReturn(data).when(engine).getData();
doReturn(resolvedCeiling).when(engine).getCaveBiome(anyInt(), eq(42), anyInt(), any(IrisDimensionCarvingResolver.State.class));
doReturn(resolvedCeiling).when(engine).getCaveBiome(anyInt(), eq(42), anyInt());
doReturn(mock(SeedManager.class)).when(engine).getSeedManager();
DecoratorTestEngines.withGeneration(engine);
@@ -78,12 +76,11 @@ public class CaveApplyingBoundarySupportTest {
Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache = new Long2ObjectOpenHashMap<>();
Map<String, IrisBiome> customBiomeCache = new HashMap<>();
IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State();
IrisBiome floor = modifier.resolveCaveBoundaryBiome(
mantleChunk, 1, 6, 2, 40, 44, resolverState, caveBiomeCache, customBiomeCache);
mantleChunk, 1, 6, 2, 40, 44, caveBiomeCache, customBiomeCache);
IrisBiome ceiling = modifier.resolveCaveBoundaryBiome(
mantleChunk, 1, 42, 2, 40, 44, resolverState, caveBiomeCache, customBiomeCache);
mantleChunk, 1, 42, 2, 40, 44, caveBiomeCache, customBiomeCache);
assertSame(customFloor, floor);
assertSame(resolvedCeiling, ceiling);
@@ -10,7 +10,6 @@ import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.world.biome.InferredType;
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.IrisDimensionCarvingResolver;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.object.world.IrisWorld;
import art.arcane.iris.spi.IrisPlatform;
@@ -85,7 +84,6 @@ public class CaveApplyingInferenceIsolationTest {
int.class,
int.class,
int.class,
IrisDimensionCarvingResolver.State.class,
Long2ObjectOpenHashMap.class,
Map.class
);
@@ -100,7 +98,6 @@ public class CaveApplyingInferenceIsolationTest {
0,
1,
1,
new IrisDimensionCarvingResolver.State(),
new Long2ObjectOpenHashMap<IrisBiome>(),
customBiomes
);
@@ -0,0 +1,98 @@
/*
* 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.engine.modifier;
import art.arcane.iris.builtin.carve.CarvingEntry;
import art.arcane.iris.builtin.carve.CarvingSettings;
import art.arcane.iris.builtin.carve.CaveDepthSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.BuiltInPack;
import art.arcane.iris.core.modules.IrisPackWorld;
import art.arcane.iris.engine.decorator.DecoratorTestEngines;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.IrisWorld;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** What the carve module answers the host about cave biomes: the biome of the dimension's band at a height above the dimension's bottom, and the minimum depths. */
public class CaveBiomeBandsTest {
private static final int MIN_HEIGHT = -64;
private static final String BANDS = """
[{"id": "shallow", "biome": "band/shallow", "worldYRange": {"min": -64, "max": 0}},
{"id": "disabled", "enabled": false, "biome": "band/disabled", "worldYRange": {"min": 100, "max": 200}},
{"id": "unloadable", "biome": "band/missing", "worldYRange": {"min": 300, "max": 310}},
{"id": "padded", "biome": " band/padded ", "worldYRange": {"min": 500, "max": 600}}]
""";
private Engine engine;
private final IrisBiome shallow = mock(IrisBiome.class);
@Before
@SuppressWarnings("unchecked")
public void mockEngine() {
IrisData data = mock(IrisData.class);
ResourceLoader<IrisBiome> biomes = mock(ResourceLoader.class);
when(data.getBiomeLoader()).thenReturn(biomes);
when(biomes.load("band/shallow")).thenReturn(shallow);
when(biomes.load("band/padded")).thenReturn(mock(IrisBiome.class));
when(biomes.load("band/disabled")).thenReturn(mock(IrisBiome.class));
when(shallow.getModuleSettings()).thenReturn(BuiltInPack.settings(new CaveDepthSettings(30)));
List<CarvingEntry> entries = new Gson().fromJson(BANDS, new com.google.gson.reflect.TypeToken<List<CarvingEntry>>() { }.getType());
IrisDimension dimension = mock(IrisDimension.class);
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(new CarvingSettings(entries)));
engine = mock(Engine.class);
when(engine.getData()).thenReturn(data);
when(engine.getDimension()).thenReturn(dimension);
when(engine.getWorld()).thenReturn(IrisWorld.builder().minHeight(MIN_HEIGHT).maxHeight(320).build());
DecoratorTestEngines.withGeneration(engine);
}
@Test
public void aPositionInsideAnEnabledBandGetsTheBandsBiomeKey() {
CaveBiomeBands bands = new CaveBiomeBands();
IrisPackWorld world = engine.getGeneration().world();
assertEquals("world Y -54 is in the band from -64 to 0", Optional.of("band/shallow"), bands.overriddenBiome(world, 5, 10, 5));
assertEquals("the band's end is in it", Optional.of("band/shallow"), bands.overriddenBiome(world, 5, 64, 5));
assertEquals("above it", Optional.empty(), bands.overriddenBiome(world, 5, 65, 5));
assertEquals("a disabled band overrides nothing", Optional.empty(), bands.overriddenBiome(world, 5, 200 - MIN_HEIGHT - 50, 5));
assertEquals("a band whose biome the pack lacks overrides nothing", Optional.empty(), bands.overriddenBiome(world, 5, 305 - MIN_HEIGHT, 5));
assertEquals("the key is trimmed as the loader is asked for it", Optional.of("band/padded"), bands.overriddenBiome(world, 5, 550 - MIN_HEIGHT, 5));
}
@Test
public void aBiomeKeyHasTheMinimumDepthItsSettingsDeclareAndZeroWhenTheKeyIsUnknown() {
CaveBiomeBands bands = new CaveBiomeBands();
IrisPackWorld world = engine.getGeneration().world();
assertEquals(30, bands.minDepthBelowSurface(world, "band/shallow"));
assertEquals(0, bands.minDepthBelowSurface(world, "band/unknown"));
}
}
@@ -1,5 +1,6 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.core.modules.ModuleSettings;
import art.arcane.iris.engine.decorator.DecoratorTestEngines;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.EngineMetrics;
@@ -9,7 +10,6 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.collection.KList;
import org.junit.Test;
import static org.mockito.ArgumentMatchers.any;
@@ -29,7 +29,7 @@ public class FloatingIslandsTest {
public void columnsWithoutFloatingChildBiomesAreLeftAlone() {
FloatingIslands islands = new FloatingIslands(engine());
IrisBiome biome = mock(IrisBiome.class);
when(biome.getFloatingChildBiomes()).thenReturn(new KList<>());
when(biome.getModuleSettings()).thenReturn(ModuleSettings.NONE);
FloatingIslandBoundarySampler sampler = mock(FloatingIslandBoundarySampler.class);
when(sampler.parent(anyInt(), anyInt())).thenReturn(biome);
ChunkContext context = mock(ChunkContext.class);
@@ -1,6 +1,8 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.deposit.DepositGenerator;
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
import art.arcane.iris.builtin.deposit.OreSizeSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.PackResourceFixture;
@@ -91,10 +93,8 @@ public class ResolvedDepositTest {
@Test
public void biomeOreTuningDefaultsPreserveExistingGeneration() {
IrisBiome biome = new IrisBiome();
assertEquals(1D, biome.getOreDepositFrequencyMultiplier(), 0D);
assertEquals(1D, biome.getOreDepositSizeMultiplier(), 0D);
assertEquals(1D, new OreFrequencySettings().multiplier(), 0D);
assertEquals(1D, new OreSizeSettings().multiplier(), 0D);
}
@Test
@@ -0,0 +1,75 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.deposit.DepositVariant;
import art.arcane.iris.engine.UsableBlockPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState;
import com.google.gson.Gson;
import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
public class ResolvedDepositVariantTest {
private static final String DEEP_IRON = """
{"minHeight": -64, "maxHeight": 0, "remap": {"minecraft:iron_ore": "minecraft:deepslate_iron_ore", "unknown_block": "minecraft:stone"}}
""";
private static void knowEveryBlockButTheUnknownOne() {
UsableBlockPlatform.bind();
when(IrisPlatforms.get().registries().blockOrNull(anyString(), anyBoolean())).thenAnswer(call -> {
String name = call.getArgument(0);
return name.equals("unknown_block") ? null : UsableBlockPlatform.block(name);
});
}
@After
public void unbindPlatform() {
UsableBlockPlatform.unbind();
}
@Test
public void aVariantAppliesWithinItsInclusiveBand() {
ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson(DEEP_IRON, DepositVariant.class));
assertTrue(variant.appliesAt(-64));
assertTrue(variant.appliesAt(0));
assertFalse(variant.appliesAt(-65));
assertFalse(variant.appliesAt(1));
}
@Test
public void anOreIsRemappedByItsMaterialAndOtherBlocksAreNot() {
knowEveryBlockButTheUnknownOne();
ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson(DEEP_IRON, DepositVariant.class));
PlatformBlockState iron = UsableBlockPlatform.block("iron_ore");
PlatformBlockState remapped = variant.remapOrNull(iron);
assertEquals("minecraft:deepslate_iron_ore", remapped.key());
assertNull(variant.remapOrNull(UsableBlockPlatform.block("coal_ore")));
assertNull(variant.remapOrNull(null));
}
@Test
public void aRuleWhoseSourceTheServerDoesNotKnowRemapsNothing() {
knowEveryBlockButTheUnknownOne();
DepositVariant unknown = new Gson().fromJson("{\"remap\": {\"unknown_block\": \"minecraft:stone\"}}", DepositVariant.class);
assertNull(new ResolvedDepositVariant(unknown).remapOrNull(UsableBlockPlatform.block("unknown_block")));
}
@Test
public void aVariantWithoutRemapsChangesNothing() {
UsableBlockPlatform.bind();
ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson("{\"maxHeight\": 5}", DepositVariant.class));
assertNull(variant.remapOrNull(UsableBlockPlatform.block("iron_ore")));
}
}
@@ -1,18 +1,21 @@
package art.arcane.iris.engine.object.terrain.carving;
import art.arcane.iris.engine.object.value.IRare;
import art.arcane.iris.engine.object.value.IrisRange;
import com.volmit.config.Range;
import art.arcane.iris.builtin.carve.CarvingEntry;
import art.arcane.iris.engine.decorator.DecoratorTestEngines;
import art.arcane.iris.engine.object.world.IrisWorld;
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;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
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.framework.EngineGeneration;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
@@ -24,7 +27,6 @@ import org.mockito.invocation.InvocationOnMock;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -48,7 +50,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public class IrisDimensionCarvingResolverParityTest {
public class CarvingResolverParityTest {
private static final int MAX_CHILD_DEPTH = 32;
private static final long CHILD_SEED_SALT = 0x9E3779B97F4A7C15L;
@@ -81,17 +83,17 @@ public class IrisDimensionCarvingResolverParityTest {
@Test
public void resolverStatefulOverloadsMatchLegacyResolverAcrossSampleGrid() {
Fixture fixture = createFixture();
IrisDimensionCarvingResolver.State state = new IrisDimensionCarvingResolver.State();
CarvingResolver.State state = new CarvingResolver.State();
for (int worldY = -64; worldY <= 320; worldY += 11) {
IrisDimensionCarvingEntry legacyRoot = legacyResolveRootEntry(fixture.engine, worldY);
IrisDimensionCarvingEntry statefulRoot = IrisDimensionCarvingResolver.resolveRootEntry(fixture.engine, worldY, state);
ResolvedCarvingEntry legacyRoot = legacyResolveRootEntry(fixture.engine, worldY);
ResolvedCarvingEntry statefulRoot = CarvingResolver.resolveRootEntry(fixture.engine, worldY, state);
assertSame("root mismatch at worldY=" + worldY, legacyRoot, statefulRoot);
for (int worldX = -384; worldX <= 384; worldX += 29) {
for (int worldZ = -384; worldZ <= 384; worldZ += 31) {
IrisDimensionCarvingEntry legacyResolved = legacyResolveFromRoot(fixture.engine, legacyRoot, worldX, worldZ);
IrisDimensionCarvingEntry statefulResolved = IrisDimensionCarvingResolver.resolveFromRoot(fixture.engine, statefulRoot, worldX, worldZ, state);
ResolvedCarvingEntry legacyResolved = legacyResolveFromRoot(fixture.engine, legacyRoot, worldX, worldZ);
ResolvedCarvingEntry statefulResolved = CarvingResolver.resolveFromRoot(fixture.engine, statefulRoot, worldX, worldZ, state);
assertSame("entry mismatch at worldY=" + worldY + " worldX=" + worldX + " worldZ=" + worldZ, legacyResolved, statefulResolved);
}
}
@@ -101,49 +103,33 @@ public class IrisDimensionCarvingResolverParityTest {
@Test
public void resolverStatefulOverloadsMatchLegacyResolverAcrossMixedDepthGraph() {
Fixture fixture = createMixedDepthFixture();
IrisDimensionCarvingResolver.State state = new IrisDimensionCarvingResolver.State();
CarvingResolver.State state = new CarvingResolver.State();
for (int worldY = -64; worldY <= 320; worldY += 17) {
IrisDimensionCarvingEntry legacyRoot = legacyResolveRootEntry(fixture.engine, worldY);
IrisDimensionCarvingEntry statefulRoot = IrisDimensionCarvingResolver.resolveRootEntry(fixture.engine, worldY, state);
ResolvedCarvingEntry legacyRoot = legacyResolveRootEntry(fixture.engine, worldY);
ResolvedCarvingEntry statefulRoot = CarvingResolver.resolveRootEntry(fixture.engine, worldY, state);
assertSame("mixed root mismatch at worldY=" + worldY, legacyRoot, statefulRoot);
for (int worldX = -640; worldX <= 640; worldX += 79) {
for (int worldZ = -640; worldZ <= 640; worldZ += 83) {
IrisDimensionCarvingEntry legacyResolved = legacyResolveFromRoot(fixture.engine, legacyRoot, worldX, worldZ);
IrisDimensionCarvingEntry statefulResolved = IrisDimensionCarvingResolver.resolveFromRoot(fixture.engine, statefulRoot, worldX, worldZ, state);
ResolvedCarvingEntry legacyResolved = legacyResolveFromRoot(fixture.engine, legacyRoot, worldX, worldZ);
ResolvedCarvingEntry statefulResolved = CarvingResolver.resolveFromRoot(fixture.engine, statefulRoot, worldX, worldZ, state);
assertSame("mixed entry mismatch at worldY=" + worldY + " worldX=" + worldX + " worldZ=" + worldZ, legacyResolved, statefulResolved);
}
}
}
}
@Test
public void caveBiomeStateOverloadMatchesDefaultOverloadAcrossSampleGrid() {
Fixture fixture = createFixture();
IrisDimensionCarvingResolver.State state = new IrisDimensionCarvingResolver.State();
for (int y = 1; y <= 300; y += 17) {
for (int x = -160; x <= 160; x += 23) {
for (int z = -160; z <= 160; z += 29) {
IrisBiome defaultBiome = fixture.engine.getCaveBiome(x, y, z);
IrisBiome stateBiome = fixture.engine.getCaveBiome(x, y, z, state);
assertSame("cave biome mismatch at x=" + x + " y=" + y + " z=" + z, defaultBiome, stateBiome);
}
}
}
}
@Test
public void columnAnchoredChunkPlanResolutionIsStableAcrossRepeatedBuilds() {
Fixture fixture = createMixedDepthFixture();
IrisDimensionCarvingResolver.State state = new IrisDimensionCarvingResolver.State();
IrisDimensionCarvingEntry root = legacyResolveRootEntry(fixture.engine, 80);
CarvingResolver.State state = new CarvingResolver.State();
ResolvedCarvingEntry root = legacyResolveRootEntry(fixture.engine, 80);
for (int chunkX = -24; chunkX <= 24; chunkX += 6) {
for (int chunkZ = -24; chunkZ <= 24; chunkZ += 6) {
IrisDimensionCarvingEntry[] firstPlan = buildColumnPlan(fixture.engine, root, chunkX, chunkZ, state);
IrisDimensionCarvingEntry[] secondPlan = buildColumnPlan(fixture.engine, root, chunkX, chunkZ, state);
ResolvedCarvingEntry[] firstPlan = buildColumnPlan(fixture.engine, root, chunkX, chunkZ, state);
ResolvedCarvingEntry[] secondPlan = buildColumnPlan(fixture.engine, root, chunkX, chunkZ, state);
for (int columnIndex = 0; columnIndex < firstPlan.length; columnIndex++) {
assertSame(
"column plan mismatch at chunkX=" + chunkX + " chunkZ=" + chunkZ + " columnIndex=" + columnIndex,
@@ -159,14 +145,14 @@ public class IrisDimensionCarvingResolverParityTest {
public void sharedResolverStateNeverCarriesDimensionEntriesAcrossEngines() {
Fixture first = createFixture();
Fixture second = createMixedDepthFixture();
IrisDimensionCarvingResolver.State state = new IrisDimensionCarvingResolver.State();
CarvingResolver.State state = new CarvingResolver.State();
IrisDimensionCarvingEntry firstExpected = legacyResolveRootEntry(first.engine, 80);
IrisDimensionCarvingEntry secondExpected = legacyResolveRootEntry(second.engine, 80);
ResolvedCarvingEntry firstExpected = legacyResolveRootEntry(first.engine, 80);
ResolvedCarvingEntry secondExpected = legacyResolveRootEntry(second.engine, 80);
assertSame(firstExpected, IrisDimensionCarvingResolver.resolveRootEntry(first.engine, 80, state));
assertSame(secondExpected, IrisDimensionCarvingResolver.resolveRootEntry(second.engine, 80, state));
assertSame(firstExpected, IrisDimensionCarvingResolver.resolveRootEntry(first.engine, 80, state));
assertSame(firstExpected, CarvingResolver.resolveRootEntry(first.engine, 80, state));
assertSame(secondExpected, CarvingResolver.resolveRootEntry(second.engine, 80, state));
assertSame(firstExpected, CarvingResolver.resolveRootEntry(first.engine, 80, state));
}
@Test
@@ -175,11 +161,11 @@ public class IrisDimensionCarvingResolverParityTest {
Fixture second = createMixedDepthFixture();
int worldY = 83;
IrisDimensionCarvingEntry firstExpected = legacyResolveRootEntry(first.engine, worldY);
IrisDimensionCarvingEntry secondExpected = legacyResolveRootEntry(second.engine, worldY);
ResolvedCarvingEntry firstExpected = legacyResolveRootEntry(first.engine, worldY);
ResolvedCarvingEntry secondExpected = legacyResolveRootEntry(second.engine, worldY);
assertSame(firstExpected, IrisDimensionCarvingResolver.resolveRootEntry(first.engine, worldY));
assertSame(secondExpected, IrisDimensionCarvingResolver.resolveRootEntry(second.engine, worldY));
assertSame(firstExpected, CarvingResolver.resolveRootEntry(first.engine, worldY));
assertSame(secondExpected, CarvingResolver.resolveRootEntry(second.engine, worldY));
}
@Test
@@ -188,25 +174,28 @@ public class IrisDimensionCarvingResolverParityTest {
Fixture replacement = createMixedDepthFixture();
AtomicReference<IrisDimension> dimension = new AtomicReference<>(first.engine.getDimension());
AtomicReference<IrisData> data = new AtomicReference<>(first.engine.getData());
AtomicReference<EngineGeneration> generation = new AtomicReference<>(first.engine.getGeneration());
Engine engine = mock(Engine.class, CALLS_REAL_METHODS);
doAnswer((InvocationOnMock invocation) -> dimension.get()).when(engine).getDimension();
doAnswer((InvocationOnMock invocation) -> data.get()).when(engine).getData();
doAnswer((InvocationOnMock invocation) -> generation.get()).when(engine).getGeneration();
int worldY = 83;
IrisDimensionCarvingEntry firstExpected = legacyResolveRootEntry(first.engine, worldY);
IrisDimensionCarvingEntry replacementExpected = legacyResolveRootEntry(replacement.engine, worldY);
assertSame(firstExpected, IrisDimensionCarvingResolver.resolveRootEntry(engine, worldY));
ResolvedCarvingEntry firstExpected = legacyResolveRootEntry(first.engine, worldY);
ResolvedCarvingEntry replacementExpected = legacyResolveRootEntry(replacement.engine, worldY);
assertSame(firstExpected, CarvingResolver.resolveRootEntry(engine, worldY));
dimension.set(replacement.engine.getDimension());
data.set(replacement.engine.getData());
assertSame(replacementExpected, IrisDimensionCarvingResolver.resolveRootEntry(engine, worldY));
generation.set(replacement.engine.getGeneration());
assertSame(replacementExpected, CarvingResolver.resolveRootEntry(engine, worldY));
}
@Test
public void resolverStateUsesWeakRuntimeIdentityBindings() throws NoSuchFieldException {
Field engineIdentity = IrisDimensionCarvingResolver.State.class.getDeclaredField("engineIdentity");
Field dimensionIdentity = IrisDimensionCarvingResolver.State.class.getDeclaredField("dimensionIdentity");
Field dataIdentity = IrisDimensionCarvingResolver.State.class.getDeclaredField("dataIdentity");
Field engineIdentity = CarvingResolver.State.class.getDeclaredField("engineIdentity");
Field dimensionIdentity = CarvingResolver.State.class.getDeclaredField("dimensionIdentity");
Field dataIdentity = CarvingResolver.State.class.getDeclaredField("dataIdentity");
assertSame(WeakReference.class, engineIdentity.getType());
assertSame(WeakReference.class, dimensionIdentity.getType());
@@ -240,19 +229,19 @@ public class IrisDimensionCarvingResolverParityTest {
private LifetimeReferences populateThreadLocalLifetimeReferences() throws Exception {
RetainedFixture fixture = createRetainedFixture();
assertNotNull(IrisDimensionCarvingResolver.resolveRootEntry(fixture.engine(), 80));
assertNotNull(CarvingResolver.resolveRootEntry(fixture.engine(), 80));
Field threadStateField = IrisDimensionCarvingResolver.class.getDeclaredField("THREAD_STATE");
Field threadStateField = CarvingResolver.class.getDeclaredField("THREAD_STATE");
threadStateField.setAccessible(true);
ThreadLocal<?> threadState = (ThreadLocal<?>) threadStateField.get(null);
Object value = threadState.get();
assertTrue(value instanceof WeakReference<?>);
@SuppressWarnings("unchecked")
WeakReference<IrisDimensionCarvingResolver.State> state =
(WeakReference<IrisDimensionCarvingResolver.State>) value;
IrisDimensionCarvingResolver.State populatedState = state.get();
WeakReference<CarvingResolver.State> state =
(WeakReference<CarvingResolver.State>) value;
CarvingResolver.State populatedState = state.get();
assertNotNull(populatedState);
Field biomeCacheField = IrisDimensionCarvingResolver.State.class.getDeclaredField("biomeCache");
Field biomeCacheField = CarvingResolver.State.class.getDeclaredField("biomeCache");
biomeCacheField.setAccessible(true);
assertFalse(((Map<?, ?>) biomeCacheField.get(populatedState)).isEmpty());
return new LifetimeReferences(
@@ -278,11 +267,11 @@ public class IrisDimensionCarvingResolverParityTest {
@Test
public void explicitStateRemainsStronglyCallerOwned() throws Exception {
RetainedFixture fixture = createRetainedFixture();
IrisDimensionCarvingResolver.State state = new IrisDimensionCarvingResolver.State();
assertSame(fixture.entry(), IrisDimensionCarvingResolver.resolveRootEntry(
CarvingResolver.State state = new CarvingResolver.State();
assertSame(fixture.entry(), CarvingResolver.resolveRootEntry(
fixture.engine(), 80, state));
Field rootEntriesField = IrisDimensionCarvingResolver.State.class
Field rootEntriesField = CarvingResolver.State.class
.getDeclaredField("rootEntriesByWorldY");
rootEntriesField.setAccessible(true);
System.gc();
@@ -300,26 +289,24 @@ public class IrisDimensionCarvingResolverParityTest {
doReturn(biome).when(biomeLoader).load("retained");
doReturn(biomeLoader).when(data).getBiomeLoader();
IrisDimensionCarvingEntry entry = buildEntry(
"retained", "retained", new IrisRange(-64, 320), 0, List.of());
KList<IrisDimensionCarvingEntry> carvingEntries = new KList<>();
carvingEntries.add(entry);
CarvingBands bands = new CarvingBands(List.of(buildEntry("retained", "retained", Range.of(-64, 320), 0, List.of())));
IrisDimension dimension = new IrisDimension();
dimension.setCarving(carvingEntries);
Engine engine = (Engine) Proxy.newProxyInstance(
Engine[] engine = new Engine[1];
AtomicReference<EngineGeneration> generation = new AtomicReference<>();
engine[0] = (Engine) Proxy.newProxyInstance(
Engine.class.getClassLoader(),
new Class<?>[]{Engine.class},
(proxy, method, arguments) -> switch (method.getName()) {
case "getDimension" -> dimension;
case "getData" -> data;
case "getGeneration" -> generation.updateAndGet(existing -> existing != null ? existing : generationWith(engine[0], bands));
case "hashCode" -> System.identityHashCode(proxy);
case "equals" -> proxy == arguments[0];
case "toString" -> "carving-retention-test-engine";
default -> throw new UnsupportedOperationException(method.toString());
});
return new RetainedFixture(engine, entry);
return new RetainedFixture(engine[0], bands.entries().getFirst());
}
private Fixture createFixture() {
@@ -336,7 +323,6 @@ public class IrisDimensionCarvingResolverParityTest {
doReturn(2).when(childABiome).getRarity();
doReturn(5).when(childBBiome).getRarity();
doReturn(1).when(childCBiome).getRarity();
doReturn(0).when(fallbackBiome).getCaveMinDepthBelowSurface();
@SuppressWarnings("unchecked")
ResourceLoader<IrisBiome> biomeLoader = mock(ResourceLoader.class);
@@ -349,29 +335,15 @@ public class IrisDimensionCarvingResolverParityTest {
IrisData data = mock(IrisData.class);
doReturn(biomeLoader).when(data).getBiomeLoader();
IrisDimensionCarvingEntry rootLow = buildEntry("root-low", "root-low", new IrisRange(-64, 120), 4, List.of("child-a", "child-b"));
IrisDimensionCarvingEntry rootHigh = buildEntry("root-high", "root-high", new IrisRange(121, 320), 3, List.of("child-b", "child-c"));
IrisDimensionCarvingEntry childA = buildEntry("child-a", "child-a", new IrisRange(-2048, -1024), 3, List.of("child-b"));
IrisDimensionCarvingEntry childB = buildEntry("child-b", "child-b", new IrisRange(-2048, -1024), 2, List.of("child-c", "child-a"));
IrisDimensionCarvingEntry childC = buildEntry("child-c", "child-c", new IrisRange(-2048, -1024), 1, List.of());
CarvingEntry rootLow = buildEntry("root-low", "root-low", Range.of(-64, 120), 4, List.of("child-a", "child-b"));
CarvingEntry rootHigh = buildEntry("root-high", "root-high", Range.of(121, 320), 3, List.of("child-b", "child-c"));
CarvingEntry childA = buildEntry("child-a", "child-a", Range.of(-2048, -1024), 3, List.of("child-b"));
CarvingEntry childB = buildEntry("child-b", "child-b", Range.of(-2048, -1024), 2, List.of("child-c", "child-a"));
CarvingEntry childC = buildEntry("child-c", "child-c", Range.of(-2048, -1024), 1, List.of());
KList<IrisDimensionCarvingEntry> carvingEntries = new KList<>();
carvingEntries.add(rootLow);
carvingEntries.add(rootHigh);
carvingEntries.add(childA);
carvingEntries.add(childB);
carvingEntries.add(childC);
Map<String, IrisDimensionCarvingEntry> index = new HashMap<>();
index.put(rootLow.getId(), rootLow);
index.put(rootHigh.getId(), rootHigh);
index.put(childA.getId(), childA);
index.put(childB.getId(), childB);
index.put(childC.getId(), childC);
CarvingBands bands = new CarvingBands(List.of(rootLow, rootHigh, childA, childB, childC));
IrisDimension dimension = mock(IrisDimension.class);
doReturn(carvingEntries).when(dimension).getCarving();
doReturn(index).when(dimension).getCarvingEntryIndex();
Engine engine = mock(Engine.class, CALLS_REAL_METHODS);
doReturn(dimension).when(engine).getDimension();
@@ -380,6 +352,7 @@ public class IrisDimensionCarvingResolverParityTest {
doReturn(IrisWorld.builder().minHeight(-64).maxHeight(320).build()).when(engine).getWorld();
doReturn(surfaceBiome).when(engine).getSurfaceBiome(anyInt(), anyInt());
doReturn(fallbackBiome).when(engine).getCaveBiome(anyInt(), anyInt());
DecoratorTestEngines.withGeneration(engine).state(CarvingBands.class, ignored -> bands);
return new Fixture(engine);
}
@@ -406,7 +379,6 @@ public class IrisDimensionCarvingResolverParityTest {
doReturn(4).when(childEBiome).getRarity();
doReturn(8).when(childFBiome).getRarity();
doReturn(2).when(childGBiome).getRarity();
doReturn(0).when(fallbackBiome).getCaveMinDepthBelowSurface();
@SuppressWarnings("unchecked")
ResourceLoader<IrisBiome> biomeLoader = mock(ResourceLoader.class);
@@ -423,41 +395,19 @@ public class IrisDimensionCarvingResolverParityTest {
IrisData data = mock(IrisData.class);
doReturn(biomeLoader).when(data).getBiomeLoader();
IrisDimensionCarvingEntry rootLow = buildEntry("root-low", "root-low", new IrisRange(-64, 120), 7, List.of("child-a", "child-d", "child-e"));
IrisDimensionCarvingEntry rootHigh = buildEntry("root-high", "root-high", new IrisRange(121, 320), 6, List.of("child-b", "child-c", "child-f"));
IrisDimensionCarvingEntry childA = buildEntry("child-a", "child-a", new IrisRange(-4096, 4096), 5, List.of("child-b", "child-g"));
IrisDimensionCarvingEntry childB = buildEntry("child-b", "child-b", new IrisRange(-4096, 4096), 1, List.of("child-c"));
IrisDimensionCarvingEntry childC = buildEntry("child-c", "child-c", new IrisRange(-4096, 4096), 0, List.of());
IrisDimensionCarvingEntry childD = buildEntry("child-d", "child-d", new IrisRange(-4096, 4096), 6, List.of("child-e", "child-f"));
IrisDimensionCarvingEntry childE = buildEntry("child-e", "child-e", new IrisRange(-4096, 4096), 2, List.of("child-a"));
IrisDimensionCarvingEntry childF = buildEntry("child-f", "child-f", new IrisRange(-4096, 4096), 8, List.of("child-g", "child-c"));
IrisDimensionCarvingEntry childG = buildEntry("child-g", "child-g", new IrisRange(-4096, 4096), 3, List.of("child-d"));
CarvingEntry rootLow = buildEntry("root-low", "root-low", Range.of(-64, 120), 7, List.of("child-a", "child-d", "child-e"));
CarvingEntry rootHigh = buildEntry("root-high", "root-high", Range.of(121, 320), 6, List.of("child-b", "child-c", "child-f"));
CarvingEntry childA = buildEntry("child-a", "child-a", Range.of(-4096, 4096), 5, List.of("child-b", "child-g"));
CarvingEntry childB = buildEntry("child-b", "child-b", Range.of(-4096, 4096), 1, List.of("child-c"));
CarvingEntry childC = buildEntry("child-c", "child-c", Range.of(-4096, 4096), 0, List.of());
CarvingEntry childD = buildEntry("child-d", "child-d", Range.of(-4096, 4096), 6, List.of("child-e", "child-f"));
CarvingEntry childE = buildEntry("child-e", "child-e", Range.of(-4096, 4096), 2, List.of("child-a"));
CarvingEntry childF = buildEntry("child-f", "child-f", Range.of(-4096, 4096), 8, List.of("child-g", "child-c"));
CarvingEntry childG = buildEntry("child-g", "child-g", Range.of(-4096, 4096), 3, List.of("child-d"));
KList<IrisDimensionCarvingEntry> carvingEntries = new KList<>();
carvingEntries.add(rootLow);
carvingEntries.add(rootHigh);
carvingEntries.add(childA);
carvingEntries.add(childB);
carvingEntries.add(childC);
carvingEntries.add(childD);
carvingEntries.add(childE);
carvingEntries.add(childF);
carvingEntries.add(childG);
Map<String, IrisDimensionCarvingEntry> index = new HashMap<>();
index.put(rootLow.getId(), rootLow);
index.put(rootHigh.getId(), rootHigh);
index.put(childA.getId(), childA);
index.put(childB.getId(), childB);
index.put(childC.getId(), childC);
index.put(childD.getId(), childD);
index.put(childE.getId(), childE);
index.put(childF.getId(), childF);
index.put(childG.getId(), childG);
CarvingBands bands = new CarvingBands(List.of(rootLow, rootHigh, childA, childB, childC, childD, childE, childF, childG));
IrisDimension dimension = mock(IrisDimension.class);
doReturn(carvingEntries).when(dimension).getCarving();
doReturn(index).when(dimension).getCarvingEntryIndex();
Engine engine = mock(Engine.class, CALLS_REAL_METHODS);
doReturn(dimension).when(engine).getDimension();
@@ -466,43 +416,51 @@ public class IrisDimensionCarvingResolverParityTest {
doReturn(IrisWorld.builder().minHeight(-64).maxHeight(320).build()).when(engine).getWorld();
doReturn(surfaceBiome).when(engine).getSurfaceBiome(anyInt(), anyInt());
doReturn(fallbackBiome).when(engine).getCaveBiome(anyInt(), anyInt());
DecoratorTestEngines.withGeneration(engine).state(CarvingBands.class, ignored -> bands);
return new Fixture(engine);
}
private IrisDimensionCarvingEntry[] buildColumnPlan(Engine engine, IrisDimensionCarvingEntry rootEntry, int chunkX, int chunkZ, IrisDimensionCarvingResolver.State state) {
IrisDimensionCarvingEntry[] plan = new IrisDimensionCarvingEntry[256];
private ResolvedCarvingEntry[] buildColumnPlan(Engine engine, ResolvedCarvingEntry rootEntry, int chunkX, int chunkZ, CarvingResolver.State state) {
ResolvedCarvingEntry[] plan = new ResolvedCarvingEntry[256];
for (int localX = 0; localX < 16; localX++) {
int worldX = (chunkX << 4) + localX;
for (int localZ = 0; localZ < 16; localZ++) {
int worldZ = (chunkZ << 4) + localZ;
int columnIndex = (localX << 4) | localZ;
plan[columnIndex] = IrisDimensionCarvingResolver.resolveFromRoot(engine, rootEntry, worldX, worldZ, state);
plan[columnIndex] = CarvingResolver.resolveFromRoot(engine, rootEntry, worldX, worldZ, state);
}
}
return plan;
}
private IrisDimensionCarvingEntry buildEntry(String id, String biome, IrisRange worldRange, int depth, List<String> children) {
IrisDimensionCarvingEntry entry = new IrisDimensionCarvingEntry();
entry.setId(id);
entry.setEnabled(true);
entry.setBiome(biome);
entry.setWorldYRange(worldRange);
entry.setChildRecursionDepth(depth);
entry.setChildren(new KList<>(children));
return entry;
private static EngineGeneration generationWith(Engine engine, CarvingBands bands) {
EngineGeneration generation = new EngineGeneration(engine);
generation.state(CarvingBands.class, ignored -> bands);
return generation;
}
private IrisDimensionCarvingEntry legacyResolveRootEntry(Engine engine, int worldY) {
IrisDimension dimension = engine.getDimension();
List<IrisDimensionCarvingEntry> entries = dimension.getCarving();
if (entries == null || entries.isEmpty()) {
private CarvingEntry buildEntry(String id, String biome, Range worldRange, int depth, List<String> children) {
JsonObject json = new JsonObject();
json.addProperty("id", id);
json.addProperty("biome", biome);
JsonObject range = new JsonObject();
range.addProperty("min", worldRange.min());
range.addProperty("max", worldRange.max());
json.add("worldYRange", range);
json.addProperty("childRecursionDepth", depth);
json.add("children", new Gson().toJsonTree(children));
return new Gson().fromJson(json, CarvingEntry.class);
}
private ResolvedCarvingEntry legacyResolveRootEntry(Engine engine, int worldY) {
List<ResolvedCarvingEntry> entries = CarvingBands.of(engine).entries();
if (entries.isEmpty()) {
return null;
}
IrisDimensionCarvingEntry resolved = null;
for (IrisDimensionCarvingEntry entry : entries) {
ResolvedCarvingEntry resolved = null;
for (ResolvedCarvingEntry entry : entries) {
if (!legacyIsRootCandidate(engine, entry, worldY)) {
continue;
}
@@ -513,7 +471,7 @@ public class IrisDimensionCarvingResolverParityTest {
return resolved;
}
private IrisDimensionCarvingEntry legacyResolveFromRoot(Engine engine, IrisDimensionCarvingEntry rootEntry, int worldX, int worldZ) {
private ResolvedCarvingEntry legacyResolveFromRoot(Engine engine, ResolvedCarvingEntry rootEntry, int worldX, int worldZ) {
if (rootEntry == null) {
return null;
}
@@ -523,22 +481,22 @@ public class IrisDimensionCarvingResolverParityTest {
return null;
}
int remainingDepth = clampDepth(rootEntry.getChildRecursionDepth());
int remainingDepth = clampDepth(rootEntry.childRecursionDepth());
if (remainingDepth <= 0) {
return rootEntry;
}
Map<String, IrisDimensionCarvingEntry> entryIndex = engine.getDimension().getCarvingEntryIndex();
IrisDimensionCarvingEntry current = rootEntry;
Map<String, ResolvedCarvingEntry> entryIndex = CarvingBands.of(engine).index();
ResolvedCarvingEntry current = rootEntry;
int depth = remainingDepth;
while (depth > 0) {
IrisDimensionCarvingEntry selected = legacySelectChild(engine, current, worldX, worldZ, entryIndex);
ResolvedCarvingEntry selected = legacySelectChild(engine, current, worldX, worldZ, entryIndex);
if (selected == null || selected == current) {
break;
}
depth--;
int childDepthLimit = clampDepth(selected.getChildRecursionDepth());
int childDepthLimit = clampDepth(selected.childRecursionDepth());
if (childDepthLimit < depth) {
depth = childDepthLimit;
}
@@ -548,20 +506,20 @@ public class IrisDimensionCarvingResolverParityTest {
return current;
}
private IrisBiome legacyResolveEntryBiome(Engine engine, IrisDimensionCarvingEntry entry) {
private IrisBiome legacyResolveEntryBiome(Engine engine, ResolvedCarvingEntry entry) {
if (entry == null) {
return null;
}
return entry.getRealBiome(engine.getData());
return entry.realBiome(engine.getData());
}
private boolean legacyIsRootCandidate(Engine engine, IrisDimensionCarvingEntry entry, int worldY) {
if (entry == null || !entry.isEnabled()) {
private boolean legacyIsRootCandidate(Engine engine, ResolvedCarvingEntry entry, int worldY) {
if (entry == null || !entry.enabled()) {
return false;
}
IrisRange worldYRange = entry.getWorldYRange();
Range worldYRange = entry.worldYRange();
if (worldYRange != null && !worldYRange.contains(worldY)) {
return false;
}
@@ -569,15 +527,15 @@ public class IrisDimensionCarvingResolverParityTest {
return legacyResolveEntryBiome(engine, entry) != null;
}
private IrisDimensionCarvingEntry legacySelectChild(
private ResolvedCarvingEntry legacySelectChild(
Engine engine,
IrisDimensionCarvingEntry parent,
ResolvedCarvingEntry parent,
int worldX,
int worldZ,
Map<String, IrisDimensionCarvingEntry> entryIndex
Map<String, ResolvedCarvingEntry> entryIndex
) {
KList<String> children = parent.getChildren();
if (children == null || children.isEmpty()) {
List<String> children = parent.children();
if (children.isEmpty()) {
return parent;
}
@@ -592,8 +550,8 @@ public class IrisDimensionCarvingResolverParityTest {
continue;
}
IrisDimensionCarvingEntry child = entryIndex.get(childId.trim());
if (child == null || !child.isEnabled()) {
ResolvedCarvingEntry child = entryIndex.get(childId.trim());
if (child == null || !child.enabled()) {
continue;
}
@@ -611,7 +569,7 @@ public class IrisDimensionCarvingResolverParityTest {
}
long seed = engine.getSeedManager().getCarve() ^ CHILD_SEED_SALT;
CNG childGenerator = parent.getChildrenGenerator(seed, engine.getData());
CNG childGenerator = parent.childrenGenerator(seed, engine.getData());
LegacyCarvingChoice selected = childGenerator.fitRarity(options, worldX, worldZ);
if (selected == null || selected.entry == null) {
return parent;
@@ -640,20 +598,20 @@ public class IrisDimensionCarvingResolverParityTest {
private record Fixture(Engine engine) {
}
private record RetainedFixture(Engine engine, IrisDimensionCarvingEntry entry) {
private record RetainedFixture(Engine engine, ResolvedCarvingEntry entry) {
}
private record LifetimeReferences(
WeakReference<IrisDimensionCarvingResolver.State> state,
WeakReference<CarvingResolver.State> state,
WeakReference<Engine> engine
) {
}
private static final class LegacyCarvingChoice implements IRare {
private final IrisDimensionCarvingEntry entry;
private final ResolvedCarvingEntry entry;
private final int rarity;
private LegacyCarvingChoice(IrisDimensionCarvingEntry entry, int rarity) {
private LegacyCarvingChoice(ResolvedCarvingEntry entry, int rarity) {
this.entry = entry;
this.rarity = rarity;
}
@@ -23,7 +23,6 @@ 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;
@@ -33,7 +32,6 @@ 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;
@@ -133,15 +131,6 @@ public class FloatingChildBiomeDecodingTest {
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);
@@ -18,6 +18,9 @@
package art.arcane.iris.engine.object.terrain.floating;
import art.arcane.iris.core.modules.ModuleSettings;
import art.arcane.iris.core.modules.BuiltInPack;
import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.engine.object.TestSettings;
import art.arcane.iris.builtin.floating.TopShapeMode;
@@ -563,7 +566,8 @@ public class FloatingIslandBoundarySamplerTest {
IrisWorld world = IrisWorld.builder().minHeight(0).maxHeight(320).build();
KList<ResolvedFloatingChild> entries = new KList<>();
entries.add(entry);
when(parent.isMergeFloatingChildBiomes()).thenReturn(false);
ModuleSettings separate = BuiltInPack.settings(new MergeFloatingChildrenSettings(false));
when(parent.getModuleSettings()).thenReturn(separate);
when(entry.getFootprintCng(anyLong(), same(data))).thenReturn(footprint);
when(entry.getAltitudeCng(anyLong(), same(data))).thenReturn(constant);
when(entry.getRealBiome(parent, data)).thenReturn(parent);
@@ -630,7 +634,8 @@ public class FloatingIslandBoundarySamplerTest {
KList<ResolvedFloatingChild> entries = new KList<>();
entries.add(lower);
entries.add(upper);
when(parent.isMergeFloatingChildBiomes()).thenReturn(true);
ModuleSettings merged = BuiltInPack.settings(new MergeFloatingChildrenSettings(true));
when(parent.getModuleSettings()).thenReturn(merged);
for (ResolvedFloatingChild entry : entries) {
when(entry.getFootprintCng(anyLong(), same(data))).thenReturn(footprint);
when(entry.getAltitudeCng(anyLong(), same(data))).thenReturn(constant);
@@ -2,11 +2,15 @@ package art.arcane.iris.engine.object.terrain.floating;
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;
import art.arcane.iris.builtin.carve.CarvingEntry;
import art.arcane.iris.builtin.carve.CarvingSettings;
import art.arcane.iris.core.modules.BuiltInPack;
import art.arcane.iris.core.modules.ModuleSettings;
import art.arcane.iris.engine.decorator.DecoratorTestEngines;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.volmlib.util.collection.KList;
import com.google.gson.Gson;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
@@ -15,6 +19,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -68,11 +73,9 @@ public class ResolvedFloatingChildCarvingResolutionTest {
public void resolveCarvingBiome_prefersDimensionCarvingEntryId() {
IrisBiome entryBiome = mock(IrisBiome.class);
IrisBiome sameKeyBiome = mock(IrisBiome.class);
IrisDimensionCarvingEntry entry = new IrisDimensionCarvingEntry();
entry.setId("global-deepdark-band");
entry.setBiome("carving/standard-deepdark");
CarvingEntry entry = new Gson().fromJson("{\"id\": \"global-deepdark-band\", \"biome\": \"carving/standard-deepdark\"}", CarvingEntry.class);
Map<String, IrisDimensionCarvingEntry> entries = new HashMap<>();
Map<String, CarvingEntry> entries = new HashMap<>();
entries.put("global-deepdark-band", entry);
Map<String, IrisBiome> biomes = new HashMap<>();
@@ -86,7 +89,7 @@ public class ResolvedFloatingChildCarvingResolutionTest {
assertSame(entryBiome, resolved);
}
private Fixture createFixture(Map<String, IrisDimensionCarvingEntry> entries, Map<String, IrisBiome> biomes) {
private Fixture createFixture(Map<String, CarvingEntry> entries, Map<String, IrisBiome> biomes) {
@SuppressWarnings("unchecked")
ResourceLoader<IrisBiome> biomeLoader = mock(ResourceLoader.class);
for (Map.Entry<String, IrisBiome> biome : biomes.entrySet()) {
@@ -97,12 +100,13 @@ public class ResolvedFloatingChildCarvingResolutionTest {
doReturn(biomeLoader).when(data).getBiomeLoader();
IrisDimension dimension = mock(IrisDimension.class);
doReturn(entries).when(dimension).getCarvingEntryIndex();
doReturn(new KList<>(entries.values())).when(dimension).getCarving();
ModuleSettings declared = BuiltInPack.settings(new CarvingSettings(new ArrayList<>(entries.values())));
doReturn(declared).when(dimension).getModuleSettings();
Engine engine = mock(Engine.class);
doReturn(data).when(engine).getData();
doReturn(dimension).when(engine).getDimension();
DecoratorTestEngines.withGeneration(engine);
return new Fixture(engine, data);
}
@@ -0,0 +1,53 @@
/*
* 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.engine.object.world;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertThrows;
/** The carving, floating and ore settings are fields of modules now, not of Iris's pack classes: they stay off them. */
public class MovedModuleFieldsTest {
@Test
public void theCaveFloatingAndOreSettingsAreNoFieldsOfTheBiome() {
for (String field : List.of("caveProfile", "carvingBiome", "caveMinDepthBelowSurface", "floatingChildBiomes", "mergeFloatingChildBiomes",
"oreDepositFrequencyMultiplier", "oreDepositSizeMultiplier", "depositVariants", "ores")) {
assertThrows(field, NoSuchFieldException.class, () -> IrisBiome.class.getDeclaredField(field));
}
}
@Test
public void theCaveAndOreSettingsAreNoFieldsOfTheRegion() {
for (String field : List.of("caveProfile", "depositVariants", "ores")) {
assertThrows(field, NoSuchFieldException.class, () -> IrisRegion.class.getDeclaredField(field));
}
}
@Test
public void theCarvingAndOreSettingsAreNoFieldsOfTheDimension() {
for (String field : List.of("caveProfile", "carving", "carvingEnabled", "depositVariants", "ores", "hideOresForHiddenOre")) {
assertThrows(field, NoSuchFieldException.class, () -> IrisDimension.class.getDeclaredField(field));
}
}
}
@@ -4,13 +4,20 @@ 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;
import art.arcane.iris.builtin.carve.CarvingBiomeSettings;
import art.arcane.iris.builtin.carve.CarvingEntry;
import art.arcane.iris.builtin.carve.CarvingSettings;
import art.arcane.iris.builtin.floating.FloatingChildSettings;
import art.arcane.iris.core.modules.BuiltInPack;
import com.google.gson.Gson;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.IrisFeature;
import org.junit.Test;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -24,44 +31,30 @@ public class IrisDimensionReachableBiomesTest {
@Test
@SuppressWarnings("unchecked")
public void includesExactRecursiveGenerationClosure() {
IrisDimensionCarvingEntry deepBand = new IrisDimensionCarvingEntry()
.setId("global-deep-band")
.setBiome("deep-root");
IrisDimensionCarvingEntry disabledBand = new IrisDimensionCarvingEntry()
.setId("disabled-band")
.setEnabled(false)
.setBiome("disabled-deep");
IrisDimensionCarvingEntry floatingCarvingEntry = new IrisDimensionCarvingEntry()
.setId("floating-carving-entry")
.setEnabled(false)
.setBiome("entry-floating-carve");
CarvingEntry deepBand = entry("global-deep-band", true, "deep-root");
CarvingEntry disabledBand = entry("disabled-band", false, "disabled-deep");
CarvingEntry floatingCarvingEntry = entry("floating-carving-entry", false, "entry-floating-carve");
IrisDimension dimension = new IrisDimension().setRegions(new KList<>("reachable", "missing"));
dimension.setCarving(new KList<>(deepBand, disabledBand, floatingCarvingEntry));
dimension.setModuleSettings(BuiltInPack.settings(new CarvingSettings(List.of(deepBand, disabledBand, floatingCarvingEntry))));
IrisRegion reachable = new IrisRegion()
.setLandBiomes(new KList<>("parent", "shared"))
.setSeaBiomes(new KList<>("shared"));
IrisBiome parent = biome("parent")
.setChildren(new KList<>("child", "shared"))
.setCarvingBiome("carve")
.setFloatingChildBiomes(new KList<>(floating("floating-target", "direct-floating-carve")));
IrisBiome parent = biome("parent", carvingBiome("carve"), floatingChildren(floating("floating-target", "direct-floating-carve")))
.setChildren(new KList<>("child", "shared"));
IrisBiome child = biome("child").setChildren(new KList<>("parent"));
IrisBiome shared = biome("shared");
IrisBiome carve = biome("carve");
IrisBiome floatingTarget = biome("floating-target")
.setChildren(new KList<>("floating-child"))
.setCarvingBiome("floating-carve");
IrisBiome floatingChild = biome("floating-child")
.setFloatingChildBiomes(new KList<>(floating("nested-floating", "floating-carving-entry")));
IrisBiome floatingTarget = biome("floating-target", carvingBiome("floating-carve"))
.setChildren(new KList<>("floating-child"));
IrisBiome floatingChild = biome("floating-child", floatingChildren(floating("nested-floating", "floating-carving-entry")));
IrisBiome floatingCarve = biome("floating-carve");
IrisBiome directFloatingCarve = biome("direct-floating-carve");
IrisBiome entryFloatingCarve = biome("entry-floating-carve");
IrisBiome shadowedFloatingCarve = biome("floating-carving-entry");
IrisBiome nestedFloating = biome("nested-floating")
.setFloatingChildBiomes(new KList<>(floating("parent")));
IrisBiome nestedFloating = biome("nested-floating", floatingChildren(floating("parent")));
IrisBiome deepRoot = biome("deep-root").setChildren(new KList<>("deep-child"));
IrisBiome deepChild = biome("deep-child").setCarvingBiome("deep-carve");
IrisBiome deepCarve = biome("deep-carve")
.setFloatingChildBiomes(new KList<>(floating("deep-floating")));
IrisBiome deepChild = biome("deep-child", carvingBiome("deep-carve"));
IrisBiome deepCarve = biome("deep-carve", floatingChildren(floating("deep-floating")));
IrisBiome deepFloating = biome("deep-floating").setChildren(new KList<>("deep-root"));
IrisBiome disabledDeep = biome("disabled-deep");
IrisBiome unused = biome("unused");
@@ -108,11 +101,10 @@ public class IrisDimensionReachableBiomesTest {
IrisDimension dimension = new IrisDimension().setRegions(new KList<>("reachable"));
IrisRegion reachable = new IrisRegion().setLandBiomes(new KList<>("a"));
IrisBiome a = biome("a").setChildren(new KList<>("b"));
IrisBiome b = biome("b").setCarvingBiome("c");
IrisBiome c = biome("c").setFloatingChildBiomes(new KList<>(floating("d", "a")));
IrisBiome d = biome("d")
.setChildren(new KList<>("a"))
.setFloatingChildBiomes(new KList<>(floating("b")));
IrisBiome b = biome("b", carvingBiome("c"));
IrisBiome c = biome("c", floatingChildren(floating("d", "a")));
IrisBiome d = biome("d", floatingChildren(floating("b")))
.setChildren(new KList<>("a"));
IrisData data = mock(IrisData.class);
ResourceLoader<IrisRegion> regionLoader = mock(ResourceLoader.class);
@@ -136,12 +128,25 @@ public class IrisDimensionReachableBiomesTest {
verify(biomeLoader, times(1)).load("d");
}
private IrisBiome biome(String loadKey) {
private IrisBiome biome(String loadKey, IrisFeature... settings) {
IrisBiome biome = new IrisBiome();
biome.setLoadKey(loadKey);
biome.setModuleSettings(BuiltInPack.settings(settings));
return biome;
}
private CarvingBiomeSettings carvingBiome(String key) {
return new CarvingBiomeSettings(key);
}
private FloatingChildSettings floatingChildren(FloatingChildBiome... children) {
return new FloatingChildSettings(List.of(children));
}
private CarvingEntry entry(String id, boolean enabled, String biome) {
return new Gson().fromJson("{\"id\": \"" + id + "\", \"enabled\": " + enabled + ", \"biome\": \"" + biome + "\"}", CarvingEntry.class);
}
private FloatingChildBiome floating(String biomeKey) {
return TestSettings.with(new FloatingChildBiome(), "biome", biomeKey);
}
@@ -0,0 +1,73 @@
/*
* 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.engine.object.world.region;
import art.arcane.iris.builtin.carve.CarvingBiomeSettings;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.builtin.floating.FloatingChildSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.BuiltInPack;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.volmlib.util.collection.KList;
import com.google.gson.Gson;
import com.volmit.IrisFeature;
import org.junit.Test;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** The biomes of a region: the ones it lists, their children and the biomes their {@code carvingBiome} registers; not the targets of floating islands. */
public class IrisRegionBiomeTreeTest {
@Test
@SuppressWarnings("unchecked")
public void aBiomesCarvingBiomeJoinsTheRegionAndAFloatingChildDoesNot() {
IrisRegion region = new IrisRegion().setLandBiomes(new KList<>("plains"));
FloatingChildBiome floating = new Gson().fromJson("{\"biome\": \"floating/target\", \"carving\": \"carving/pocket\"}", FloatingChildBiome.class);
IrisBiome plains = biome("plains", new CarvingBiomeSettings("carving/mushroom"), new FloatingChildSettings(List.of(floating)))
.setChildren(new KList<>("meadow"));
IrisBiome meadow = biome("meadow");
IrisBiome mushroom = biome("carving/mushroom", new CarvingBiomeSettings("carving/nested"));
IrisBiome nested = biome("carving/nested");
IrisData data = mock(IrisData.class);
ResourceLoader<IrisBiome> biomes = mock(ResourceLoader.class);
when(data.getBiomeLoader()).thenReturn(biomes);
when(biomes.load("plains")).thenReturn(plains);
when(biomes.load("meadow")).thenReturn(meadow);
when(biomes.load("carving/mushroom")).thenReturn(mushroom);
when(biomes.load("carving/nested")).thenReturn(nested);
Set<String> keys = region.getAllBiomes(() -> data).stream().map(IrisBiome::getLoadKey).collect(Collectors.toSet());
assertEquals(Set.of("plains", "meadow", "carving/mushroom", "carving/nested"), keys);
}
private static IrisBiome biome(String key, IrisFeature... settings) {
IrisBiome biome = new IrisBiome();
biome.setLoadKey(key);
biome.setModuleSettings(BuiltInPack.settings(settings));
return biome;
}
}
@@ -0,0 +1,292 @@
{
"name": "Amethyst Cavern",
"derivative": "minecraft:dripstone_caves",
"vanillaDerivative": "minecraft:dripstone_caves",
"wall": {
"palette": [
{
"block": "minecraft:amethyst_block",
"weight": 6
},
{
"block": "minecraft:budding_amethyst"
}
]
},
"layers": [
{
"palette": [
{
"block": "minecraft:amethyst_block",
"weight": 6
},
{
"block": "minecraft:budding_amethyst"
}
],
"maxHeight": 2,
"minHeight": 2
},
{
"palette": [
{
"block": "minecraft:deepslate"
}
]
}
],
"decorators": [
{
"chance": 0.1,
"palette": [
{
"block": "minecraft:amethyst_cluster",
"weight": 4
},
{
"block": "minecraft:small_amethyst_bud",
"weight": 3
},
{
"block": "minecraft:medium_amethyst_bud",
"weight": 2
},
{
"block": "minecraft:large_amethyst_bud"
}
]
},
{
"partOf": "CEILING",
"chance": 0.1,
"palette": [
{
"block": "minecraft:amethyst_cluster",
"data": {
"facing": "down"
},
"weight": 4
},
{
"block": "minecraft:small_amethyst_bud",
"data": {
"facing": "down"
},
"weight": 3
},
{
"block": "minecraft:medium_amethyst_bud",
"data": {
"facing": "down"
},
"weight": 2
},
{
"block": "minecraft:large_amethyst_bud",
"data": {
"facing": "down"
}
}
]
}
],
"caveCeilingLayers": [
{
"palette": [
{
"block": "minecraft:amethyst_block",
"weight": 6
},
{
"block": "minecraft:budding_amethyst"
}
],
"maxHeight": 2,
"minHeight": 2
},
{
"palette": [
{
"block": "minecraft:deepslate"
}
]
}
],
"objects": [
{
"chance": 0.21,
"density": 4,
"carvingSupport": "CARVING_ONLY",
"caveAnchorMode": "PROFILE_DEFAULT",
"translate": {
"y": -1
},
"place": [
"clutter/amethyst-cluster1",
"clutter/amethyst-cluster2",
"clutter/amethyst-cluster3",
"clutter/amethyst-cluster4"
],
"bottom": true,
"force": true,
"scale": {
"size": 0.75
}
},
{
"chance": 0.165,
"density": 4,
"carvingSupport": "CARVING_ONLY",
"caveAnchorMode": "PROFILE_DEFAULT",
"translate": {
"y": -1
},
"place": [
"clutter/amethyst-cluster1",
"clutter/amethyst-cluster2",
"clutter/amethyst-cluster3",
"clutter/amethyst-cluster4",
"clutter/amethyst-cluster5"
],
"bottom": true,
"force": true,
"scale": {
"size": 0.75
}
},
{
"chance": 0.0972,
"density": 4,
"carvingSupport": "CARVING_ONLY",
"caveAnchorMode": "PROFILE_DEFAULT",
"translate": {
"y": -1
},
"place": [
"clutter/amethyst-cluster1",
"clutter/amethyst-cluster2",
"clutter/amethyst-cluster3"
],
"bottom": true,
"force": true,
"scale": {
"size": 0.75
}
},
{
"chance": 0.0972,
"density": 4,
"carvingSupport": "CARVING_ONLY",
"caveAnchorMode": "PROFILE_DEFAULT",
"translate": {
"y": -1
},
"place": [
"clutter/rock1",
"clutter/rock2",
"clutter/rock3",
"clutter/rock4",
"clutter/boulder1",
"clutter/boulder2",
"clutter/boulder3",
"clutter/boulder4"
],
"bottom": true,
"force": true,
"scale": {
"size": 0.75
}
}
],
"caveProfile": {
"enabled": true,
"verticalRange": {
"min": 6,
"max": 620
},
"baseDensityStyle": {
"style": "PERLIN_IRIS",
"zoom": 0.8
},
"detailDensityStyle": {
"style": "FRACTAL_BILLOW_SIMPLEX",
"zoom": 0.52
},
"warpStyle": {
"style": "SIMPLEX",
"zoom": 0.46
},
"baseWeight": 0.91,
"detailWeight": 0.1,
"warpStrength": 0.18,
"densityThreshold": {
"min": -0.12,
"max": -0.04,
"style": {
"style": "SIMPLEX",
"zoom": 0.7
}
},
"thresholdBias": 0.12,
"sampleStep": 2,
"surfaceClearance": 6,
"allowSurfaceBreak": true,
"surfaceBreakStyle": {
"style": "SIMPLEX",
"zoom": 0.9
},
"surfaceBreakNoiseThreshold": 0.68,
"surfaceBreakDepth": 12,
"surfaceBreakThresholdBoost": 0.1,
"objectMinDepthBelowSurface": 16,
"defaultObjectAnchor": "FLOOR",
"defaultObjectPlaceMode": "ORGANIC_STILT",
"anchorScanStep": 1,
"anchorSearchAttempts": 18,
"allowFluid": true,
"fluidMinDepthBelowSurface": 20,
"fluidRequiresFloor": true,
"allowLava": true,
"modules": [
{
"style": {
"style": "SIMPLEX_VASCULAR",
"zoom": 0.98
},
"weight": 0.08,
"threshold": 0.03,
"verticalRange": {
"min": 24,
"max": 680
},
"invert": false
},
{
"style": {
"style": "FRACTAL_BILLOW_SIMPLEX",
"zoom": 0.34
},
"weight": 0.04,
"threshold": 0.07,
"verticalRange": {
"min": 8,
"max": 260
},
"invert": true
}
],
"verticalEdgeFade": 26,
"verticalEdgeFadeStrength": 0.18,
"minCarveCells": 24,
"recoveryThresholdBoost": 0.07
},
"caveMinDepthBelowSurface": 10,
"children": [
"carving/amethyst-child"
],
"childStyle": {
"style": "CELLULAR_IRIS_DOUBLE",
"zoom": 0.74
},
"childShrinkFactor": 1.54
}
@@ -0,0 +1,551 @@
{
"name": "Magnetics Plains",
"color": "#89C46A",
"rarity": 1,
"derivative": "minecraft:plains",
"vanillaDerivative": "minecraft:plains",
"generators": [
{
"min": -3,
"max": 14,
"generator": "magnetics/plains"
}
],
"wall": {
"palette": [
{
"block": "minecraft:mossy_cobblestone"
},
{
"block": "minecraft:cobblestone"
},
{
"block": "minecraft:stone"
},
{
"block": "minecraft:moss_block"
}
]
},
"layers": [
{
"maxHeight": 1,
"palette": [
{
"block": "minecraft:grass_block"
},
{
"block": "minecraft:moss_block"
}
],
"slopeCondition": {
"maximumSlope": 4
}
},
{
"minHeight": 1,
"maxHeight": 3,
"palette": [
{
"block": "minecraft:dirt"
},
{
"block": "minecraft:rooted_dirt"
},
{
"block": "minecraft:coarse_dirt"
}
]
},
{
"minHeight": 3,
"maxHeight": 6,
"palette": [
{
"block": "minecraft:mossy_cobblestone"
},
{
"block": "minecraft:cobblestone"
},
{
"block": "minecraft:stone"
}
]
},
{
"minHeight": 6,
"maxHeight": 18,
"palette": [
{
"block": "minecraft:stone"
},
{
"block": "minecraft:andesite"
},
{
"block": "minecraft:deepslate"
},
{
"block": "minecraft:cobblestone"
}
]
}
],
"objects": [
{
"place": [
"trees/oak/antioch1",
"trees/oak/antioch2",
"trees/oak/antioch4",
"trees/oak/antioch5",
"trees/oak/antioch6",
"trees/oak/antioch7",
"trees/oak/antioch8",
"trees/oak/antioch9",
"trees/oak/antioch10",
"trees/oak/antioch11",
"trees/oak/antioch12",
"trees/oak/antioch13"
],
"carvingSupport": "SURFACE_ONLY",
"chance": 0.5,
"mode": "CENTER_STILT",
"stiltSettings": {
"yMax": 4,
"yRand": 1
},
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
}
],
"decorators": [
{
"chance": 0.2,
"palette": [
{
"block": "minecraft:dandelion"
},
{
"block": "minecraft:poppy"
},
{
"block": "minecraft:blue_orchid"
},
{
"block": "minecraft:allium"
},
{
"block": "minecraft:azure_bluet"
},
{
"block": "minecraft:cornflower"
},
{
"block": "minecraft:lily_of_the_valley"
}
]
},
{
"chance": 0.75,
"palette": [
{
"block": "minecraft:short_grass"
}
]
}
],
"mergeFloatingChildBiomes": true,
"floatingChildBiomes": [
{
"biome": "mushroom/forest",
"rarity": 1,
"footprintStyle": {
"style": "GLOB_IRIS_THICK",
"zoom": 0.76,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.16,
"multiplier": 5
}
},
"footprintThreshold": 0.47,
"pickerStyle": {
"style": "SIMPLEX",
"zoom": 4.0
},
"altitudeStyle": {
"style": "SIMPLEX",
"zoom": 2.7
},
"minHeightAboveSurface": 115,
"maxHeightAboveSurface": 155,
"topShapeMode": "NOISE",
"maxTopHeight": 17,
"topShapeStyle": {
"style": "PERLIN_IRIS_THICK",
"zoom": 0.55,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.18,
"multiplier": 6
}
},
"topShapeAmp": 0.75,
"edgeTaperWidth": 14,
"edgeTaperExponent": 1.4,
"edgeTaperVariationStyle": {
"style": "SIMPLEX",
"zoom": 0.18
},
"edgeTaperVariationAmplitude": 4,
"bottomStyle": {
"style": "SIMPLEX_VASCULAR",
"zoom": 0.3,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.13,
"multiplier": 5
}
},
"bottomDepthMin": 6,
"bottomDepthMax": 46,
"bottomExponent": 2.2,
"bottomPaletteMode": "CUSTOM",
"bottomPalette": [
{
"minHeight": 18,
"maxHeight": 18,
"palette": [
{
"block": "minecraft:andesite"
}
]
}
],
"maxThickness": 72,
"wallWarpStyle": {
"style": "SIMPLEX",
"zoom": 0.25,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.12,
"multiplier": 3
}
},
"wallWarpAmplitude": 5,
"carving": "carving/mushroom",
"carveStyle": {
"style": "SIMPLEX",
"zoom": 0.22,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.14,
"multiplier": 3
}
},
"carveThreshold": 0.84,
"inheritDecorators": true,
"inheritObjects": true,
"objectShrinkFactor": 0.5,
"topObjectMode": "MERGE",
"topObjectOverrides": [
{
"place": [
"trees/mushroom/mushclut1",
"trees/mushroom/mushclut2",
"trees/mushroom/mushclut3",
"trees/mushroom/mushclut4",
"trees/mushroom/mushclut5",
"trees/mushroom/mushclut6",
"trees/mushroom/mushclut7",
"trees/mushroom/mushclut8",
"trees/mushroom/mushclut9",
"trees/mushroom/mushclut10"
],
"chance": 0.82,
"mode": "CENTER_HEIGHT",
"density": 7,
"scale": {
"size": 0.85
},
"warp": {
"style": "SIMPLEX",
"zoom": 0.28,
"multiplier": 1.1
},
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
},
{
"place": [
"trees/mushroom/browngeneric1",
"trees/mushroom/browngeneric2",
"trees/mushroom/redgeneric3",
"trees/mushroom/redgeneric4",
"trees/mushroom/redgeneric5",
"trees/mushroom/redgeneric6",
"trees/mushroom/redgeneric7",
"trees/mushroom/redgeneric8",
"trees/mushroom/redgeneric9",
"trees/mushroom/redgeneric10",
"trees/mushroom/redgeneric11",
"trees/mushroom/redlumotall1",
"trees/mushroom/redlumotall2",
"trees/mushroom/redlumotall3",
"trees/mushroom/redlumotall4",
"trees/mushroom/redlumotall5"
],
"chance": 0.62,
"mode": "CENTER_STILT",
"density": 5,
"scale": {
"size": 0.8
},
"warp": {
"style": "SIMPLEX_VASCULAR",
"zoom": 0.32,
"multiplier": 1.0
},
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
},
{
"place": [
"trees/mushroom/smolshroom1",
"trees/mushroom/smolshroom2",
"trees/mushroom/smolshroom3",
"trees/mushroom/smolshroom4",
"trees/mushroom/smolshroom5"
],
"chance": 0.85,
"mode": "CENTER_HEIGHT",
"density": 8,
"scale": {
"size": 0.9
},
"warp": {
"style": "SIMPLEX",
"zoom": 0.2,
"multiplier": 0.7
},
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
}
],
"bottomObjectMode": "REPLACE",
"bottomObjectOverrides": [
{
"place": [
"trees/mushroom/mushclut1",
"trees/mushroom/mushclut2",
"trees/mushroom/mushclut3",
"trees/mushroom/mushclut4",
"trees/mushroom/mushclut5",
"trees/mushroom/mushclut6",
"trees/mushroom/mushclut7",
"trees/mushroom/mushclut8",
"trees/mushroom/mushclut9",
"trees/mushroom/mushclut10",
"trees/mushroom/smolshroom1",
"trees/mushroom/smolshroom2",
"trees/mushroom/smolshroom3",
"trees/mushroom/smolshroom4",
"trees/mushroom/smolshroom5"
],
"chance": 0.5,
"mode": "FAST_MIN_HEIGHT",
"density": 5,
"scale": {
"size": 0.7
},
"warp": {
"style": "SIMPLEX",
"zoom": 0.25,
"multiplier": 0.8
},
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
}
]
},
{
"biome": "tropical/wilds",
"rarity": 1,
"footprintStyle": {
"style": "GLOB_IRIS_DOUBLE",
"zoom": 0.72,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.24,
"multiplier": 4
}
},
"footprintThreshold": 0.5,
"pickerStyle": {
"style": "SIMPLEX",
"zoom": 4.0
},
"altitudeStyle": {
"style": "SIMPLEX",
"zoom": 2.3
},
"minHeightAboveSurface": 75,
"maxHeightAboveSurface": 115,
"topShapeMode": "NOISE",
"maxTopHeight": 18,
"topShapeStyle": {
"style": "FRACTAL_WATER",
"zoom": 0.38,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.18,
"multiplier": 4
}
},
"topShapeAmp": 0.7,
"edgeTaperWidth": 15,
"edgeTaperExponent": 1.35,
"edgeTaperVariationStyle": {
"style": "SIMPLEX",
"zoom": 0.2
},
"edgeTaperVariationAmplitude": 4,
"bottomStyle": {
"style": "SIMPLEX_VASCULAR",
"zoom": 0.32,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.14,
"multiplier": 5
}
},
"bottomDepthMin": 6,
"bottomDepthMax": 44,
"bottomExponent": 2.15,
"maxThickness": 72,
"wallWarpStyle": {
"style": "SIMPLEX",
"zoom": 0.26,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.13,
"multiplier": 3
}
},
"wallWarpAmplitude": 5,
"carving": "carving/lush-child",
"carveStyle": {
"style": "SIMPLEX",
"zoom": 0.22,
"fracture": {
"style": "SIMPLEX",
"zoom": 0.14,
"multiplier": 3
}
},
"carveThreshold": 0.86,
"inheritDecorators": true,
"inheritObjects": true,
"objectShrinkFactor": 0.5,
"topObjectMode": "MERGE",
"topObjectOverrides": [
{
"place": [
"clutter/shrub4",
"clutter/shrub5",
"clutter/shrub6",
"clutter/oakshrub1",
"clutter/oakshrub2",
"clutter/oakshrub3"
],
"chance": 0.75,
"mode": "CENTER_HEIGHT",
"density": 8
},
{
"place": [
"trees/oak/antioch7",
"trees/oak/antioch8",
"trees/oak/antioch9",
"trees/oak/antioch10",
"trees/oak/antioch11",
"trees/oak/antioch12"
],
"chance": 0.5,
"mode": "CENTER_STILT",
"density": 5,
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
}
],
"bottomObjectMode": "INHERIT_ONLY",
"bottomObjectOverrides": [
{
"place": [
"trees/oak/antioch7",
"trees/oak/antioch8",
"trees/oak/antioch9",
"trees/oak/antioch10",
"clutter/boulder1",
"clutter/boulder2",
"clutter/boulder3"
],
"chance": 0.5,
"mode": "FAST_MIN_HEIGHT",
"density": 6,
"rotation": {
"yAxis": {
"min": 0,
"max": 270,
"interval": 90,
"enabled": true
},
"enabled": true
}
}
]
}
]
}
@@ -0,0 +1,107 @@
{
"name": "Forests",
"color": "#9BEE61",
"rarity": 1,
"landBiomes": [
"tundra/forest",
"tundra/autumn",
"mountain/plains",
"temperate/reaching-forest-violet",
"temperate/flower-forest",
"temperate/birch-tall",
"temperate/osaka-red-forest",
"mountain/mountain",
"temperate/combo-forest",
"tundra/redwood-forest",
"vanilla/old_growth_birch_forest",
"vanilla/old_growth_pine_taiga",
"vanilla/windswept_forest"
],
"caveBiomes": [
"carving/rocky-cavebiome",
"carving/lush",
"carving/mountain-caves",
"carving/moss-pillars"
],
"shoreBiomes": [
"temperate/shore/beach",
"temperate/shore/oak-beach"
],
"seaBiomeZoom": 6,
"seaBiomes": [
"ocean/deep",
"ocean/dark-depth-ocean",
"ocean/rich-oceans"
],
"shoreBiomeZoom": 0.15,
"landBiomeZoom": 3.5,
"shoreHeightMin": 1,
"shoreHeightMax": 5.2,
"shoreHeightZoom": 1.14,
"loot": {
"mode": "FALLBACK",
"multiplier": 0.5,
"tables": [
"temperate/clutter",
"temperate/food"
]
},
"caveProfile": {
"enabled": true,
"verticalRange": {
"min": 6,
"max": 120
},
"baseDensityStyle": {
"style": "PERLIN",
"zoom": 0.55
},
"detailDensityStyle": {
"style": "SIMPLEX",
"zoom": 0.5
},
"warpStyle": {
"style": "SIMPLEX",
"zoom": 0.5
},
"baseWeight": 1,
"detailWeight": 0,
"warpStrength": 0,
"densityThreshold": {
"min": -0.14,
"max": -0.06,
"style": {
"style": "SIMPLEX",
"zoom": 0.5
}
},
"thresholdBias": 0.06,
"sampleStep": 3,
"surfaceClearance": 12,
"allowSurfaceBreak": false,
"surfaceBreakStyle": {
"style": "SIMPLEX",
"zoom": 0.88
},
"surfaceBreakNoiseThreshold": 0.99,
"surfaceBreakDepth": 4,
"surfaceBreakThresholdBoost": 0.02,
"objectMinDepthBelowSurface": 14,
"defaultObjectAnchor": "FLOOR",
"defaultObjectPlaceMode": "ORGANIC_STILT",
"anchorScanStep": 1,
"anchorSearchAttempts": 12,
"allowFluid": true,
"fluidMinDepthBelowSurface": 20,
"fluidRequiresFloor": true,
"allowLava": true,
"modules": []
},
"caveBiomeZoom": 3.3,
"entitySpawners": [
"temperate/cave",
"temperate/hostile",
"temperate/passive",
"temperate/water"
]
}
@@ -0,0 +1,5 @@
{
"enabled": true,
"verticalRange": {"min": 10, "max": 100},
"sampleStep": 2
}