Drop Iris's compatibility seeds, reserved stage flags and noise fallbacks

- Iris answers every purpose seed by the API's rule; IrisWorldSeeds and
  its legacy map are gone.
- Every mantle stage gets an assigned flag; disabledComponents names
  stages by id, and a name that matches no stage fails the world.
- An unknown noise style or a missing expression throws.
This commit is contained in:
piexel committed 2026-11-06 07:31:11 +01:00
1 parent 6e1a206013
commit 949157fd26
15 files changed
+122 -260

No files matched your search

@@ -18,17 +18,13 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.spi.IrisLogging;
import com.volmit.host.ResolvedStage;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* The names in a dimension's {@code disabledComponents}: the flag of one of Iris's own mantle stages
* ({@code CARVED}) or the id of any mantle stage ({@code example:moss/veins}).
*/
/** The names in a dimension's {@code disabledComponents}: ids of mantle stages, such as {@code iris:carve/caves}. */
final class DisabledComponents {
private final Set<String> names;
@@ -37,23 +33,23 @@ final class DisabledComponents {
}
boolean disables(ResolvedStage stage) {
return names.stream().anyMatch(name -> isNamed(stage, name));
return names.contains(stage.stage().id().toString());
}
/** The names that match none of {@code stages}, sorted. */
List<String> unknown(List<ResolvedStage> stages) {
return names.stream().filter(name -> stages.stream().noneMatch(stage -> isNamed(stage, name))).sorted().toList();
List<String> stageIds = MantleStageFlags.stageIds(stages);
return names.stream().filter(name -> !stageIds.contains(name)).sorted().toList();
}
void warnAboutUnknown(List<ResolvedStage> stages) {
for (String name : unknown(stages)) {
IrisLogging.warn("disabledComponents names \"%s\", which is neither a mantle flag of Iris (%s) nor the id of a mantle stage of the pack; ignored.",
name, MantleStageFlags.builtIn());
/** Fails when a name matches no mantle stage of the pack, listing the ids it could name. */
void requireKnown(List<ResolvedStage> stages) {
List<String> unknown = unknown(stages);
if (unknown.isEmpty()) {
return;
}
}
private static boolean isNamed(ResolvedStage stage, String name) {
return stage.stage().id().toString().equals(name)
|| MantleStageFlags.builtInFlag(stage.stage().id()).filter(flag -> flag.name().equals(name)).isPresent();
throw new IllegalArgumentException("disabledComponents names " + unknown + ", which "
+ (unknown.size() == 1 ? "is not the id" : "are not ids") + " of mantle stages of the pack: "
+ MantleStageFlags.stageIds(stages));
}
}
@@ -26,7 +26,6 @@ import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.host.WorldStates;
import com.volmit.placement.Placements;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import com.volmit.world.RunningWorld;
import java.util.Optional;
@@ -75,10 +74,6 @@ public final class IrisPackWorld implements PackWorld {
return engine.getSeedManager().getSeed();
}
@Override
public long seed(ResourceId purpose) {
return IrisWorldSeeds.seed(engine.getSeedManager(), purpose);
}
@Override
public IrisPackResources resources() {
@@ -35,6 +35,7 @@ import com.volmit.config.Range;
import com.volmit.noise.StyledRange;
import com.volmit.geometry.BlockPosition;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import java.util.Map;
import java.util.Optional;
@@ -95,16 +96,17 @@ public final class IrisValues {
}
/**
* {@code style} as the generator style Iris builds noise from; a style name Iris does not know is flat. For behaviour that
* reads Iris's generator itself, such as the cave carvers' signed 3D reads, which {@code PackResources.noise()} does not offer.
* The expression and image map ids become the pack keys of {@code resources} that have them.
* {@code style} as the generator style Iris builds noise from. For behaviour that reads Iris's generator itself, such as
* the cave carvers' signed 3D reads, which {@code PackResources.noise()} does not offer. The expression and image map
* ids become the pack keys of {@code resources} that have them. A style name Iris does not know, or an expression the
* pack does not have, throws {@link IllegalArgumentException}.
*/
public static IrisGeneratorStyle generatorStyle(com.volmit.noise.NoiseStyle style, IrisPackResources resources) {
IrisGeneratorStyle iris = new IrisGeneratorStyle(irisStyle(style.style()));
iris.setCellularFrequency(style.cellularFrequency());
iris.setCellularZoom(style.cellularZoom());
iris.setZoom(style.zoom());
iris.setExpression(style.expression().map(id -> resources.keyOf(PackResources.EXPRESSIONS, id)).orElse(null));
iris.setExpression(style.expression().map(id -> expressionKey(id, resources)).orElse(null));
iris.setImageMap(style.imageMap().map(id -> resources.keyOf(PackResources.IMAGE_MAPS, id)).orElse(null));
iris.setMultiplier(style.multiplier());
iris.setFracture(style.fracture().map(fracture -> generatorStyle(fracture, resources)).orElse(null));
@@ -148,7 +150,14 @@ public final class IrisValues {
try {
return NoiseStyle.valueOf(name);
} catch (IllegalArgumentException unknown) {
return NoiseStyle.FLAT;
throw new IllegalArgumentException("Iris has no noise style \"" + name + "\"", unknown);
}
}
private static String expressionKey(ResourceId id, IrisPackResources resources) {
if (!resources.ids(PackResources.EXPRESSIONS).contains(id)) {
throw new IllegalArgumentException("The pack has no expression " + id);
}
return resources.keyOf(PackResources.EXPRESSIONS, id);
}
}
@@ -1,39 +0,0 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeedPurposes;
import art.arcane.iris.engine.framework.SeedManager;
import com.volmit.random.WorldRandom;
import com.volmit.resource.ResourceId;
import java.util.Map;
import java.util.function.ToLongFunction;
/**
* How Iris answers {@link com.volmit.world.PackWorld#seed(ResourceId)}: the built-in modules' {@link IrisSeedPurposes}
* get the seeds Iris's worlds always used for those features, every other purpose the API's rule.
*/
final class IrisWorldSeeds {
/** Object placements warped their surface with the component seed moved by this much. */
private static final long OBJECT_WARP_OFFSET = 1024L;
private static final Map<ResourceId, ToLongFunction<SeedManager>> LEGACY_SEEDS = Map.ofEntries(
Map.entry(IrisSeedPurposes.BIOME, SeedManager::getBiome),
Map.entry(IrisSeedPurposes.CARVE, SeedManager::getCarve),
Map.entry(IrisSeedPurposes.COMPLEX, SeedManager::getComplex),
Map.entry(IrisSeedPurposes.COMPONENT, SeedManager::getComponent),
Map.entry(IrisSeedPurposes.DECORATOR, SeedManager::getDecorator),
Map.entry(IrisSeedPurposes.DEPOSIT, SeedManager::getDeposit),
Map.entry(IrisSeedPurposes.ENTITY, SeedManager::getEntity),
Map.entry(IrisSeedPurposes.LOOT, SeedManager::getLoot),
Map.entry(IrisSeedPurposes.MANTLE, SeedManager::getMantle),
Map.entry(IrisSeedPurposes.OBJECT_WARP, seeds -> seeds.getComponent() + OBJECT_WARP_OFFSET),
Map.entry(IrisSeedPurposes.POST, SeedManager::getPost),
Map.entry(IrisSeedPurposes.TERRAIN, SeedManager::getTerrain));
private IrisWorldSeeds() {
}
static long seed(SeedManager seeds, ResourceId purpose) {
ToLongFunction<SeedManager> legacy = LEGACY_SEEDS.get(purpose);
return legacy != null ? legacy.applyAsLong(seeds) : WorldRandom.purposeSeed(seeds.getSeed(), purpose);
}
}
@@ -18,45 +18,25 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
import com.volmit.host.ResolvedStage;
import com.volmit.resource.ResourceId;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* The mantle flag of each mantle stage: it marks a mantle chunk whose stage has run, and names the stage in a
* dimension's {@code disabledComponents} when it is one of Iris's own. Iris's own mantle stages keep the flags
* their mantle components had, so packs that disable {@code CARVED} keep doing so and existing worlds stay
* marked. Every other stage gets a custom flag in resolved order, so adding or removing a pack mantle stage can
* renumber the stages after it; those flags stay internal and a dimension names such a stage by its id.
* The mantle flag of each mantle stage, which marks a mantle chunk whose stage has run. Every stage gets a custom
* flag in resolved order, so adding or removing a mantle stage can renumber the stages after it. The flags stay
* internal: a dimension names a stage in {@code disabledComponents} by its id.
*/
public final class MantleStageFlags {
private static final List<BuiltIn> BUILT_IN = List.of(
new BuiltIn(IrisStages.Carve.CAVES.id(), ReservedFlag.CARVED),
new BuiltIn(IrisStages.Objects.PLACE.id(), ReservedFlag.OBJECT),
new BuiltIn(IrisStages.Floating.OBJECTS.id(), ReservedFlag.FLOATING_OBJECT),
new BuiltIn(IrisStages.Structure.PLACE.id(), ReservedFlag.JIGSAW));
private MantleStageFlags() {
}
/** The flags of Iris's own mantle stages, in their order, which a dimension can list in {@code disabledComponents}. */
public static List<MantleFlag> builtIn() {
return BUILT_IN.stream().map(BuiltIn::flag).toList();
}
/** The ids of the mantle stages that have no flag of their own, which a dimension names by id in {@code disabledComponents}. */
public static List<String> packStageIds(List<ResolvedStage> stages) {
return stages.stream()
.map(stage -> stage.stage().id())
.filter(id -> builtInFlag(id).isEmpty())
.map(ResourceId::toString)
.toList();
/** The ids of {@code stages}, which a dimension names in {@code disabledComponents}. */
public static List<String> stageIds(List<ResolvedStage> stages) {
return stages.stream().map(stage -> stage.stage().id()).map(ResourceId::toString).toList();
}
/** One flag per stage, in the order of {@code stages}. */
@@ -64,11 +44,6 @@ public final class MantleStageFlags {
List<MantleFlag> flags = new ArrayList<>(stages.size());
int nextCustom = MantleFlag.MIN_ORDINAL;
for (ResolvedStage stage : stages) {
Optional<MantleFlag> builtIn = builtInFlag(stage.stage().id());
if (builtIn.isPresent()) {
flags.add(builtIn.get());
continue;
}
if (nextCustom > MantleFlag.MAX_ORDINAL) {
throw new IllegalStateException("The pack has more mantle stages than Iris has mantle flags for; stage "
+ stage.stage().id() + " of module " + stage.module() + " is one too many");
@@ -77,11 +52,4 @@ public final class MantleStageFlags {
}
return List.copyOf(flags);
}
static Optional<MantleFlag> builtInFlag(ResourceId stage) {
return BUILT_IN.stream().filter(builtIn -> builtIn.stage().equals(stage)).map(BuiltIn::flag).findFirst();
}
private record BuiltIn(ResourceId stage, MantleFlag flag) {
}
}
@@ -62,7 +62,7 @@ public final class ModuleMantleComponent implements MantleComponent {
/**
* One component per mantle stage of the engine's pack, in resolved order, each its own pass. A stage named in
* {@code disabledComponents} is turned off; a name that matches no stage is warned about.
* {@code disabledComponents} is turned off; a name that matches no stage fails.
*/
public static List<ModuleMantleComponent> forPack(Engine engine, Collection<String> disabledComponents) {
return forPack(engine, engine.getData().getModules().pack(), disabledComponents);
@@ -71,7 +71,7 @@ public final class ModuleMantleComponent implements MantleComponent {
static List<ModuleMantleComponent> forPack(Engine engine, LoadedPack pack, Collection<String> disabledComponents) {
ResolvedGraph graph = pack.mantle();
DisabledComponents disabled = new DisabledComponents(disabledComponents);
disabled.warnAboutUnknown(graph.stages());
disabled.requireKnown(graph.stages());
MantleRunner runner = new MantleRunner(graph);
IrisPackSettings settings = new IrisPackSettings(engine);
List<MantleFlag> flags = MantleStageFlags.assign(graph.stages());
@@ -25,7 +25,6 @@ import com.volmit.config.PackSettings;
import com.volmit.host.WorldStates;
import com.volmit.placement.Placements;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import com.volmit.world.RunningWorld;
@@ -63,10 +62,6 @@ final class ToolWorld implements PackWorld, AutoCloseable {
return seeds.getSeed();
}
@Override
public long seed(ResourceId purpose) {
return IrisWorldSeeds.seed(seeds, purpose);
}
@Override
public PackResources resources() {
@@ -4,11 +4,10 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.MantleStageFlags;
import art.arcane.iris.engine.framework.ListFunction;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
/**
* What studio offers for a dimension's {@code disabledComponents}: the flags of Iris's own mantle stages, such as
* {@code CARVED} for caves, then the ids of the pack's mantle stages.
* What studio offers for a dimension's {@code disabledComponents}: the ids of the pack's mantle stages, such as
* {@code iris:carve/caves}.
*/
public class ComponentFlagFunction implements ListFunction<KList<String>> {
@Override
@@ -23,8 +22,6 @@ public class ComponentFlagFunction implements ListFunction<KList<String>> {
@Override
public KList<String> apply(IrisData data) {
KList<String> names = MantleStageFlags.builtIn().stream().map(MantleFlag::toString).collect(KList.collector());
names.addAll(MantleStageFlags.packStageIds(data.getModules().pack().mantle().stages()));
return names;
return new KList<>(MantleStageFlags.stageIds(data.getModules().pack().mantle().stages()));
}
}
@@ -213,7 +213,7 @@ public class IrisDimension extends IrisRegistrant {
private KList<String> datapackImports = new KList<>();
@RegistryListFunction(ComponentFlagFunction.class)
@ArrayType(type = String.class)
@Desc("Mantle passes to skip in this dimension: CARVED (caves), OBJECT (objects), FLOATING_OBJECT (objects on floating islands) or JIGSAW (structures), or the id of a pack module's mantle stage, such as example:moss/veins. A name that matches nothing is warned about and ignored.")
@Desc("Mantle passes to skip in this dimension, by the id of their mantle stage, such as iris:carve/caves (caves), iris:objects/place (objects), iris:floating/objects (objects on floating islands), iris:structure/place (structures) or a pack module's example:moss/veins. A name that matches no stage fails the world.")
private KList<String> disabledComponents = new KList<>();
public int getMaxHeight() {