diff --git a/README.md b/README.md index 1cf202039..2727a6778 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ only: `DepositSettings` holds `DepositGenerator`s (blocks as `BlockSpec`, its en `art.arcane.iris.builtin.deposit`), and packs write `"deposits": [...]`, as they always have (`@Feature(key = "deposits", root = "generators")`: the key holds the one option's list). What needs Iris (resolving the palette, ore checks, clump shapes per world seed) lives in the module's own code, `ResolvedDeposit`. -Settings that live inside a class of Iris's own, such as an object placement's clamp, stilt, vacuum and edit settings, its slope condition, -a cave profile, a floating child biome or a procedural coral, are module-owned classes too (`art.arcane.iris.builtin.validate`, +Settings that live inside a class of Iris's own, such as an object placement's clamp, stilt, vacuum and edit settings, its slope condition +or a procedural coral, are module-owned classes too (`art.arcane.iris.builtin.validate`, `.stilt`, `.vacuum`, `.blocks`, `.prepare`, `.carve`, `.floating`, `.objects.*`). The module registers each with `registry.registerHeldType(...)` so studio describes it from the module's own annotations; packs write the same JSON as before. Behaviour that needs Iris (noise built from the styles, blocks resolved through the pack, baked object variants) lives in `Resolved*` classes beside the @@ -73,6 +73,18 @@ for a pack, `BiomeLayers`, the world's state, keeps them and stacks a biome's la rock and fluid as a block for every column; the terrain, cave, floating and post stages ask them. The slope limit of a layer, a decorator and an object placement is the one `SlopeClip`. +Caves, floating islands and ores are settings of their modules too, written under the keys they always had. `iris:carve` owns +`caveProfile` (dimension, region, biome; an object, or a `snippet/cave-profile/...` reference), `carving` (dimension; a list of bands) and +`carvingEnabled` (dimension; a boolean), `carvingBiome` (biome; a biome key) and `caveMinDepthBelowSurface` (biome; a number). `iris:floating` +owns `floatingChildBiomes` (biome; a list) and `mergeFloatingChildBiomes` (biome; a boolean). `iris:terrain` owns `ores` (dimension, region, +biome; a list of generators) and `hideOresForHiddenOre` (dimension; a boolean); `iris:deposit` owns `depositVariants` (dimension, region, biome; a list) +and `oreDepositFrequencyMultiplier` and `oreDepositSizeMultiplier` (biome; numbers). Behaviour that needs Iris lives in the `Resolved*` classes beside the +workers: `ResolvedOre`/`ResolvedOres` (blocks and chance noise per world, `TerrainOres` the world's state), `ResolvedDepositVariant`, +`ResolvedCarvingEntry`/`CarvingBands`/`CarvingResolver` (the band for a position) and `ResolvedFloatingChild`. The settings that name biomes +(`carvingBiome`, a band's biome, a floating child's target and carving) implement `LinkedBiomes`, which is how Iris's biome tree and the biomes a +dimension reaches learn of them without reading the settings classes; and `iris:carve` provides the `CaveBiomes` service +(`CaveBiomeBands`), which Iris asks for the dimension's carving band at a position and for a biome's minimum cave depth. + Packs write each settings feature under the short key it declares: `deposits` (dimension, region, biome; a list), `decorators` (biome; a list) and `importedStructures` (dimension; an object of `disabled`, `adjustments` and the rest). The feature ids (`iris:deposit`, `iris:decorant`, `iris:structure`) stay the modules' identity in the stage graph and logs. A key is unique diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java b/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java new file mode 100644 index 000000000..e2942aecb --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java @@ -0,0 +1,54 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.carve; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.LinkedBiomes; +import com.volmit.config.Ref; +import com.volmit.config.Reference; + +import java.util.Set; + +/** A biome's {@code carvingBiome}, written as the biome key: it registers that biome with the pack's layout and is not applied as a substitute under carvings. */ +@Desc("Registers the referenced biome with this pack's reachable biome set. It is NOT applied as a substitute under carvings; cave biomes come from the region's caveBiomes list.") +@Feature(id = "iris:carve/biome", name = "Carving biome", key = "carvingBiome", root = "biome", targets = Target.BIOME) +public final class CarvingBiomeSettings implements IrisFeature, LinkedBiomes { + @Ref(Reference.PACK_BIOME) + @Desc("Registers the referenced biome with this pack's reachable biome set. It is NOT applied as a substitute under carvings; cave biomes come from the region's caveBiomes list.") + private String biome = ""; + + public CarvingBiomeSettings() { + } + + public CarvingBiomeSettings(String biome) { + this.biome = biome; + } + + public String biome() { + return biome == null ? "" : biome; + } + + @Override + public Set treeBiomes() { + return Set.of(biome()); + } +} diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarvingEnabledSettings.java b/src/main/java/art/arcane/iris/builtin/carve/CarvingEnabledSettings.java new file mode 100644 index 000000000..d09f7e7ac --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/carve/CarvingEnabledSettings.java @@ -0,0 +1,43 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.carve; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; + +/** A dimension's {@code carvingEnabled}, written as the bare boolean. */ +@Desc("Enable or disable all carving for this dimension") +@Feature(id = "iris:carve/enabled", name = "Carving enabled", key = "carvingEnabled", root = "enabled", targets = Target.DIMENSION) +public final class CarvingEnabledSettings implements IrisFeature { + @Desc("Enable or disable all carving for this dimension") + private boolean enabled = true; + + public CarvingEnabledSettings() { + } + + public CarvingEnabledSettings(boolean enabled) { + this.enabled = enabled; + } + + public boolean enabled() { + return enabled; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarvingEntry.java b/src/main/java/art/arcane/iris/builtin/carve/CarvingEntry.java new file mode 100644 index 000000000..7508832a7 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/carve/CarvingEntry.java @@ -0,0 +1,103 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.carve; + +import com.volmit.config.Desc; +import com.volmit.config.Range; +import com.volmit.config.Ref; +import com.volmit.config.Reference; +import com.volmit.config.Snippet; +import com.volmit.noise.NoiseStyle; + +import java.util.Collections; +import java.util.List; + +/** + * One dimension-level cave biome override, an entry of {@code carving}: a pack biome that replaces the cave biome within a band + * of world Y, optionally split into child entries by a noise pattern. IrisApi types only; {@code CarvingResolver} picks + * the entry for a position. + */ +@Snippet("dimension-carving-entry") +@Desc("Dimension-level cave biome override with absolute world Y bounds.") +public final class CarvingEntry { + private static final double DEFAULT_WORLD_Y_MIN = -64; + private static final double DEFAULT_WORLD_Y_MAX = 320; + private static final double DEFAULT_CHILD_SHRINK_FACTOR = 1.5; + private static final int DEFAULT_CHILD_RECURSION_DEPTH = 3; + + @Desc("Stable id for this carving entry") + private String id = ""; + + @Desc("Enable or disable this carving entry") + private boolean enabled = true; + + @Ref(Reference.PACK_BIOME) + @Desc("Cave biome to apply when world Y falls within worldYRange") + private String biome = ""; + + @Desc("Absolute world Y bounds where this carving entry applies") + private Range worldYRange = Range.of(DEFAULT_WORLD_Y_MIN, DEFAULT_WORLD_Y_MAX); + + @Desc("If this carving entry has child carving entries, this controls how small those child carving patches are.") + private double childShrinkFactor = DEFAULT_CHILD_SHRINK_FACTOR; + + @Desc("If this carving entry has child carving entries, this controls the shape pattern used to pick them.") + private NoiseStyle childStyle = NoiseStyle.of("CELLULAR_IRIS_DOUBLE"); + + @Desc("Child carving entry ids. Child ids can point back to parent ids to create cycles; recursion is bounded by childRecursionDepth.") + private List children = List.of(); + + @Desc("Maximum recursion depth when resolving child carving entries from this entry.") + private int childRecursionDepth = DEFAULT_CHILD_RECURSION_DEPTH; + + public CarvingEntry() { + } + + public String id() { + return id == null ? "" : id; + } + + public boolean enabled() { + return enabled; + } + + public String biome() { + return biome == null ? "" : biome; + } + + public Range worldYRange() { + return worldYRange; + } + + public double childShrinkFactor() { + return childShrinkFactor; + } + + public NoiseStyle childStyle() { + return childStyle; + } + + public List children() { + return children == null ? List.of() : Collections.unmodifiableList(children); + } + + public int childRecursionDepth() { + return childRecursionDepth; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java b/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java new file mode 100644 index 000000000..afd544963 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java @@ -0,0 +1,80 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.carve; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.LinkedBiomes; +import com.volmit.config.MinItems; + +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +/** + * The cave biome overrides a dimension declares, written as {@code "carving": [...]}, the list of {@link CarvingEntry}s. + * The biome of every enabled entry takes part in the pack's layout like any biome the dimension reaches. + */ +@Desc("Dimension-level cave biome carving overrides with absolute world Y ranges") +@Feature(id = "iris:carve/bands", name = "Cave biome bands", key = "carving", root = "entries", targets = Target.DIMENSION) +public final class CarvingSettings implements IrisFeature, LinkedBiomes { + @MinItems(1) + @Desc("Dimension-level cave biome carving overrides with absolute world Y ranges") + private List entries = List.of(); + + public CarvingSettings() { + } + + public CarvingSettings(List entries) { + this.entries = List.copyOf(entries); + } + + public List entries() { + return entries == null ? List.of() : Collections.unmodifiableList(entries); + } + + /** + * The biome key {@code reference} stands for: the biome of the entry with that id, ignoring surrounding blanks, or + * {@code reference} itself when no entry has the id. When several entries share an id the last one counts. + */ + public String biomeOf(String reference) { + CarvingEntry entry = null; + for (CarvingEntry candidate : entries()) { + if (candidate != null && !candidate.id().isBlank() && candidate.id().trim().equals(reference)) { + entry = candidate; + } + } + return entry == null ? reference : entry.biome(); + } + + @Override + public Set usedBiomes(Collection dimension) { + Set biomes = new LinkedHashSet<>(); + for (CarvingEntry entry : entries()) { + if (entry != null && entry.enabled()) { + biomes.add(entry.biome()); + } + } + return biomes; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/carve/CaveDepthSettings.java b/src/main/java/art/arcane/iris/builtin/carve/CaveDepthSettings.java new file mode 100644 index 000000000..08f005403 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/carve/CaveDepthSettings.java @@ -0,0 +1,47 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.carve; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; + +/** A biome's {@code caveMinDepthBelowSurface}, written as the bare number of blocks. */ +@Desc("Minimum depth below terrain surface required before this cave biome can be selected.") +@Feature(id = "iris:carve/min-depth", name = "Cave minimum depth", key = "caveMinDepthBelowSurface", root = "depth", targets = Target.BIOME) +public final class CaveDepthSettings implements IrisFeature { + @MinNumber(0) + @MaxNumber(256) + @Desc("Minimum depth below terrain surface required before this cave biome can be selected.") + private int depth = 0; + + public CaveDepthSettings() { + } + + public CaveDepthSettings(int depth) { + this.depth = depth; + } + + public int depth() { + return depth; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/carve/CaveProfile.java b/src/main/java/art/arcane/iris/builtin/carve/CaveProfile.java index 0884897b3..a64df4d67 100644 --- a/src/main/java/art/arcane/iris/builtin/carve/CaveProfile.java +++ b/src/main/java/art/arcane/iris/builtin/carve/CaveProfile.java @@ -19,7 +19,10 @@ package art.arcane.iris.builtin.carve; import art.arcane.iris.builtin.anchor.ObjectPlaceMode; +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; import com.volmit.config.Desc; +import com.volmit.config.Feature; import com.volmit.config.MaxNumber; import com.volmit.config.MinItems; import com.volmit.config.MinNumber; @@ -35,11 +38,13 @@ import java.util.Optional; /** * A 3D cave profile as packs write it for a dimension, region or biome ({@code caveProfile}) or under * {@code snippet/cave-profile/}: the noise fields that decide where caves are, how they meet the surface, where - * cave fluid may sit and how objects find anchors in them. IrisApi types only; the carving module builds the noise. + * cave fluid may sit and how objects find anchors in them. A level that writes none has no profile, which is the + * same as one that is not {@code enabled}. IrisApi types only; the carving module builds the noise. */ @Snippet("cave-profile") @Desc("Represents a configurable 3D cave profile.") -public final class CaveProfile { +@Feature(id = "iris:carve/profile", name = "Cave profile", key = "caveProfile", targets = {Target.DIMENSION, Target.REGION, Target.BIOME}) +public final class CaveProfile implements IrisFeature { @Desc("Enable profile-driven cave carving.") private boolean enabled = false; diff --git a/src/main/java/art/arcane/iris/builtin/deposit/DepositVariant.java b/src/main/java/art/arcane/iris/builtin/deposit/DepositVariant.java new file mode 100644 index 000000000..582301354 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/deposit/DepositVariant.java @@ -0,0 +1,67 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.deposit; + +import com.volmit.config.Desc; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; +import com.volmit.config.Required; +import com.volmit.config.Snippet; + +import java.util.Collections; +import java.util.Map; + +/** + * One deposit ore remap rule, an entry of {@code depositVariants}: within a vertical band, ore blocks are rewritten to + * alternate blocks. A value of IrisApi types only; {@code ResolvedDepositVariant} resolves the blocks. + */ +@Snippet("deposit-variant") +@Desc("Remaps ore block ids to alternate block ids within a vertical band. Ores declared at dimension, region, and biome scope can be rewritten at placement time (for example, iron_ore -> deepslate_iron_ore inside a deep carving band, or yourmod:iron -> yourmod:moon_iron inside a lunar biome).") +public final class DepositVariant { + @Required + @MinNumber(-2048) + @MaxNumber(8192) + @Desc("Inclusive minimum world Y this variant applies at.") + private int minHeight = 0; + + @Required + @MinNumber(-2048) + @MaxNumber(8192) + @Desc("Inclusive maximum world Y this variant applies at.") + private int maxHeight = 0; + + @Required + @Desc("Source block id (for example `minecraft:iron_ore`) -> replacement block id (for example `minecraft:deepslate_iron_ore`). Any block id the data loader resolves is accepted, including external/mod blocks. Source match is by material only, so block properties on the source key are ignored.") + private Map remap = Map.of(); + + public DepositVariant() { + } + + public int minHeight() { + return minHeight; + } + + public int maxHeight() { + return maxHeight; + } + + public Map remap() { + return remap == null ? Map.of() : Collections.unmodifiableMap(remap); + } +} diff --git a/src/main/java/art/arcane/iris/builtin/deposit/DepositVariantSettings.java b/src/main/java/art/arcane/iris/builtin/deposit/DepositVariantSettings.java new file mode 100644 index 000000000..e6a6d15ef --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/deposit/DepositVariantSettings.java @@ -0,0 +1,52 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.deposit; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.MinItems; + +import java.util.Collections; +import java.util.List; + +/** + * The deposit ore remap rules one dimension, region or biome declares, written as {@code "depositVariants": [...]}, the list + * of {@link DepositVariant}s. The biome's rules apply first, then the region's, then the dimension's; the first matching rule wins. + */ +@Desc("Deposit ore remap rules. Each entry declares a vertical band and a source->replacement block id map. Applied biome first, then region, then dimension; first matching rule wins.") +@Feature(id = "iris:deposit/variants", name = "Deposit variants", key = "depositVariants", root = "variants", + targets = {Target.DIMENSION, Target.REGION, Target.BIOME}) +public final class DepositVariantSettings implements IrisFeature { + @MinItems(1) + @Desc("Deposit ore remap rules. Each entry declares a vertical band and a source->replacement block id map. Applied biome first, then region, then dimension; first matching rule wins.") + private List variants = List.of(); + + public DepositVariantSettings() { + } + + public DepositVariantSettings(List variants) { + this.variants = List.copyOf(variants); + } + + public List variants() { + return variants == null ? List.of() : Collections.unmodifiableList(variants); + } +} diff --git a/src/main/java/art/arcane/iris/builtin/deposit/OreFrequencySettings.java b/src/main/java/art/arcane/iris/builtin/deposit/OreFrequencySettings.java new file mode 100644 index 000000000..e279b0df6 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/deposit/OreFrequencySettings.java @@ -0,0 +1,49 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.deposit; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; + +/** A biome's {@code oreDepositFrequencyMultiplier}, written as the bare number. */ +@Desc("Multiplier applied to the frequency of every ore deposit whose center is inside this biome. A value of 0.4 keeps 40% of ore veins while leaving non-ore deposits unchanged.") +@Feature(id = "iris:deposit/ore-frequency", name = "Ore deposit frequency", key = "oreDepositFrequencyMultiplier", root = "multiplier", targets = Target.BIOME) +public final class OreFrequencySettings implements IrisFeature { + private static final double UNCHANGED = 1D; + + @MinNumber(0) + @MaxNumber(1) + @Desc("Multiplier applied to the frequency of every ore deposit whose center is inside this biome. A value of 0.4 keeps 40% of ore veins while leaving non-ore deposits unchanged.") + private double multiplier = UNCHANGED; + + public OreFrequencySettings() { + } + + public OreFrequencySettings(double multiplier) { + this.multiplier = multiplier; + } + + public double multiplier() { + return multiplier; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/deposit/OreSizeSettings.java b/src/main/java/art/arcane/iris/builtin/deposit/OreSizeSettings.java new file mode 100644 index 000000000..80e1d5892 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/deposit/OreSizeSettings.java @@ -0,0 +1,49 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.deposit; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; + +/** A biome's {@code oreDepositSizeMultiplier}, written as the bare number. */ +@Desc("Multiplier applied to the block count of every ore deposit whose center is inside this biome. Non-ore deposits are unchanged.") +@Feature(id = "iris:deposit/ore-size", name = "Ore deposit size", key = "oreDepositSizeMultiplier", root = "multiplier", targets = Target.BIOME) +public final class OreSizeSettings implements IrisFeature { + private static final double UNCHANGED = 1D; + + @MinNumber(0.01) + @MaxNumber(16) + @Desc("Multiplier applied to the block count of every ore deposit whose center is inside this biome. Non-ore deposits are unchanged.") + private double multiplier = UNCHANGED; + + public OreSizeSettings() { + } + + public OreSizeSettings(double multiplier) { + this.multiplier = multiplier; + } + + public double multiplier() { + return multiplier; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java b/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java new file mode 100644 index 000000000..796b062f8 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java @@ -0,0 +1,70 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.floating; + +import art.arcane.iris.builtin.carve.CarvingSettings; +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.LinkedBiomes; +import com.volmit.config.MinItems; + +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +/** + * The floating child biomes one biome declares, written as {@code "floatingChildBiomes": [...]}, the list of + * {@link FloatingChildBiome}s. The target biome of every child, and the biome its {@code carving} names, take part in the + * pack's layout like any biome a dimension reaches. + */ +@Desc("Floating child biomes that procedurally generate above this biome's terrain. Each entry references a target biome whose layers, decorators, and objects drive the floating island's visual design, while the config here drives size, shape, altitude, rarity, and water level. Multiple entries are supported and selected by rarity per column unless mergeFloatingChildBiomes is enabled.") +@Feature(id = "iris:floating/children", name = "Floating child biomes", key = "floatingChildBiomes", root = "children", targets = Target.BIOME) +public final class FloatingChildSettings implements IrisFeature, LinkedBiomes { + @MinItems(1) + @Desc("Floating child biomes that procedurally generate above this biome's terrain. Each entry references a target biome whose layers, decorators, and objects drive the floating island's visual design, while the config here drives size, shape, altitude, rarity, and water level. Multiple entries are supported and selected by rarity per column unless mergeFloatingChildBiomes is enabled.") + private List children = List.of(); + + public FloatingChildSettings() { + } + + public FloatingChildSettings(List children) { + this.children = List.copyOf(children); + } + + public List children() { + return children == null ? List.of() : Collections.unmodifiableList(children); + } + + @Override + public Set usedBiomes(Collection dimension) { + CarvingSettings carving = dimension.stream().filter(CarvingSettings.class::isInstance).map(CarvingSettings.class::cast).findFirst().orElse(null); + Set biomes = new LinkedHashSet<>(); + for (FloatingChildBiome child : children()) { + if (child != null) { + biomes.add(child.biome()); + biomes.add(carving == null ? child.carving() : carving.biomeOf(child.carving())); + } + } + return biomes; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/floating/MergeFloatingChildrenSettings.java b/src/main/java/art/arcane/iris/builtin/floating/MergeFloatingChildrenSettings.java new file mode 100644 index 000000000..24224b836 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/floating/MergeFloatingChildrenSettings.java @@ -0,0 +1,43 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.floating; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; + +/** A biome's {@code mergeFloatingChildBiomes}, written as the bare boolean. */ +@Desc("When true, every floating child entry is sampled independently and their solid masks are unioned, so multiple floating islands can stack, overlap, and collide instead of the picker choosing only one child per column.") +@Feature(id = "iris:floating/merge", name = "Merge floating child biomes", key = "mergeFloatingChildBiomes", root = "merge", targets = Target.BIOME) +public final class MergeFloatingChildrenSettings implements IrisFeature { + @Desc("When true, every floating child entry is sampled independently and their solid masks are unioned, so multiple floating islands can stack, overlap, and collide instead of the picker choosing only one child per column.") + private boolean merge = false; + + public MergeFloatingChildrenSettings() { + } + + public MergeFloatingChildrenSettings(boolean merge) { + this.merge = merge; + } + + public boolean merge() { + return merge; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/terrain/HideOresSettings.java b/src/main/java/art/arcane/iris/builtin/terrain/HideOresSettings.java new file mode 100644 index 000000000..afebc3443 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/terrain/HideOresSettings.java @@ -0,0 +1,46 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.terrain; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; + +/** + * A dimension's {@code hideOresForHiddenOre}: whether every ore block the generator would place is replaced with its base + * material. Written as the bare boolean. + */ +@Desc("When true, every ore block the generator would place (terrain ores, deposits, ores inside objects) is replaced with its base material such as stone, deepslate or netherrack, so drop-control plugins like HiddenOre can manage ore rewards themselves") +@Feature(id = "iris:terrain/hide-ores", name = "Hide ores", key = "hideOresForHiddenOre", root = "hide", targets = Target.DIMENSION) +public final class HideOresSettings implements IrisFeature { + @Desc("When true, every ore block the generator would place (terrain ores, deposits, ores inside objects) is replaced with its base material such as stone, deepslate or netherrack, so drop-control plugins like HiddenOre can manage ore rewards themselves") + private boolean hide = false; + + public HideOresSettings() { + } + + public HideOresSettings(boolean hide) { + this.hide = hide; + } + + public boolean hide() { + return hide; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/terrain/OreGenerator.java b/src/main/java/art/arcane/iris/builtin/terrain/OreGenerator.java new file mode 100644 index 000000000..1f9cb8f47 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/terrain/OreGenerator.java @@ -0,0 +1,80 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.terrain; + +import com.volmit.block.PaletteSpec; +import com.volmit.config.Desc; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; +import com.volmit.config.Range; +import com.volmit.noise.NoiseStyle; + +import java.util.List; + +/** + * One ore generator of a dimension, region or biome, an entry of its {@code ores} list: single ore blocks scattered + * through the terrain by a noise field, in a vertical band. A value of IrisApi types only; the terrain module resolves + * its blocks and builds its noise ({@code ResolvedOre}). + */ +@Desc("Scatters single ore blocks through terrain by sampling a noise field at every block in a vertical band. Defined on dimensions, regions, or biomes; the most specific level wins.") +public final class OreGenerator { + private static final double DEFAULT_THRESHOLD = 0.5; + private static final double DEFAULT_RANGE_MIN = 30; + private static final double DEFAULT_RANGE_MAX = 80; + + @Desc("The ore blocks to place. An empty palette generates nothing, so this must be set for the generator to have any effect.") + private PaletteSpec palette = PaletteSpec.of(List.of()); + + @Desc("The noise style sampled per block to decide where ore appears. STATIC gives independent random speckle; smoother styles give veiny clusters.") + private NoiseStyle chanceStyle = NoiseStyle.of("STATIC"); + + @Desc("When true this generator also replaces surface-layer blocks (it runs before layers and fluid); when false it only replaces underground rock.") + private boolean generateSurface = false; + + @MinNumber(0) + @MaxNumber(1) + @Desc("Noise cutoff: a block becomes ore when the sampled noise is at or below this value, so higher means more ore. 0 disables, 1 replaces everything in range.") + private double threshold = DEFAULT_THRESHOLD; + + @Desc("Vertical band (min, max) this ore can generate in, in engine-local Y where 0 is the bottom of the dimension, not world Y.") + private Range range = Range.of(DEFAULT_RANGE_MIN, DEFAULT_RANGE_MAX); + + public OreGenerator() { + } + + public PaletteSpec palette() { + return palette; + } + + public NoiseStyle chanceStyle() { + return chanceStyle; + } + + public boolean generateSurface() { + return generateSurface; + } + + public double threshold() { + return threshold; + } + + public Range range() { + return range; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/terrain/OreSettings.java b/src/main/java/art/arcane/iris/builtin/terrain/OreSettings.java new file mode 100644 index 000000000..ae2d39553 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/terrain/OreSettings.java @@ -0,0 +1,52 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.terrain; + +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; +import com.volmit.config.MinItems; + +import java.util.Collections; +import java.util.List; + +/** + * The ore generators one dimension, region or biome declares, written as {@code "ores": [...]}, the list of generators. + * Levels stack: a column's ores come from its biome first, then its region, then the dimension. IrisApi types only, + * like {@link OreGenerator}. + */ +@Desc("Collection of ores to be generated") +@Feature(id = "iris:terrain/ores", name = "Ores", key = "ores", root = "generators", targets = {Target.DIMENSION, Target.REGION, Target.BIOME}) +public final class OreSettings implements IrisFeature { + @MinItems(1) + @Desc("Collection of ores to be generated") + private List generators = List.of(); + + public OreSettings() { + } + + public OreSettings(List generators) { + this.generators = List.copyOf(generators); + } + + public List generators() { + return generators == null ? List.of() : Collections.unmodifiableList(generators); + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/HiddenOres.java b/src/main/java/art/arcane/iris/engine/actuator/HiddenOres.java new file mode 100644 index 000000000..48b5a3535 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/HiddenOres.java @@ -0,0 +1,32 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.actuator; + +import art.arcane.iris.builtin.terrain.HideOresSettings; +import art.arcane.iris.engine.object.world.dimension.IrisDimension; + +/** Whether a dimension hides its ores ({@code hideOresForHiddenOre}): the terrain places none and the perfection pass turns the rest into their base blocks. */ +public final class HiddenOres { + private HiddenOres() { + } + + public static boolean in(IrisDimension dimension) { + return dimension.getModuleSettings().find(HideOresSettings.class).map(HideOresSettings::hide).orElse(false); + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java b/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java index 0e5bbbaf9..11935ef1f 100644 --- a/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java +++ b/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java @@ -19,55 +19,52 @@ package art.arcane.iris.engine.actuator; import art.arcane.iris.engine.framework.Engine; -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.region.IrisRegion; import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.math.RNG; import java.util.Comparator; +import java.util.function.LongSupplier; /** * Builds the noise of every ore generator the world's biomes, regions and dimension declare before generation needs it. - * A generator keeps the noise of the first random it is given, so each one is warmed with the random of its place in + * A generator keeps the noise of the first seed it is given, so each one is warmed with the seed of its place in * this order: the biomes by key, the regions by key, then the dimension. The order is part of what a world generates. */ final class OreWarmUp { private static final long ROOT_SEED_SALT = 7777L; private final Engine engine; + private final TerrainOres ores; private final RNG root; private int warmed; OreWarmUp(Engine engine) { + this(engine, TerrainOres.of(engine)); + } + + OreWarmUp(Engine engine, TerrainOres ores) { this.engine = engine; + this.ores = ores; this.root = new RNG(engine.getSeedManager().getComponent() + ROOT_SEED_SALT); } void warm() { + LongSupplier seeds = () -> root.nextParallelRNG(warmed++).getSeed(); + KList biomes = engine.getAllBiomes(); biomes.sort(Comparator.comparing(IrisBiome::getLoadKey)); for (IrisBiome biome : biomes) { - warmAll(biome.getOres()); + ores.of(biome).warm(seeds); } KList regions = engine.getDimension().getAllRegions(engine); regions.sort(Comparator.comparing(IrisRegion::getLoadKey)); for (IrisRegion region : regions) { - warmAll(region.getOres()); + ores.of(region).warm(seeds); } - warmAll(engine.getDimension().getOres()); - } - - private void warmAll(KList ores) { - if (ores == null) { - return; - } - for (IrisOreGenerator ore : ores) { - if (ore != null) { - ore.warm(root.nextParallelRNG(warmed++), engine.getData()); - } - } + ores.of(engine.getDimension()).warm(seeds); } } diff --git a/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java new file mode 100644 index 000000000..721dbbb0c --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java @@ -0,0 +1,133 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.actuator; + +import art.arcane.iris.builtin.terrain.OreGenerator; +import art.arcane.iris.engine.data.cache.AtomicCache; +import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.spi.PlatformBlockState; +import art.arcane.iris.util.common.data.B; +import com.volmit.block.BlockRegistry; +import com.volmit.block.BlockSpec; +import com.volmit.block.PaletteSampler; +import com.volmit.noise.NoiseFactory; +import com.volmit.noise.NoiseSampler; + +import java.util.ArrayList; +import java.util.List; + +/** + * One {@link OreGenerator} made ready for one world: its palette resolved to the platform's blocks and the noise that + * decides where it places ore, built from the seed it is warmed with or, when nothing warmed it, from the terrain seed + * of its first use. The palette picks with the terrain seed. What the generator describes stays in the settings; + * everything that needs the platform, the pack or the world seed is here. + */ +final class ResolvedOre { + private final OreGenerator settings; + private final NoiseFactory noise; + private final BlockRegistry blockRegistry; + private final long terrainSeed; + private final List blocks; + private final AtomicCache chance = new AtomicCache<>(); + private final AtomicCache palette = new AtomicCache<>(); + + /** + * @param terrainSeed the seed the palette picks with, and the noise is built from when nothing warmed it first + * @param blocks the palette as the platform's blocks, each repeated by its weight + */ + ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List blocks) { + this.settings = settings; + this.noise = noise; + this.blockRegistry = blockRegistry; + this.terrainSeed = terrainSeed; + this.blocks = List.copyOf(blocks); + } + + /** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its picks seeded with the terrain seed. */ + static ResolvedOre of(OreGenerator settings, Engine engine) { + var resources = engine.getData().getPackResources(); + BlockRegistry registry = resources.blocks(); + return new ResolvedOre(settings, resources.noise(), registry, engine.getSeedManager().getTerrain(), weighted(registry, settings.palette().palette())); + } + + private static List weighted(BlockRegistry registry, List specs) { + List weighted = new ArrayList<>(); + for (BlockSpec spec : specs) { + PlatformBlockState state = B.getState(registry.resolve(spec).key()); + if (state == null) { + continue; + } + for (int n = 0; n < spec.weight(); n++) { + weighted.add(state); + } + } + return weighted; + } + + boolean generatesSurface() { + return settings.generateSurface(); + } + + double minY() { + return settings.range().min(); + } + + double maxY() { + return settings.range().max(); + } + + /** Builds the chance noise from {@code seed}, unless it is built already: the first seed it is given is the one it keeps. */ + void warm(long seed) { + chance.aquire(() -> noise.sampler(settings.chanceStyle(), seed)); + } + + /** The ore block at the position, or null when the position is out of the band, the chance noise is above the threshold or the palette has no block. */ + PlatformBlockState generate(int x, int y, int z) { + if (!settings.range().contains(y)) { + return null; + } + if (settings.palette().palette().isEmpty()) { + return null; + } + if (chanceNoise().sample(x, y, z) > settings.threshold()) { + return null; + } + return pick(x, y, z); + } + + /** The chance noise, which this runs per block of the terrain, so a built one is read without creating a supplier. */ + private NoiseSampler chanceNoise() { + NoiseSampler built = chance.getIfPresent(); + if (built != null) { + return built; + } + return chance.aquire(() -> noise.sampler(settings.chanceStyle(), terrainSeed)); + } + + private PlatformBlockState pick(int x, int y, int z) { + if (blocks.isEmpty()) { + return null; + } + if (blocks.size() == 1) { + return blocks.getFirst(); + } + PaletteSampler sampler = palette.aquire(() -> blockRegistry.palette(settings.palette(), terrainSeed)); + return B.getState(sampler.at(x, y, z).key()); + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java new file mode 100644 index 000000000..e3df4ad35 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java @@ -0,0 +1,119 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.actuator; + +import art.arcane.iris.builtin.terrain.OreGenerator; +import art.arcane.iris.builtin.terrain.OreSettings; +import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.spi.PlatformBlockState; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.LongSupplier; + +/** + * The ore generators of one dimension, region or biome made ready ({@link ResolvedOre}), in the order its settings list them + * and split into the ones that also replace surface blocks and the ones that only replace rock. A level without ores is + * {@link #NONE}. + */ +final class ResolvedOres { + static final ResolvedOres NONE = new ResolvedOres(List.of()); + + private final List all; + private final List surface; + private final List underground; + private final YBand surfaceBand; + private final YBand undergroundBand; + + ResolvedOres(List all) { + this.all = List.copyOf(all); + this.surface = this.all.stream().filter(ResolvedOre::generatesSurface).toList(); + this.underground = this.all.stream().filter(ore -> !ore.generatesSurface()).toList(); + this.surfaceBand = YBand.of(surface); + this.undergroundBand = YBand.of(underground); + } + + /** {@code settings} ready for {@code engine}; generators the pack wrote as {@code null} are left out. */ + static ResolvedOres of(OreSettings settings, Engine engine) { + List ores = new ArrayList<>(); + for (OreGenerator generator : settings.generators()) { + if (generator != null) { + ores.add(ResolvedOre.of(generator, engine)); + } + } + return ores.isEmpty() ? NONE : new ResolvedOres(ores); + } + + /** The heights where any surface ore can generate. */ + YBand surfaceBand() { + return surfaceBand; + } + + /** The heights where any rock-only ore can generate. */ + YBand undergroundBand() { + return undergroundBand; + } + + /** Warms every ore in the order the settings list them, each with the next seed. */ + void warm(LongSupplier seeds) { + for (ResolvedOre ore : all) { + ore.warm(seeds.getAsLong()); + } + } + + PlatformBlockState generateSurface(int x, int y, int z) { + return firstOre(surface, x, y, z); + } + + PlatformBlockState generateUnderground(int x, int y, int z) { + return firstOre(underground, x, y, z); + } + + private static PlatformBlockState firstOre(List ores, int x, int y, int z) { + for (int index = 0; index < ores.size(); index++) { + PlatformBlockState ore = ores.get(index).generate(x, y, z); + if (ore != null) { + return ore; + } + } + return null; + } + + /** The lowest and highest height any of a set of ores reaches; empty when there are none. */ + record YBand(boolean hasOres, double min, double max) { + static final YBand EMPTY = new YBand(false, 0, 0); + + static YBand of(List ores) { + if (ores.isEmpty()) { + return EMPTY; + } + double min = Double.POSITIVE_INFINITY; + double max = Double.NEGATIVE_INFINITY; + for (ResolvedOre ore : ores) { + min = Math.min(min, ore.minY()); + max = Math.max(max, ore.maxY()); + } + return new YBand(true, min, max); + } + + boolean contains(int y) { + return hasOres && y >= min && y <= max; + } + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java index e0068796d..279980029 100644 --- a/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java +++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java @@ -28,14 +28,15 @@ import art.arcane.iris.builtin.terrain.RockPaletteSettings; import art.arcane.iris.builtin.terrain.SeaLayersSettings; import art.arcane.iris.builtin.terrain.SlabSettings; import art.arcane.iris.builtin.terrain.WallSettings; +import art.arcane.iris.builtin.terrain.HideOresSettings; +import art.arcane.iris.builtin.terrain.OreSettings; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.core.modules.IrisChunk; import art.arcane.iris.core.modules.IrisPackWorld; import art.arcane.iris.engine.IrisComplex; import art.arcane.iris.engine.UpperDimensionContext; +import art.arcane.iris.engine.actuator.ResolvedOres.YBand; import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; 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; @@ -83,6 +84,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { registry.registerSettings(LockLayersMaxSettings.class); registry.registerSettings(RockPaletteSettings.class); registry.registerSettings(FluidPaletteSettings.class); + registry.registerSettings(OreSettings.class); + registry.registerSettings(HideOresSettings.class); registry.registerLifecycle(this); } @@ -110,16 +113,18 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { private final Engine engine; private final TerrainPalettes palettes; private final BiomeLayers layers; + private final TerrainOres ores; private final RNG rng; TerrainShaper(Engine engine) { - this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine)); + this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine), TerrainOres.of(engine)); } - TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers) { + TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) { this.engine = engine; this.palettes = palettes; this.layers = layers; + this.ores = ores; this.rng = new RNG(engine.getSeedManager().getTerrain()); } @@ -145,17 +150,16 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { int fluidHeight = dimension.getFluidHeight(); int clampedFluidHeight = Math.min(chunkHeight, fluidHeight); boolean bedrockEnabled = dimension.isBedrock(); - boolean hideOres = dimension.isHideOresForHiddenOre(); + boolean hideOres = HiddenOres.in(dimension); ChunkedDataCache biomeCache = context.getBiome(); ChunkedDataCache regionCache = context.getRegion(); int realX = xf + x; UpperDimensionContext upperContext = engine.getUpperContext(); // Dimension-level ore lookups are chunk-invariant; resolving them per column paid - // four accessor chains times 256 per chunk for constants. - KList dimensionSurfaceOres = hideOres ? null : dimension.getSurfaceOreGenerators(); - KList dimensionUndergroundOres = hideOres ? null : dimension.getUndergroundOreGenerators(); - IrisOreGeneratorBounds dimensionSurfaceOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : dimension.getSurfaceOreGeneratorBounds(); - IrisOreGeneratorBounds dimensionUndergroundOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : dimension.getUndergroundOreGeneratorBounds(); + // the settings lookup times 256 per chunk for a constant. + ResolvedOres dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(dimension); + YBand dimensionSurfaceBand = dimensionOres.surfaceBand(); + YBand dimensionUndergroundBand = dimensionOres.undergroundBand(); for (int zf = 0; zf < chunkDepth; zf++) { int realZ = zf + z; @@ -171,16 +175,14 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { PlatformBlockState fluid = palettes.fluidAt(realX, realZ); PlatformBlockState rock = palettes.rockAt(realX, realZ); PlatformBlockState mappedSurfaceBlock = complex.getImageMapRuntime().sampleSurfaceBlock(realX, realZ); - KList biomeSurfaceOres = hideOres ? null : biome.getSurfaceOreGenerators(); - KList regionSurfaceOres = hideOres ? null : region.getSurfaceOreGenerators(); - KList biomeUndergroundOres = hideOres ? null : biome.getUndergroundOreGenerators(); - KList regionUndergroundOres = hideOres ? null : region.getUndergroundOreGenerators(); - IrisOreGeneratorBounds biomeSurfaceOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : biome.getSurfaceOreGeneratorBounds(); - IrisOreGeneratorBounds regionSurfaceOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : region.getSurfaceOreGeneratorBounds(); - IrisOreGeneratorBounds biomeUndergroundOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : biome.getUndergroundOreGeneratorBounds(); - IrisOreGeneratorBounds regionUndergroundOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : region.getUndergroundOreGeneratorBounds(); - boolean hasSurfaceOres = biomeSurfaceOreBounds.hasOres() || regionSurfaceOreBounds.hasOres() || dimensionSurfaceOreBounds.hasOres(); - boolean hasUndergroundOres = biomeUndergroundOreBounds.hasOres() || regionUndergroundOreBounds.hasOres() || dimensionUndergroundOreBounds.hasOres(); + ResolvedOres biomeOres = hideOres ? ResolvedOres.NONE : ores.of(biome); + ResolvedOres regionOres = hideOres ? ResolvedOres.NONE : ores.of(region); + YBand biomeSurfaceBand = biomeOres.surfaceBand(); + YBand regionSurfaceBand = regionOres.surfaceBand(); + YBand biomeUndergroundBand = biomeOres.undergroundBand(); + YBand regionUndergroundBand = regionOres.undergroundBand(); + boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres(); + boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres(); KList blocks = null; KList fblocks = null; @@ -192,14 +194,14 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { PlatformBlockState ore = null; if (hasSurfaceOres) { - if (biomeSurfaceOreBounds.contains(i)) { - ore = generateOres(biomeSurfaceOres, realX, i, realZ, localRng, data); + if (biomeSurfaceBand.contains(i)) { + ore = biomeOres.generateSurface(realX, i, realZ); } - if (ore == null && regionSurfaceOreBounds.contains(i)) { - ore = generateOres(regionSurfaceOres, realX, i, realZ, localRng, data); + if (ore == null && regionSurfaceBand.contains(i)) { + ore = regionOres.generateSurface(realX, i, realZ); } - if (ore == null && dimensionSurfaceOreBounds.contains(i)) { - ore = generateOres(dimensionSurfaceOres, realX, i, realZ, localRng, data); + if (ore == null && dimensionSurfaceBand.contains(i)) { + ore = dimensionOres.generateSurface(realX, i, realZ); } } if (ore != null) { @@ -237,14 +239,14 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { } if (hasUndergroundOres) { - if (biomeUndergroundOreBounds.contains(i)) { - ore = generateOres(biomeUndergroundOres, realX, i, realZ, localRng, data); + if (biomeUndergroundBand.contains(i)) { + ore = biomeOres.generateUnderground(realX, i, realZ); } - if (ore == null && regionUndergroundOreBounds.contains(i)) { - ore = generateOres(regionUndergroundOres, realX, i, realZ, localRng, data); + if (ore == null && regionUndergroundBand.contains(i)) { + ore = regionOres.generateUnderground(realX, i, realZ); } - if (ore == null && dimensionUndergroundOreBounds.contains(i)) { - ore = generateOres(dimensionUndergroundOres, realX, i, realZ, localRng, data); + if (ore == null && dimensionUndergroundBand.contains(i)) { + ore = dimensionOres.generateUnderground(realX, i, realZ); } } @@ -292,22 +294,5 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { } } } - - private PlatformBlockState generateOres(KList oreGenerators, int x, int y, int z, RNG rng, IrisData data) { - if (oreGenerators == null || oreGenerators.isEmpty()) { - return null; - } - - int oreCount = oreGenerators.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = oreGenerators.get(oreIndex); - PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data); - if (ore != null) { - return ore; - } - } - - return null; - } } } diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java new file mode 100644 index 000000000..1eb73d719 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java @@ -0,0 +1,60 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.actuator; + +import art.arcane.iris.builtin.terrain.OreSettings; +import art.arcane.iris.core.loader.IrisRegistrant; +import art.arcane.iris.engine.framework.Engine; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * What the terrain module keeps for one world: the ore generators of its dimension, regions and biomes made ready + * ({@link ResolvedOres}), built from their {@link OreSettings} when first asked for or ahead of generation by {@link OreWarmUp}. + */ +final class TerrainOres { + private final Engine engine; + private final Map resolved = new ConcurrentHashMap<>(); + + TerrainOres(Engine engine) { + this.engine = engine; + } + + /** The ores of the world {@code engine} generates now. */ + static TerrainOres of(Engine engine) { + return engine.getGeneration().state(TerrainOres.class, TerrainOres::new); + } + + /** + * The ore generators {@code owner}, a dimension, region or biome, declares; {@link ResolvedOres#NONE} when it declares none. The + * terrain asks this for two owners per column, so a resolved set is read without taking the map's lock. + */ + ResolvedOres of(IrisRegistrant owner) { + OreSettings settings = owner.getModuleSettings().find(OreSettings.class).orElse(null); + if (settings == null) { + return ResolvedOres.NONE; + } + ResolvedOres existing = resolved.get(settings); + if (existing != null) { + return existing; + } + return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, engine)); + } +} diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java b/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java index 9ece76776..7046d1da8 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java @@ -19,14 +19,18 @@ package art.arcane.iris.engine.mantle.components; import art.arcane.iris.builtin.carve.CaveProfile; +import art.arcane.iris.core.modules.IrisValues; import art.arcane.iris.engine.IrisComplex; import art.arcane.iris.engine.UpperDimensionContext; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.mantle.MantleWriter; import art.arcane.iris.engine.terrain.TerrainPalettes; +import art.arcane.iris.engine.object.terrain.carving.CaveProfiles; import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver; +import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry; +import art.arcane.iris.engine.modifier.CaveBiomeBands; +import art.arcane.iris.engine.object.terrain.carving.CarvingBands; +import art.arcane.iris.engine.object.terrain.carving.CarvingResolver; import art.arcane.iris.engine.object.world.region.IrisRegion; import art.arcane.iris.engine.object.value.IrisRange; import art.arcane.iris.spi.PlatformBlockState; @@ -90,7 +94,7 @@ public class CaveCarving { /** Carves the caves of the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ public void carve(MantleWriter writer, int x, int z, ChunkContext context) { IrisComplex complex = context.getComplex(); - IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State(); + CarvingResolver.State resolverState = new CarvingResolver.State(); BlendScratch blendScratch = BLEND_SCRATCH.get(); int[] chunkSurfaceHeights = prepareChunkSurfaceHeights(x, z, context, blendScratch.chunkSurfaceHeights); PrecisionStopwatch resolveStopwatch = PrecisionStopwatch.start(); @@ -201,7 +205,7 @@ public class CaveCarving { } } - private List resolveWeightedProfiles(int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState) { + private List resolveWeightedProfiles(int chunkX, int chunkZ, IrisComplex complex, CarvingResolver.State resolverState) { BlendScratch blendScratch = BLEND_SCRATCH.get(); CaveProfile[] profileField = blendScratch.profileField; Map columnProfileWeights = blendScratch.columnProfileWeights; @@ -297,40 +301,40 @@ public class CaveCarving { return resolvedProfiles; } - private List resolveDimensionCarvingProfiles(int chunkX, int chunkZ, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) { + private List resolveDimensionCarvingProfiles(int chunkX, int chunkZ, CarvingResolver.State resolverState, BlendScratch blendScratch) { List weightedProfiles = new ArrayList<>(); - List entries = engine.getDimension().getCarving(); - if (entries == null || entries.isEmpty()) { + List entries = CarvingBands.of(engine).entries(); + if (entries.isEmpty()) { return weightedProfiles; } - Map dimensionColumnPlans = blendScratch.dimensionColumnPlans; + Map dimensionColumnPlans = blendScratch.dimensionColumnPlans; dimensionColumnPlans.clear(); - for (IrisDimensionCarvingEntry entry : entries) { - if (entry == null || !entry.isEnabled()) { + for (ResolvedCarvingEntry entry : entries) { + if (!entry.enabled()) { continue; } - IrisBiome rootBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, entry, resolverState); + IrisBiome rootBiome = CarvingResolver.resolveEntryBiome(engine, entry, resolverState); if (rootBiome == null) { continue; } - IrisDimensionCarvingEntry[] columnPlan = dimensionColumnPlans.computeIfAbsent(entry, key -> new IrisDimensionCarvingEntry[CHUNK_AREA]); + ResolvedCarvingEntry[] columnPlan = dimensionColumnPlans.computeIfAbsent(entry, key -> new ResolvedCarvingEntry[CHUNK_AREA]); buildDimensionColumnPlan(columnPlan, chunkX, chunkZ, entry, resolverState); Map rootProfileColumnWeights = new IdentityHashMap<>(); List rootProfileOrder = new ArrayList<>(); - IrisRange worldYRange = entry.getWorldYRange(); + IrisRange worldYRange = entry.worldYRange() == null ? null : IrisValues.range(entry.worldYRange()); for (int columnIndex = 0; columnIndex < CHUNK_AREA; columnIndex++) { - IrisDimensionCarvingEntry resolvedEntry = columnPlan[columnIndex]; - IrisBiome resolvedBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, resolvedEntry, resolverState); + ResolvedCarvingEntry resolvedEntry = columnPlan[columnIndex]; + IrisBiome resolvedBiome = CarvingResolver.resolveEntryBiome(engine, resolvedEntry, resolverState); if (resolvedBiome == null) { continue; } - CaveProfile profile = resolvedBiome.getCaveProfile(); + CaveProfile profile = CaveProfiles.declaredBy(resolvedBiome); if (!isProfileEnabled(profile)) { continue; } @@ -352,7 +356,7 @@ public class CaveCarving { return weightedProfiles; } - private void buildDimensionColumnPlan(IrisDimensionCarvingEntry[] columnPlan, int chunkX, int chunkZ, IrisDimensionCarvingEntry entry, IrisDimensionCarvingResolver.State resolverState) { + private void buildDimensionColumnPlan(ResolvedCarvingEntry[] columnPlan, int chunkX, int chunkZ, ResolvedCarvingEntry entry, CarvingResolver.State resolverState) { int baseX = PowerOfTwoCoordinates.chunkToBlock(chunkX); int baseZ = PowerOfTwoCoordinates.chunkToBlock(chunkZ); for (int localX = 0; localX < CHUNK_SIZE; localX++) { @@ -360,12 +364,12 @@ public class CaveCarving { for (int localZ = 0; localZ < CHUNK_SIZE; localZ++) { int worldZ = baseZ + localZ; int columnIndex = PowerOfTwoCoordinates.packLocal16(localX, localZ); - columnPlan[columnIndex] = IrisDimensionCarvingResolver.resolveFromRoot(engine, entry, worldX, worldZ, resolverState); + columnPlan[columnIndex] = CarvingResolver.resolveFromRoot(engine, entry, worldX, worldZ, resolverState); } } } - private void fillProfileField(CaveProfile[] profileField, int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) { + private void fillProfileField(CaveProfile[] profileField, int chunkX, int chunkZ, IrisComplex complex, CarvingResolver.State resolverState, BlendScratch blendScratch) { int startX = PowerOfTwoCoordinates.chunkToBlock(chunkX) - BLEND_RADIUS; int startZ = PowerOfTwoCoordinates.chunkToBlock(chunkZ) - BLEND_RADIUS; prefillProfileFieldSamples(startX, startZ, complex, blendScratch); @@ -405,23 +409,23 @@ public class CaveCarving { IrisRegion region, IrisBiome surfaceBiome, IrisBiome caveBiome, - IrisDimensionCarvingResolver.State resolverState + CarvingResolver.State resolverState ) { CaveProfile resolved = null; - CaveProfile dimensionProfile = engine.getDimension().getCaveProfile(); + CaveProfile dimensionProfile = CaveProfiles.declaredBy(engine.getDimension()); if (isProfileEnabled(dimensionProfile)) { resolved = dimensionProfile; } if (region != null) { - CaveProfile regionProfile = region.getCaveProfile(); + CaveProfile regionProfile = CaveProfiles.declaredBy(region); if (isProfileEnabled(regionProfile)) { resolved = regionProfile; } } if (surfaceBiome != null) { - CaveProfile surfaceProfile = surfaceBiome.getCaveProfile(); + CaveProfile surfaceProfile = CaveProfiles.declaredBy(surfaceBiome); if (isProfileEnabled(surfaceProfile)) { resolved = surfaceProfile; } @@ -430,11 +434,11 @@ public class CaveCarving { int roundedSurfaceY = (int) Math.round(surfaceHeight); int sampleY = Math.max(1, roundedSurfaceY - 56); int worldY = sampleY + engine.getWorld().minHeight(); - IrisDimensionCarvingEntry rootCarvingEntry = IrisDimensionCarvingResolver.resolveRootEntry(engine, worldY, resolverState); + ResolvedCarvingEntry rootCarvingEntry = CarvingResolver.resolveRootEntry(engine, worldY, resolverState); IrisBiome resolvedCarvingBiome = null; if (rootCarvingEntry != null) { - IrisDimensionCarvingEntry resolvedCarvingEntry = IrisDimensionCarvingResolver.resolveFromRoot(engine, rootCarvingEntry, worldX, worldZ, resolverState); - resolvedCarvingBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, resolvedCarvingEntry, resolverState); + ResolvedCarvingEntry resolvedCarvingEntry = CarvingResolver.resolveFromRoot(engine, rootCarvingEntry, worldX, worldZ, resolverState); + resolvedCarvingBiome = CarvingResolver.resolveEntryBiome(engine, resolvedCarvingEntry, resolverState); if (resolvedCarvingBiome != null) { caveBiome = resolvedCarvingBiome; } @@ -448,7 +452,7 @@ public class CaveCarving { if (depthBelowSurface <= 0) { effectiveCaveBiome = surfaceBiome; } else { - int minDepth = Math.max(0, caveBiome.getCaveMinDepthBelowSurface()); + int minDepth = Math.max(0, CaveBiomeBands.minDepthBelowSurface(caveBiome)); if (depthBelowSurface < minDepth) { effectiveCaveBiome = surfaceBiome; } @@ -456,7 +460,7 @@ public class CaveCarving { } } - CaveProfile caveProfile = effectiveCaveBiome.getCaveProfile(); + CaveProfile caveProfile = CaveProfiles.declaredBy(effectiveCaveBiome); if (isProfileEnabled(caveProfile)) { resolved = caveProfile; } @@ -681,7 +685,7 @@ public class CaveCarving { private final CaveProfile[] kernelProfiles = new CaveProfile[KERNEL_SIZE]; private final double[] kernelProfileWeights = new double[KERNEL_SIZE]; private final IdentityHashMap columnProfileWeights = new IdentityHashMap<>(); - private final IdentityHashMap dimensionColumnPlans = new IdentityHashMap<>(); + private final IdentityHashMap dimensionColumnPlans = new IdentityHashMap<>(); private final IdentityHashMap activeProfiles = new IdentityHashMap<>(); private final List profileOrder = new ArrayList<>(); private final double[] fieldSurfaceHeights = new double[FIELD_SIZE * FIELD_SIZE]; diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver.java b/src/main/java/art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver.java index b80204f93..b45fbe693 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver.java @@ -23,6 +23,7 @@ import art.arcane.iris.engine.data.cache.Cache; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.mantle.EngineMantle; import art.arcane.iris.engine.modifier.FloatingIslands; +import art.arcane.iris.engine.object.terrain.floating.FloatingChildren; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler; import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample; import art.arcane.iris.engine.object.world.biome.IrisBiome; @@ -56,7 +57,7 @@ final class FloatingIslandSampleResolver implements IslandObjectPlacer.SamplePro return sampleCache.get(key); } IrisBiome parent = parent(x, z); - if (parent == null || parent.getFloatingChildBiomes() == null || parent.getFloatingChildBiomes().isEmpty()) { + if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) { resolvedSamples.add(key); return null; } diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java b/src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java index 2a74bfb86..6537c02ce 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java @@ -543,8 +543,8 @@ public class FloatingObjectPlacing { try { IrisData data = engine.getData(); for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) { - List settings = biome.getFloatingChildBiomes(); - if (settings == null || settings.isEmpty()) { + List settings = FloatingChildren.declaredBy(biome); + if (settings.isEmpty()) { continue; } for (ResolvedFloatingChild entry : FloatingChildren.of(engine).of(settings)) { diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java index 88d18f4b8..80e64d2e1 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java @@ -25,6 +25,7 @@ import art.arcane.iris.builtin.carve.CaveAnchorMode; import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.builtin.anchor.ObjectPlaceMode; import art.arcane.iris.builtin.prepare.AxisRotationClamp; +import art.arcane.iris.engine.object.terrain.carving.CaveProfiles; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.engine.object.placement.IrisObjectVacuum; import art.arcane.iris.core.IrisSettings; @@ -78,6 +79,7 @@ import java.util.concurrent.atomic.AtomicLong; * placement reach of any object the dimension can place. */ public class ObjectPlacing { + private static final CaveProfile DEFAULT_CAVE_PROFILE = new CaveProfile(); private static final long CAVE_REJECT_LOG_THROTTLE_MS = 5000L; private static final int BEDROCK_CLEARANCE = 6; private static final byte LIQUID_FORCED_AIR = 3; @@ -235,8 +237,8 @@ public class ObjectPlacing { int rejected = 0; int nullObjects = 0; int errors = 0; - CaveProfile biomeCaveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile()); - CaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome.getCaveProfile()); + CaveProfile biomeCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(caveBiome), CaveProfiles.declaredBy(region)); + CaveProfile regionCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(region), CaveProfiles.declaredBy(caveBiome)); CaveAnchorCache caveAnchorCache = new CaveAnchorCache(); for (IrisObjectPlacement i : surfaceBiome.getSurfaceObjects()) { @@ -384,12 +386,12 @@ public class ObjectPlacing { @ChunkCoordinates private void placeProceduralObjects(MantleWriter writer, RNG rng, int x, int z, IrisBiome surfaceBiome, IrisBiome caveBiome, IrisRegion region) { - CaveProfile surfaceCaveProfile = resolveCaveProfile(surfaceBiome.getCaveProfile(), region.getCaveProfile()); - CaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome == null ? null : caveBiome.getCaveProfile()); + CaveProfile surfaceCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(surfaceBiome), CaveProfiles.declaredBy(region)); + CaveProfile regionCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(region), caveBiome == null ? null : CaveProfiles.declaredBy(caveBiome)); placeProceduralFrom(writer, rng, x, z, surfaceBiome.getProceduralObjects(), surfaceBiome.getName(), surfaceCaveProfile, surfaceBiome.getLoadKey()); placeProceduralFrom(writer, rng, x, z, region.getProceduralObjects(), region.getName(), regionCaveProfile, null); if (caveBiome != null && caveBiome != surfaceBiome) { - CaveProfile caveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile()); + CaveProfile caveProfile = resolveCaveProfile(CaveProfiles.declaredBy(caveBiome), CaveProfiles.declaredBy(region)); placeProceduralFrom(writer, rng, x, z, caveBiome.getProceduralObjects(), caveBiome.getName(), caveProfile, caveBiome.getLoadKey()); } } @@ -1319,7 +1321,7 @@ public class ObjectPlacing { } private CaveProfile resolveCaveProfile(CaveProfile preferred, CaveProfile secondary) { - CaveProfile dimensionProfile = engine.getDimension().getCaveProfile(); + CaveProfile dimensionProfile = CaveProfiles.declaredBy(engine.getDimension()); if (preferred != null && preferred.enabled()) { return preferred; } @@ -1332,7 +1334,7 @@ public class ObjectPlacing { return dimensionProfile; } - return new CaveProfile(); + return DEFAULT_CAVE_PROFILE; } private CaveAnchorMode resolveAnchorMode(IrisObjectPlacement objectPlacement, CaveProfile caveProfile) { diff --git a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java index d69592f3d..4d6a91412 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java @@ -18,7 +18,10 @@ package art.arcane.iris.engine.modifier; -import art.arcane.iris.builtin.carve.CaveFieldModule; +import art.arcane.iris.builtin.carve.CarvingBiomeSettings; +import art.arcane.iris.builtin.carve.CarvingEnabledSettings; +import art.arcane.iris.builtin.carve.CarvingSettings; +import art.arcane.iris.builtin.carve.CaveDepthSettings; import art.arcane.iris.builtin.carve.CaveProfile; import com.volmit.FeatureRegistry; import art.arcane.iris.builtin.IrisStages; @@ -28,6 +31,7 @@ import art.arcane.iris.engine.mantle.components.CaveCarving; import art.arcane.iris.engine.object.world.dimension.IrisDimension; import com.volmit.IrisModule; import com.volmit.ModuleInfo; +import com.volmit.service.CaveBiomes; import com.volmit.stage.ChunkStageContext; import com.volmit.stage.MantleStageContext; import com.volmit.stage.StageGraph; @@ -51,8 +55,12 @@ public final class CarveModule implements IrisModule { @Override public void register(FeatureRegistry registry) { - registry.registerHeldType(CaveProfile.class); - registry.registerHeldType(CaveFieldModule.class); + registry.registerSettings(CaveProfile.class); + registry.registerSettings(CarvingSettings.class); + registry.registerSettings(CarvingEnabledSettings.class); + registry.registerSettings(CarvingBiomeSettings.class); + registry.registerSettings(CaveDepthSettings.class); + registry.registerService(CaveBiomes.class, new CaveBiomeBands()); } @Override @@ -83,6 +91,6 @@ public final class CarveModule implements IrisModule { * also does: Iris then skips this stage's mantle pass like any disabled component. */ private static boolean carves(IrisDimension dimension) { - return dimension.isCarvingEnabled(); + return dimension.getModuleSettings().find(CarvingEnabledSettings.class).map(CarvingEnabledSettings::enabled).orElse(true); } } diff --git a/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java b/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java index 9ecd42df6..49b57c590 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java +++ b/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java @@ -28,7 +28,6 @@ import art.arcane.iris.engine.decorator.IrisSurfaceDecorator; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.object.world.biome.InferredType; import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver; import art.arcane.iris.util.project.context.ChunkContext; import art.arcane.iris.util.common.data.B; import art.arcane.volmlib.util.documentation.ChunkCoordinates; @@ -88,7 +87,6 @@ public class CaveApplying { public void apply(int x, int z, Hunk output, boolean multicore, ChunkContext context) { PrecisionStopwatch caveStopwatch = PrecisionStopwatch.start(); Mantle mantle = engine.getMantle().getMantle(); - IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State(); Long2ObjectOpenHashMap caveBiomeCache = new Long2ObjectOpenHashMap<>(2048); IrisCarveScratch scratch = SCRATCH.get(); scratch.reset(); @@ -180,7 +178,7 @@ public class CaveApplying { int worldZ = rz + chunkBlockZ; String customBiome = cavern.getCustomBiome(); IrisBiome biome = customBiome.isEmpty() - ? resolveCaveBiome(caveBiomeCache, worldX, yy, worldZ, resolverState) + ? resolveCaveBiome(caveBiomeCache, worldX, yy, worldZ) : resolveCustomBiome(customBiomeCache, customBiome); if (biome != null) { @@ -194,14 +192,14 @@ public class CaveApplying { }); for (int columnIndex = 0; columnIndex < 256; columnIndex++) { - processColumnFromMask(output, mantleChunk, mantle, columnMasks[columnIndex], columnIndex, x, z, resolverState, caveBiomeCache, customBiomeCache); + processColumnFromMask(output, mantleChunk, mantle, columnMasks[columnIndex], columnIndex, x, z, caveBiomeCache, customBiomeCache); } for (int columnIndex = 0; columnIndex < 256; columnIndex++) { if (boundaryMasks[columnIndex].isEmpty() || !columnMasks[columnIndex].isEmpty()) { continue; } - processBoundaryColumnFromMask(output, boundaryMasks[columnIndex], walls, columnIndex, x, z, resolverState, caveBiomeCache, customBiomeCache); + processBoundaryColumnFromMask(output, boundaryMasks[columnIndex], walls, columnIndex, x, z, caveBiomeCache, customBiomeCache); } // Surface-break carving must not leave an ore cap suspended across the opening. @@ -415,7 +413,6 @@ public class CaveApplying { int columnIndex, int chunkX, int chunkZ, - IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache ) { @@ -444,7 +441,7 @@ public class CaveApplying { zone.ceiling = buf; } else { if (zone.isValid(engine)) { - processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, resolverState, caveBiomeCache, customBiomeCache); + processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, caveBiomeCache, customBiomeCache); } zone = new CaveZone(); zone.setFloor(y); @@ -456,7 +453,7 @@ public class CaveApplying { } if (zone.isValid(engine)) { - processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, resolverState, caveBiomeCache, customBiomeCache); + processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, caveBiomeCache, customBiomeCache); } } @@ -467,7 +464,6 @@ public class CaveApplying { int columnIndex, int chunkX, int chunkZ, - IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache ) { @@ -488,14 +484,14 @@ public class CaveApplying { if (y == zoneCeiling + 1) { zoneCeiling = y; } else { - paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, resolverState, caveBiomeCache, customBiomeCache); + paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, caveBiomeCache, customBiomeCache); zoneFloor = y; zoneCeiling = y; } y = boundaryMask.nextSetBit(y + 1); } - paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, resolverState, caveBiomeCache, customBiomeCache); + paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, caveBiomeCache, customBiomeCache); } private void paintBoundaryZone( @@ -507,16 +503,15 @@ public class CaveApplying { int worldZ, int zoneFloor, int zoneCeiling, - IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache ) { IrisBiome floorBiome = resolveCaveBoundaryBiome( walls.get(rx, zoneFloor, rz), worldX, zoneFloor, worldZ, - resolverState, caveBiomeCache, customBiomeCache); + caveBiomeCache, customBiomeCache); IrisBiome ceilingBiome = resolveCaveBoundaryBiome( walls.get(rx, zoneCeiling, rz), worldX, zoneCeiling, worldZ, - resolverState, caveBiomeCache, customBiomeCache); + caveBiomeCache, customBiomeCache); if (floorBiome == null && ceilingBiome == null) { return; } @@ -580,7 +575,7 @@ public class CaveApplying { return (h & 15L) == 0L; } - private void processZone(Hunk output, MantleChunk mc, Mantle mantle, CaveZone zone, int rx, int rz, int xx, int zz, IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache) { + private void processZone(Hunk output, MantleChunk mc, Mantle mantle, CaveZone zone, int rx, int rz, int xx, int zz, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache) { int maxY = output.getHeight(); if (zone.ceiling + 1 < maxY && B.isDecorant(output.getRaw(rx, zone.ceiling + 1, rz))) { @@ -602,8 +597,8 @@ public class CaveApplying { mantle.set(xx, zone.floor, zz, MarkerMatter.CAVE_FLOOR); } - IrisBiome floorBiome = resolveCaveBoundaryBiome(mc, rx, zone.floor, rz, xx, zz, resolverState, caveBiomeCache, customBiomeCache); - IrisBiome ceilingBiome = resolveCaveBoundaryBiome(mc, rx, zone.ceiling, rz, xx, zz, resolverState, caveBiomeCache, customBiomeCache); + IrisBiome floorBiome = resolveCaveBoundaryBiome(mc, rx, zone.floor, rz, xx, zz, caveBiomeCache, customBiomeCache); + IrisBiome ceilingBiome = resolveCaveBoundaryBiome(mc, rx, zone.ceiling, rz, xx, zz, caveBiomeCache, customBiomeCache); if (floorBiome == null && ceilingBiome == null) { return; } @@ -657,10 +652,10 @@ public class CaveApplying { } } - IrisBiome resolveCaveBoundaryBiome(MantleChunk mantleChunk, int x, int y, int z, int worldX, int worldZ, IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache) { + IrisBiome resolveCaveBoundaryBiome(MantleChunk mantleChunk, int x, int y, int z, int worldX, int worldZ, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache) { MatterCavern cavern = dataIfPresent(mantleChunk, x, y, z, MatterCavern.class); return resolveCaveBoundaryBiome( - cavern, worldX, y, worldZ, resolverState, caveBiomeCache, customBiomeCache); + cavern, worldX, y, worldZ, caveBiomeCache, customBiomeCache); } private static T dataIfPresent(MantleChunk mantleChunk, int x, int y, int z, Class type) { @@ -675,11 +670,11 @@ public class CaveApplying { return matter.getSlice(type).get(x & 15, y & 15, z & 15); } - IrisBiome resolveCaveBoundaryBiome(MatterCavern cavern, int worldX, int y, int worldZ, IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache) { + IrisBiome resolveCaveBoundaryBiome(MatterCavern cavern, int worldX, int y, int worldZ, Long2ObjectOpenHashMap caveBiomeCache, Map customBiomeCache) { if (cavern != null && !cavern.getCustomBiome().isEmpty()) { return resolveCustomBiome(customBiomeCache, cavern.getCustomBiome()); } - return resolveCaveBiome(caveBiomeCache, worldX, y, worldZ, resolverState); + return resolveCaveBiome(caveBiomeCache, worldX, y, worldZ); } static boolean canReplaceCaveFloorLayer(Hunk output, int x, int y, int z, PlatformBlockState layer) { @@ -701,16 +696,16 @@ public class CaveApplying { return state != null && state.hasGravity(); } - private IrisBiome resolveCaveBiome(Long2ObjectOpenHashMap caveBiomeCache, int x, int y, int z, IrisDimensionCarvingResolver.State resolverState) { - IrisBiome center = sampleCaveBiome(caveBiomeCache, x, y, z, resolverState); + private IrisBiome resolveCaveBiome(Long2ObjectOpenHashMap caveBiomeCache, int x, int y, int z) { + IrisBiome center = sampleCaveBiome(caveBiomeCache, x, y, z); if (center == null) { return null; } - IrisBiome xPos = sampleCaveBiome(caveBiomeCache, x + CAVE_BIOME_BLEND_RADIUS, y, z, resolverState); - IrisBiome xNeg = sampleCaveBiome(caveBiomeCache, x - CAVE_BIOME_BLEND_RADIUS, y, z, resolverState); - IrisBiome zPos = sampleCaveBiome(caveBiomeCache, x, y, z + CAVE_BIOME_BLEND_RADIUS, resolverState); - IrisBiome zNeg = sampleCaveBiome(caveBiomeCache, x, y, z - CAVE_BIOME_BLEND_RADIUS, resolverState); + IrisBiome xPos = sampleCaveBiome(caveBiomeCache, x + CAVE_BIOME_BLEND_RADIUS, y, z); + IrisBiome xNeg = sampleCaveBiome(caveBiomeCache, x - CAVE_BIOME_BLEND_RADIUS, y, z); + IrisBiome zPos = sampleCaveBiome(caveBiomeCache, x, y, z + CAVE_BIOME_BLEND_RADIUS); + IrisBiome zNeg = sampleCaveBiome(caveBiomeCache, x, y, z - CAVE_BIOME_BLEND_RADIUS); if (xPos == center && xNeg == center && zPos == center && zNeg == center) { return center; @@ -733,14 +728,14 @@ public class CaveApplying { return zNeg != null ? zNeg : center; } - private IrisBiome sampleCaveBiome(Long2ObjectOpenHashMap caveBiomeCache, int x, int y, int z, IrisDimensionCarvingResolver.State resolverState) { + private IrisBiome sampleCaveBiome(Long2ObjectOpenHashMap caveBiomeCache, int x, int y, int z) { long key = BlockPosition.toLong(x, y, z); IrisBiome cachedBiome = caveBiomeCache.get(key); if (cachedBiome != null) { return cachedBiome; } - IrisBiome resolvedBiome = engine.getCaveBiome(x, y, z, resolverState); + IrisBiome resolvedBiome = engine.getCaveBiome(x, y, z); if (resolvedBiome != null) { caveBiomeCache.put(key, resolvedBiome); } diff --git a/src/main/java/art/arcane/iris/engine/modifier/CaveBiomeBands.java b/src/main/java/art/arcane/iris/engine/modifier/CaveBiomeBands.java new file mode 100644 index 000000000..4a67e77c3 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/CaveBiomeBands.java @@ -0,0 +1,61 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.carve.CaveDepthSettings; +import art.arcane.iris.core.modules.IrisPackWorld; +import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.object.terrain.carving.CarvingResolver; +import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry; +import art.arcane.iris.engine.object.world.biome.IrisBiome; +import com.volmit.service.CaveBiomes; +import com.volmit.world.PackWorld; + +import java.util.Optional; + +/** + * What the carve module tells the host about cave biomes ({@link CaveBiomes}): the biome of the dimension's carving band at a + * position, and how far below the surface a biome's caves begin. + */ +public final class CaveBiomeBands implements CaveBiomes { + @Override + public Optional overriddenBiome(PackWorld world, int x, int y, int z) { + Engine engine = IrisPackWorld.of(world).engine(); + ResolvedCarvingEntry rootEntry = CarvingResolver.resolveRootEntry(engine, y + engine.getWorld().minHeight(), null); + if (rootEntry == null) { + return Optional.empty(); + } + ResolvedCarvingEntry entry = CarvingResolver.resolveFromRoot(engine, rootEntry, x, z, null); + if (CarvingResolver.resolveEntryBiome(engine, entry, null) == null) { + return Optional.empty(); + } + return Optional.of(entry.biomeKey().trim()); + } + + @Override + public int minDepthBelowSurface(PackWorld world, String biomeKey) { + IrisBiome biome = IrisPackWorld.of(world).engine().getData().getBiomeLoader().load(biomeKey); + return biome == null ? 0 : minDepthBelowSurface(biome); + } + + /** How many blocks below the surface {@code biome}'s caves begin, as its {@code caveMinDepthBelowSurface} says; 0 where it says none. */ + public static int minDepthBelowSurface(IrisBiome biome) { + return biome.getModuleSettings().find(CaveDepthSettings.class).map(CaveDepthSettings::depth).orElse(0); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java b/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java index f2889714b..668755e37 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java @@ -21,7 +21,11 @@ package art.arcane.iris.engine.modifier; import art.arcane.iris.builtin.IrisStages; import art.arcane.iris.builtin.deposit.DepositGenerator; import art.arcane.iris.builtin.deposit.DepositSettings; +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.core.modules.IrisChunk; +import com.volmit.FeatureRegistry; import com.volmit.IrisModule; import com.volmit.ModuleInfo; import com.volmit.config.FeatureSettings; @@ -48,6 +52,13 @@ public final class DepositModule implements IrisModule { return ModuleInfo.of("iris:deposit", "Deposits", VERSION); } + @Override + public void register(FeatureRegistry registry) { + registry.registerSettings(DepositVariantSettings.class); + registry.registerSettings(OreFrequencySettings.class); + registry.registerSettings(OreSizeSettings.class); + } + @Override public void install(StageGraph graph) { graph.define(IrisStages.Deposit.ORES) diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java index ff3844442..a6fa011ca 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java +++ b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java @@ -21,12 +21,15 @@ package art.arcane.iris.engine.modifier; import art.arcane.iris.builtin.deposit.DepositGenerator; import art.arcane.iris.builtin.deposit.DepositHeightDistribution; import art.arcane.iris.builtin.deposit.DepositPlacementScope; +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.core.loader.IrisRegistrant; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.EngineAssignedComponent; import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; import art.arcane.iris.engine.object.world.dimension.IrisDimension; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver; import art.arcane.iris.engine.object.prefab.IrisObject; import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; import art.arcane.iris.engine.object.world.region.IrisRegion; @@ -52,7 +55,10 @@ import java.util.concurrent.ConcurrentHashMap; */ public class DepositPlacer extends EngineAssignedComponent { private final RNG rng; + private static final double UNCHANGED_ORE_MULTIPLIER = 1D; + private final Map resolved = new ConcurrentHashMap<>(); + private final Map variants = new ConcurrentHashMap<>(); public DepositPlacer(Engine engine) { super(engine, "Deposit"); @@ -95,7 +101,6 @@ public class DepositPlacer extends EngineAssignedComponent { } public void generate(DepositGenerator k, MantleChunk chunk, Hunk data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) { - IrisDimensionCarvingResolver.State carvingState = new IrisDimensionCarvingResolver.State(); ResolvedDeposit deposit = resolved(k); if (k.spawnChance() < rng.d()) return; @@ -141,8 +146,7 @@ public class DepositPlacer extends EngineAssignedComponent { boolean oreDeposit = deposit.isOre(); IrisBiome surfaceBiome = context.getBiome().get(x, z); IrisBiome depositBiome = oreDeposit || k.usesCaveBiomeFilter() - ? getEngine().getCaveBiome( - (cx << 4) + x, biomeY, (cz << 4) + z, carvingState) + ? getEngine().getCaveBiome((cx << 4) + x, biomeY, (cz << 4) + z) : null; if (!deposit.matchesBiome(surfaceBiome, depositBiome)) { continue; @@ -150,13 +154,13 @@ public class DepositPlacer extends EngineAssignedComponent { if (oreDeposit) { if (depositBiome != null) { - double frequencyMultiplier = depositBiome.getOreDepositFrequencyMultiplier(); + double frequencyMultiplier = oreFrequencyMultiplier(depositBiome); if (frequencyMultiplier < 1D && !passesOreFrequency(frequencyMultiplier, rng.d())) { continue; } - double sizeMultiplier = depositBiome.getOreDepositSizeMultiplier(); + double sizeMultiplier = oreSizeMultiplier(depositBiome); if (sizeMultiplier != 1D) { IrisObject scaledClump = deposit.clump(rng, sizeMultiplier); int scaledDimension = scaledClump.getW(); @@ -204,7 +208,7 @@ public class DepositPlacer extends EngineAssignedComponent { if (chunk.get(nx, ny, nz, MatterCavern.class) == null) { PlatformBlockState ore = clump.getBlocks().get(j); PlatformBlockState remapped = resolveDepositVariant( - cx, cz, nx, ny, nz, ore, dimension, context, carvingState); + cx, cz, nx, ny, nz, ore, dimension, context); PlatformBlockState finalBlock = remapped != null ? remapped : B.toDeepSlateOre(current, ore); @@ -310,14 +314,14 @@ public class DepositPlacer extends EngineAssignedComponent { return Math.max(minimum, Math.min(center, maximum)); } - private PlatformBlockState resolveDepositVariant(int cx, int cz, int nx, int localY, int nz, PlatformBlockState ore, IrisDimension dimension, ChunkContext context, IrisDimensionCarvingResolver.State carvingState) { + private PlatformBlockState resolveDepositVariant(int cx, int cz, int nx, int localY, int nz, PlatformBlockState ore, IrisDimension dimension, ChunkContext context) { int worldX = (cx << 4) + nx; int worldZ = (cz << 4) + nz; int worldY = absoluteWorldY(getEngine().getMinHeight(), localY); - IrisBiome biome = getEngine().getCaveBiome(worldX, localY, worldZ, carvingState); + IrisBiome biome = getEngine().getCaveBiome(worldX, localY, worldZ); if (biome != null) { - PlatformBlockState match = matchDepositVariant(biome.getDepositVariants(), ore, worldY); + PlatformBlockState match = matchDepositVariant(biome, ore, worldY); if (match != null) { return match; } @@ -325,14 +329,14 @@ public class DepositPlacer extends EngineAssignedComponent { IrisRegion region = context.getRegion().get(nx, nz); if (region != null) { - PlatformBlockState match = matchDepositVariant(region.getDepositVariants(), ore, worldY); + PlatformBlockState match = matchDepositVariant(region, ore, worldY); if (match != null) { return match; } } if (dimension != null) { - PlatformBlockState match = matchDepositVariant(dimension.getDepositVariants(), ore, worldY); + PlatformBlockState match = matchDepositVariant(dimension, ore, worldY); if (match != null) { return match; } @@ -341,17 +345,14 @@ public class DepositPlacer extends EngineAssignedComponent { return null; } - private PlatformBlockState matchDepositVariant(java.util.List variants, PlatformBlockState ore, int y) { - if (variants == null || variants.isEmpty()) { - return null; - } - - for (IrisDepositVariant variant : variants) { - if (y < variant.getMinHeight() || y > variant.getMaxHeight()) { + private PlatformBlockState matchDepositVariant(IrisRegistrant owner, PlatformBlockState ore, int y) { + for (DepositVariant declared : variantsOf(owner)) { + ResolvedDepositVariant variant = variants.computeIfAbsent(declared, ResolvedDepositVariant::new); + if (!variant.appliesAt(y)) { continue; } - PlatformBlockState swapped = variant.remapOrNull(ore, getData()); + PlatformBlockState swapped = variant.remapOrNull(ore); if (swapped != null) { return swapped; } @@ -359,4 +360,16 @@ public class DepositPlacer extends EngineAssignedComponent { return null; } + + private static List variantsOf(IrisRegistrant owner) { + return owner.getModuleSettings().find(DepositVariantSettings.class).map(DepositVariantSettings::variants).orElse(List.of()); + } + + private static double oreFrequencyMultiplier(IrisBiome biome) { + return biome.getModuleSettings().find(OreFrequencySettings.class).map(OreFrequencySettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER); + } + + private static double oreSizeMultiplier(IrisBiome biome) { + return biome.getModuleSettings().find(OreSizeSettings.class).map(OreSizeSettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER); + } } diff --git a/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java b/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java index 90f51a6e0..7ef4161f9 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java +++ b/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java @@ -19,6 +19,7 @@ package art.arcane.iris.engine.modifier; +import art.arcane.iris.engine.object.terrain.floating.FloatingChildren; import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild; import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode; import art.arcane.iris.builtin.prepare.SlopeClip; @@ -229,7 +230,7 @@ public class FloatingIslands { int wx = x + xf; int wz = z + zf; IrisBiome parent = boundarySampler.parent(wx, wz); - if (parent == null || parent.getFloatingChildBiomes() == null || parent.getFloatingChildBiomes().isEmpty()) { + if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) { continue; } FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler); @@ -314,7 +315,7 @@ public class FloatingIslands { int wx = x + xf; int wz = z + zf; IrisBiome parent = boundarySampler.parent(wx, wz); - if (parent == null || parent.getFloatingChildBiomes() == null || parent.getFloatingChildBiomes().isEmpty()) { + if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) { continue; } FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler); diff --git a/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java b/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java index 691d6ba22..f116a6cdc 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java @@ -18,7 +18,8 @@ package art.arcane.iris.engine.modifier; -import art.arcane.iris.builtin.floating.FloatingChildBiome; +import art.arcane.iris.builtin.floating.FloatingChildSettings; +import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings; import com.volmit.FeatureRegistry; import art.arcane.iris.builtin.IrisStages; import art.arcane.iris.core.modules.IrisChunk; @@ -50,7 +51,8 @@ public final class FloatingModule implements IrisModule { @Override public void register(FeatureRegistry registry) { - registry.registerHeldType(FloatingChildBiome.class); + registry.registerSettings(FloatingChildSettings.class); + registry.registerSettings(MergeFloatingChildrenSettings.class); } @Override diff --git a/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java b/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java index 6e45f193f..cc98dc82c 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java @@ -20,6 +20,7 @@ package art.arcane.iris.engine.modifier; import art.arcane.iris.builtin.IrisStages; import art.arcane.iris.core.modules.IrisChunk; +import art.arcane.iris.engine.actuator.HiddenOres; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; import art.arcane.iris.engine.object.world.dimension.IrisDimension; @@ -68,7 +69,7 @@ public final class PerfectionModule implements IrisModule { IrisDimension dimension = engine.getDimension(); PrecisionStopwatch stopwatch = PrecisionStopwatch.start(); Hunk blocks = chunk.blocks(); - if (dimension.isHideOresForHiddenOre()) { + if (HiddenOres.in(dimension)) { hideOres(blocks); } boolean removed; diff --git a/src/main/java/art/arcane/iris/engine/modifier/ResolvedDepositVariant.java b/src/main/java/art/arcane/iris/engine/modifier/ResolvedDepositVariant.java new file mode 100644 index 000000000..b1a6dce34 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/ResolvedDepositVariant.java @@ -0,0 +1,66 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.deposit.DepositVariant; +import art.arcane.iris.engine.data.cache.AtomicCache; +import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; +import art.arcane.iris.spi.PlatformBlockState; +import art.arcane.iris.util.common.data.B; + +import java.util.HashMap; +import java.util.Map; + +/** + * One {@link DepositVariant} made ready: its source and replacement block ids resolved to the platform's blocks, built once on + * first use. A rule whose source or replacement the platform does not know remaps nothing. + */ +final class ResolvedDepositVariant { + private final DepositVariant settings; + private final AtomicCache> remapped = new AtomicCache<>(); + + ResolvedDepositVariant(DepositVariant settings) { + this.settings = settings; + } + + boolean appliesAt(int worldY) { + return worldY >= settings.minHeight() && worldY <= settings.maxHeight(); + } + + /** The block {@code ore} is rewritten to, or null when the rule does not remap its material. */ + PlatformBlockState remapOrNull(PlatformBlockState ore) { + if (ore == null || settings.remap().isEmpty()) { + return null; + } + return remapped.aquire(this::resolveRemap).get(IrisProceduralBlocks.materialKey(ore)); + } + + private Map resolveRemap() { + Map resolved = new HashMap<>(); + for (Map.Entry entry : settings.remap().entrySet()) { + PlatformBlockState source = B.getStateOrNull(entry.getKey(), false); + PlatformBlockState target = B.getStateOrNull(entry.getValue(), true); + if (source == null || target == null) { + continue; + } + resolved.put(IrisProceduralBlocks.materialKey(source), target); + } + return resolved; + } +} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/carving/CarvingBands.java b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CarvingBands.java new file mode 100644 index 000000000..916e35316 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CarvingBands.java @@ -0,0 +1,71 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.object.terrain.carving; + +import art.arcane.iris.builtin.carve.CarvingEntry; +import art.arcane.iris.builtin.carve.CarvingSettings; +import art.arcane.iris.engine.framework.Engine; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * What the carve module keeps for one world: the cave biome bands its dimension declares ({@link CarvingSettings}) made ready + * ({@link ResolvedCarvingEntry}), in the order the dimension lists them, and by id. + */ +public final class CarvingBands { + private final List entries; + private final Map index; + + CarvingBands(List declared) { + this.entries = declared.stream().filter(Objects::nonNull).map(ResolvedCarvingEntry::new).toList(); + this.index = indexById(entries); + } + + CarvingBands(Engine engine) { + this(engine.getDimension().getModuleSettings().find(CarvingSettings.class).map(CarvingSettings::entries).orElse(List.of())); + } + + /** The bands of the world {@code engine} generates now. */ + public static CarvingBands of(Engine engine) { + return engine.getGeneration().state(CarvingBands.class, CarvingBands::new); + } + + /** Every declared entry, enabled or not. */ + public List entries() { + return entries; + } + + /** The entries by their trimmed ids; entries without an id are not in it, and the last of several with one id is. */ + public Map index() { + return index; + } + + private static Map indexById(List entries) { + Map index = new HashMap<>(); + for (ResolvedCarvingEntry entry : entries) { + if (!entry.id().isBlank()) { + index.put(entry.id().trim(), entry); + } + } + return Map.copyOf(index); + } +} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/carving/IrisDimensionCarvingResolver.java b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CarvingResolver.java similarity index 69% rename from src/main/java/art/arcane/iris/engine/object/terrain/carving/IrisDimensionCarvingResolver.java rename to src/main/java/art/arcane/iris/engine/object/terrain/carving/CarvingResolver.java index 951b70fe9..a4eb736ed 100644 --- a/src/main/java/art/arcane/iris/engine/object/terrain/carving/IrisDimensionCarvingResolver.java +++ b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CarvingResolver.java @@ -1,14 +1,13 @@ 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 art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.util.project.interpolation.IrisInterpolation; -import art.arcane.volmlib.util.collection.KList; import art.arcane.iris.util.project.noise.CNG; +import com.volmit.config.Range; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -17,36 +16,40 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -public final class IrisDimensionCarvingResolver { +/** + * Picks the dimension's carving entry for a position: the last enabled root entry whose world Y band holds the height, + * then, through the entries' children, the one a noise pattern selects at the column. The state a caller passes (or, when + * it passes none, the thread's) keeps the picks and the entries' biomes, so a caller resolving many positions reuses them. + */ +public final class CarvingResolver { private static final int MAX_CHILD_DEPTH = 32; private static final long CHILD_SEED_SALT = 0x9E3779B97F4A7C15L; private static final ThreadLocal> THREAD_STATE = ThreadLocal.withInitial(() -> new WeakReference<>(null)); - private IrisDimensionCarvingResolver() { + private CarvingResolver() { } - public static IrisDimensionCarvingEntry resolveRootEntry(Engine engine, int worldY) { + public static ResolvedCarvingEntry resolveRootEntry(Engine engine, int worldY) { return resolveRootEntry(engine, worldY, threadState()); } - public static IrisDimensionCarvingEntry resolveRootEntry(Engine engine, int worldY, State state) { + public static ResolvedCarvingEntry resolveRootEntry(Engine engine, int worldY, State state) { State resolvedState = state == null ? threadState() : state; resolvedState.bind(engine); if (resolvedState.rootEntriesByWorldY.containsKey(worldY)) { return resolvedState.rootEntriesByWorldY.get(worldY); } - IrisDimension dimension = engine.getDimension(); - List entries = dimension.getCarving(); - if (entries == null || entries.isEmpty()) { + List entries = resolvedState.bands.entries(); + if (entries.isEmpty()) { resolvedState.rootEntriesByWorldY.put(worldY, null); return null; } - IrisDimensionCarvingEntry resolved = null; - for (IrisDimensionCarvingEntry entry : entries) { + ResolvedCarvingEntry resolved = null; + for (ResolvedCarvingEntry entry : entries) { if (!isRootCandidate(engine, entry, worldY, resolvedState)) { continue; } @@ -58,11 +61,11 @@ public final class IrisDimensionCarvingResolver { return resolved; } - public static IrisDimensionCarvingEntry resolveFromRoot(Engine engine, IrisDimensionCarvingEntry rootEntry, int worldX, int worldZ) { + public static ResolvedCarvingEntry resolveFromRoot(Engine engine, ResolvedCarvingEntry rootEntry, int worldX, int worldZ) { return resolveFromRoot(engine, rootEntry, worldX, worldZ, threadState()); } - public static IrisDimensionCarvingEntry resolveFromRoot(Engine engine, IrisDimensionCarvingEntry rootEntry, int worldX, int worldZ, State state) { + public static ResolvedCarvingEntry resolveFromRoot(Engine engine, ResolvedCarvingEntry rootEntry, int worldX, int worldZ, State state) { State resolvedState = state == null ? threadState() : state; resolvedState.bind(engine); if (rootEntry == null) { @@ -74,22 +77,22 @@ public final class IrisDimensionCarvingResolver { return null; } - int remainingDepth = clampDepth(rootEntry.getChildRecursionDepth()); + int remainingDepth = clampDepth(rootEntry.childRecursionDepth()); if (remainingDepth <= 0) { return rootEntry; } - Map entryIndex = resolveEntryIndex(engine, resolvedState); - IrisDimensionCarvingEntry current = rootEntry; + Map entryIndex = resolvedState.bands.index(); + ResolvedCarvingEntry current = rootEntry; int depth = remainingDepth; while (depth > 0) { - IrisDimensionCarvingEntry selected = selectChild(engine, current, worldX, worldZ, entryIndex, resolvedState); + ResolvedCarvingEntry selected = selectChild(engine, current, worldX, worldZ, entryIndex, resolvedState); if (selected == null || selected == current) { break; } depth--; - int childDepthLimit = clampDepth(selected.getChildRecursionDepth()); + int childDepthLimit = clampDepth(selected.childRecursionDepth()); if (childDepthLimit < depth) { depth = childDepthLimit; } @@ -99,17 +102,17 @@ public final class IrisDimensionCarvingResolver { return current; } - public static IrisBiome resolveEntryBiome(Engine engine, IrisDimensionCarvingEntry entry) { + public static IrisBiome resolveEntryBiome(Engine engine, ResolvedCarvingEntry entry) { return resolveEntryBiome(engine, entry, null); } - public static IrisBiome resolveEntryBiome(Engine engine, IrisDimensionCarvingEntry entry, State state) { + public static IrisBiome resolveEntryBiome(Engine engine, ResolvedCarvingEntry entry, State state) { if (entry == null) { return null; } if (state == null) { - return entry.getRealBiome(engine.getData()); + return entry.realBiome(engine.getData()); } state.bind(engine); @@ -117,17 +120,17 @@ public final class IrisDimensionCarvingResolver { return state.biomeCache.get(entry); } - IrisBiome biome = entry.getRealBiome(engine.getData()); + IrisBiome biome = entry.realBiome(engine.getData()); state.biomeCache.put(entry, biome); return biome; } - private static boolean isRootCandidate(Engine engine, IrisDimensionCarvingEntry entry, int worldY, State state) { - if (entry == null || !entry.isEnabled()) { + private static boolean isRootCandidate(Engine engine, ResolvedCarvingEntry entry, int worldY, State state) { + if (entry == null || !entry.enabled()) { return false; } - IrisRange worldYRange = entry.getWorldYRange(); + Range worldYRange = entry.worldYRange(); if (worldYRange != null && !worldYRange.contains(worldY)) { return false; } @@ -135,16 +138,16 @@ public final class IrisDimensionCarvingResolver { return resolveEntryBiome(engine, entry, state) != null; } - private static IrisDimensionCarvingEntry selectChild( + private static ResolvedCarvingEntry selectChild( Engine engine, - IrisDimensionCarvingEntry parent, + ResolvedCarvingEntry parent, int worldX, int worldZ, - Map entryIndex, + Map entryIndex, State state ) { - KList children = parent.getChildren(); - if (children == null || children.isEmpty()) { + List children = parent.children(); + if (children.isEmpty()) { return parent; } @@ -164,7 +167,7 @@ public final class IrisDimensionCarvingResolver { } long seed = resolveChildSeed(engine, state); - CNG childGenerator = parent.getChildrenGenerator(seed, engine.getData()); + CNG childGenerator = parent.childrenGenerator(seed, engine.getData()); double sample = childGenerator.noiseFast2D(worldX, worldZ); int selectedIndex = (int) Math.round(IrisInterpolation.lerp(0, selectionPlan.maxIndex, sample)); CarvingChoice selected = selectionPlan.get(selectedIndex); @@ -177,31 +180,28 @@ public final class IrisDimensionCarvingResolver { private static ParentSelectionPlan buildSelectionPlan( Engine engine, - IrisDimensionCarvingEntry parent, + ResolvedCarvingEntry parent, IrisBiome parentBiome, - Map entryIndex, + Map entryIndex, State state ) { List options = new ArrayList<>(); - KList children = parent.getChildren(); - if (children != null) { - for (String childId : children) { - if (childId == null || childId.isBlank()) { - continue; - } - - IrisDimensionCarvingEntry child = entryIndex.get(childId.trim()); - if (child == null || !child.isEnabled()) { - continue; - } - - IrisBiome childBiome = resolveEntryBiome(engine, child, state); - if (childBiome == null) { - continue; - } - - options.add(new CarvingChoice(child, rarity(childBiome))); + for (String childId : parent.children()) { + if (childId == null || childId.isBlank()) { + continue; } + + ResolvedCarvingEntry child = entryIndex.get(childId.trim()); + if (child == null || !child.enabled()) { + continue; + } + + IrisBiome childBiome = resolveEntryBiome(engine, child, state); + if (childBiome == null) { + continue; + } + + options.add(new CarvingChoice(child, rarity(childBiome))); } options.add(new CarvingChoice(parent, rarity(parentBiome))); @@ -260,14 +260,6 @@ public final class IrisDimensionCarvingResolver { return Math.min(depth, MAX_CHILD_DEPTH); } - private static Map resolveEntryIndex(Engine engine, State state) { - if (state.entryIndex == null) { - state.entryIndex = engine.getDimension().getCarvingEntryIndex(); - } - - return state.entryIndex; - } - private static long resolveChildSeed(Engine engine, State state) { if (state.childSeed == null) { state.childSeed = engine.getSeedManager().getCarve() ^ CHILD_SEED_SALT; @@ -288,13 +280,13 @@ public final class IrisDimensionCarvingResolver { } public static final class State { - private final Map rootEntriesByWorldY = new HashMap<>(); - private final Map selectionPlans = new IdentityHashMap<>(); - private final Map biomeCache = new IdentityHashMap<>(); + private final Map rootEntriesByWorldY = new HashMap<>(); + private final Map selectionPlans = new IdentityHashMap<>(); + private final Map biomeCache = new IdentityHashMap<>(); private WeakReference engineIdentity; private WeakReference dimensionIdentity; private WeakReference dataIdentity; - private Map entryIndex; + private CarvingBands bands; private Long childSeed; private void bind(Engine engine) { @@ -308,10 +300,10 @@ public final class IrisDimensionCarvingResolver { engineIdentity = new WeakReference<>(engine); dimensionIdentity = new WeakReference<>(dimension); dataIdentity = new WeakReference<>(data); + bands = CarvingBands.of(engine); rootEntriesByWorldY.clear(); selectionPlans.clear(); biomeCache.clear(); - entryIndex = null; childSeed = null; } @@ -359,10 +351,10 @@ public final class IrisDimensionCarvingResolver { } private static final class CarvingChoice implements IRare { - private final IrisDimensionCarvingEntry entry; + private final ResolvedCarvingEntry entry; private final int rarity; - private CarvingChoice(IrisDimensionCarvingEntry entry, int rarity) { + private CarvingChoice(ResolvedCarvingEntry entry, int rarity) { this.entry = entry; this.rarity = rarity; } diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java new file mode 100644 index 000000000..55628bb16 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java @@ -0,0 +1,33 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.object.terrain.carving; + +import art.arcane.iris.builtin.carve.CaveProfile; +import art.arcane.iris.core.loader.IrisRegistrant; + +/** The cave profiles dimensions, regions and biomes declare ({@code caveProfile}). */ +public final class CaveProfiles { + private CaveProfiles() { + } + + /** The profile {@code owner}, a dimension, region or biome, declares; null when it declares none, which is as good as one that is not enabled. */ + public static CaveProfile declaredBy(IrisRegistrant owner) { + return owner.getModuleSettings().find(CaveProfile.class).orElse(null); + } +} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/carving/IrisDimensionCarvingEntry.java b/src/main/java/art/arcane/iris/engine/object/terrain/carving/IrisDimensionCarvingEntry.java deleted file mode 100644 index 6256fc281..000000000 --- a/src/main/java/art/arcane/iris/engine/object/terrain/carving/IrisDimensionCarvingEntry.java +++ /dev/null @@ -1,84 +0,0 @@ -package art.arcane.iris.engine.object.terrain.carving; - -import art.arcane.iris.engine.object.noise.IrisGeneratorStyle; -import art.arcane.iris.engine.object.noise.NoiseStyle; -import art.arcane.iris.engine.object.value.IrisRange; -import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.core.loader.IrisData; -import art.arcane.iris.engine.data.cache.AtomicCache; -import art.arcane.iris.engine.object.annotations.ArrayType; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.DependsOn; -import art.arcane.iris.engine.object.annotations.RegistryListResource; -import art.arcane.iris.engine.object.annotations.Snippet; -import art.arcane.iris.util.project.noise.CNG; -import art.arcane.volmlib.util.collection.KList; -import art.arcane.volmlib.util.math.RNG; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@Snippet("dimension-carving-entry") -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("Dimension-level cave biome override with absolute world Y bounds.") -@Data -public class IrisDimensionCarvingEntry { - private final transient AtomicCache realBiome = new AtomicCache<>(true); - private final transient Map childGenerators = new ConcurrentHashMap<>(); - - @Desc("Stable id for this carving entry") - private String id = ""; - - @Desc("Enable or disable this carving entry") - private boolean enabled = true; - - @RegistryListResource(IrisBiome.class) - @Desc("Cave biome to apply when world Y falls within worldYRange") - private String biome = ""; - - @Desc("Absolute world Y bounds where this carving entry applies") - private IrisRange worldYRange = new IrisRange(-64, 320); - - @DependsOn({"children"}) - @Desc("If this carving entry has child carving entries, this controls how small those child carving patches are.") - private double childShrinkFactor = 1.5; - - @DependsOn({"children"}) - @Desc("If this carving entry has child carving entries, this controls the shape pattern used to pick them.") - private IrisGeneratorStyle childStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); - - @ArrayType(min = 1, type = String.class) - @Desc("Child carving entry ids. Child ids can point back to parent ids to create cycles; recursion is bounded by childRecursionDepth.") - private KList children = new KList<>(); - - @Desc("Maximum recursion depth when resolving child carving entries from this entry.") - private int childRecursionDepth = 3; - - public IrisBiome getRealBiome(IrisData data) { - return realBiome.aquire(() -> { - String biomeKey = getBiome(); - if (biomeKey == null || biomeKey.isBlank()) { - return null; - } - - return data.getBiomeLoader().load(biomeKey.trim()); - }); - } - - public CNG getChildrenGenerator(long seed, IrisData data) { - String entryId = getId(); - long idHash = entryId == null ? 0L : entryId.trim().hashCode(); - long generatorSeed = seed ^ (idHash << 32) ^ 2137L; - return childGenerators.computeIfAbsent(generatorSeed, key -> { - double scale = Math.max(0.0001D, getChildShrinkFactor()); - RNG random = new RNG(key); - return getChildStyle().create(random.nextParallelRNG(2137), data).bake().scale(scale).bake(); - }); - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/carving/ResolvedCarvingEntry.java b/src/main/java/art/arcane/iris/engine/object/terrain/carving/ResolvedCarvingEntry.java new file mode 100644 index 000000000..fc880344d --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/object/terrain/carving/ResolvedCarvingEntry.java @@ -0,0 +1,101 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.object.terrain.carving; + +import art.arcane.iris.builtin.carve.CarvingEntry; +import art.arcane.iris.core.loader.IrisData; +import art.arcane.iris.core.modules.IrisValues; +import art.arcane.iris.engine.data.cache.AtomicCache; +import art.arcane.iris.engine.object.noise.IrisGeneratorStyle; +import art.arcane.iris.engine.object.world.biome.IrisBiome; +import art.arcane.iris.util.project.noise.CNG; +import art.arcane.volmlib.util.math.RNG; +import com.volmit.config.Range; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * One {@link CarvingEntry} made ready for one world: the biome it names, loaded from the pack when first asked for, and the + * noise that splits it into child entries, built once per seed. What the entry describes stays in the settings. + */ +public final class ResolvedCarvingEntry { + private static final long CHILD_GENERATOR_SALT = 2137L; + private static final int CHILD_GENERATOR_SIGNATURE = 2137; + private static final double MIN_CHILD_SCALE = 0.0001D; + + private final CarvingEntry settings; + private final IrisGeneratorStyle childStyle; + private final AtomicCache realBiome = new AtomicCache<>(true); + private final Map childGenerators = new ConcurrentHashMap<>(); + + ResolvedCarvingEntry(CarvingEntry settings) { + this.settings = settings; + this.childStyle = IrisValues.generatorStyle(settings.childStyle()); + } + + public String id() { + return settings.id(); + } + + public boolean enabled() { + return settings.enabled(); + } + + /** The biome key the entry names, as the pack wrote it. */ + public String biomeKey() { + return settings.biome(); + } + + public Range worldYRange() { + return settings.worldYRange(); + } + + public List children() { + return settings.children(); + } + + public int childRecursionDepth() { + return settings.childRecursionDepth(); + } + + /** The pack biome the entry names; null when it names none or the pack has no such biome. */ + public IrisBiome realBiome(IrisData data) { + return realBiome.aquire(() -> { + String biomeKey = settings.biome(); + if (biomeKey.isBlank()) { + return null; + } + + return data.getBiomeLoader().load(biomeKey.trim()); + }); + } + + /** The noise that picks between the entry and its children, seeded by {@code seed} and the entry's id. */ + public CNG childrenGenerator(long seed, IrisData data) { + long idHash = settings.id().trim().hashCode(); + long generatorSeed = seed ^ (idHash << 32) ^ CHILD_GENERATOR_SALT; + return childGenerators.computeIfAbsent(generatorSeed, key -> { + double scale = Math.max(MIN_CHILD_SCALE, settings.childShrinkFactor()); + RNG random = new RNG(key); + return childStyle.create(random.nextParallelRNG(CHILD_GENERATOR_SIGNATURE), data).bake().scale(scale).bake(); + }); + } +} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisBiomeOres.java b/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisBiomeOres.java deleted file mode 100644 index 1473d3b1b..000000000 --- a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisBiomeOres.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.object.terrain.deposit; - -import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.core.loader.IrisData; -import art.arcane.iris.engine.data.cache.AtomicCache; -import art.arcane.iris.spi.PlatformBlockState; -import art.arcane.volmlib.util.collection.KList; -import art.arcane.volmlib.util.math.RNG; - -/** - * Ore generation for {@link IrisBiome}. IrisBiome is Gson deserialized from pack JSON, so its - * fields stay put and only the behavior lives here. Note that {@code IrisBiome.setOres(KList)} - * stays on IrisBiome: it is a hand written Lombok setter override that resets these caches. - */ -public final class IrisBiomeOres { - private IrisBiomeOres() { - } - - public static PlatformBlockState generateOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data, boolean surface) { - KList localOres = surface ? getSurfaceOres(biome) : getUndergroundOres(biome); - return generateOres(localOres, x, y, z, rng, data); - } - - public static PlatformBlockState generateSurfaceOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) { - return generateOres(getSurfaceOres(biome), x, y, z, rng, data); - } - - public static PlatformBlockState generateUndergroundOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) { - return generateOres(getUndergroundOres(biome), x, y, z, rng, data); - } - - public static boolean hasSurfaceOres(IrisBiome biome) { - return !getSurfaceOres(biome).isEmpty(); - } - - public static boolean hasUndergroundOres(IrisBiome biome) { - return !getUndergroundOres(biome).isEmpty(); - } - - public static KList getSurfaceOreGenerators(IrisBiome biome) { - return getOres(biome, true); - } - - public static KList getUndergroundOreGenerators(IrisBiome biome) { - return getOres(biome, false); - } - - public static IrisOreGeneratorBounds getSurfaceOreGeneratorBounds(IrisBiome biome) { - // getIfPresent fast path: aquire allocates a capturing lambda even on a hit, and this - // runs per column on the terrain hot path. - IrisOreGeneratorBounds cached = biome.getSurfaceOreBoundsCache().getIfPresent(); - if (cached != null) { - return cached; - } - return biome.getSurfaceOreBoundsCache().aquire(() -> IrisOreGeneratorBounds.of(getSurfaceOres(biome))); - } - - public static IrisOreGeneratorBounds getUndergroundOreGeneratorBounds(IrisBiome biome) { - IrisOreGeneratorBounds cached = biome.getUndergroundOreBoundsCache().getIfPresent(); - if (cached != null) { - return cached; - } - return biome.getUndergroundOreBoundsCache().aquire(() -> IrisOreGeneratorBounds.of(getUndergroundOres(biome))); - } - - private static KList getSurfaceOres(IrisBiome biome) { - return getOres(biome, true); - } - - private static KList getUndergroundOres(IrisBiome biome) { - return getOres(biome, false); - } - - private static KList getOres(IrisBiome biome, boolean surface) { - AtomicCache> oreCache = surface ? biome.getSurfaceOreCache() : biome.getUndergroundOreCache(); - KList cached = oreCache.getIfPresent(); - - if (cached != null) { - return cached; - } - - return oreCache.aquire(() -> { - KList filtered = new KList<>(); - KList localOres = biome.getOres(); - int oreCount = localOres.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = localOres.get(oreIndex); - if (oreGenerator.isGenerateSurface() == surface) { - filtered.add(oreGenerator); - } - } - - return filtered; - }); - } - - private static PlatformBlockState generateOres(KList localOres, int x, int y, int z, RNG rng, IrisData data) { - if (localOres.isEmpty()) { - return null; - } - - int oreCount = localOres.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = localOres.get(oreIndex); - PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data); - if (ore != null) { - return ore; - } - } - return null; - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisDepositVariant.java b/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisDepositVariant.java deleted file mode 100644 index 966a751d1..000000000 --- a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisDepositVariant.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.object.terrain.deposit; - -import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; -import art.arcane.iris.core.loader.IrisData; -import art.arcane.iris.engine.data.cache.AtomicCache; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.MaxNumber; -import art.arcane.iris.engine.object.annotations.MinNumber; -import art.arcane.iris.engine.object.annotations.Required; -import art.arcane.iris.engine.object.annotations.Snippet; -import art.arcane.volmlib.util.collection.KMap; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import art.arcane.iris.spi.PlatformBlockState; -import art.arcane.iris.util.common.data.B; -import lombok.experimental.Accessors; - -@Snippet("deposit-variant") -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("Remaps ore block ids to alternate block ids within a vertical band. Ores declared at dimension, region, and biome scope can be rewritten at placement time (for example, iron_ore -> deepslate_iron_ore inside a deep carving band, or yourmod:iron -> yourmod:moon_iron inside a lunar biome).") -@Data -public class IrisDepositVariant { - private final transient AtomicCache> resolved = new AtomicCache<>(); - - @Required - @MinNumber(-2048) - @MaxNumber(8192) - @Desc("Inclusive minimum world Y this variant applies at.") - private int minHeight = 0; - - @Required - @MinNumber(-2048) - @MaxNumber(8192) - @Desc("Inclusive maximum world Y this variant applies at.") - private int maxHeight = 0; - - @Required - @Desc("Source block id (for example `minecraft:iron_ore`) -> replacement block id (for example `minecraft:deepslate_iron_ore`). Any block id the data loader resolves is accepted, including external/mod blocks. Source match is by material only, so block properties on the source key are ignored.") - private KMap remap = new KMap<>(); - - public PlatformBlockState remapOrNull(PlatformBlockState ore, IrisData rdata) { - if (ore == null || remap == null || remap.isEmpty()) { - return null; - } - - KMap map = resolved.aquire(() -> buildResolved(rdata)); - return map.get(IrisProceduralBlocks.materialKey(ore)); - } - - private KMap buildResolved(IrisData rdata) { - KMap out = new KMap<>(); - - for (java.util.Map.Entry entry : remap.entrySet()) { - PlatformBlockState source = B.getStateOrNull(entry.getKey(), false); - PlatformBlockState target = B.getStateOrNull(entry.getValue(), true); - - if (source == null || target == null) { - continue; - } - - out.put(IrisProceduralBlocks.materialKey(source), target); - } - - return out; - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisOreGenerator.java b/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisOreGenerator.java deleted file mode 100644 index ed5e9502e..000000000 --- a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisOreGenerator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.object.terrain.deposit; - -import art.arcane.iris.engine.object.material.IrisMaterialPalette; -import art.arcane.iris.engine.object.noise.IrisGeneratorStyle; -import art.arcane.iris.engine.object.noise.NoiseStyle; -import art.arcane.iris.engine.object.value.IrisRange; -import art.arcane.iris.core.loader.IrisData; -import art.arcane.iris.engine.data.cache.AtomicCache; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.MaxNumber; -import art.arcane.iris.engine.object.annotations.MinNumber; -import art.arcane.volmlib.util.math.RNG; -import art.arcane.iris.util.project.noise.CNG; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import art.arcane.iris.spi.PlatformBlockState; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("Scatters single ore blocks through terrain by sampling a noise field at every block in a vertical band. Defined on dimensions, regions, or biomes; the most specific level wins.") -@Data -public class IrisOreGenerator { - @Desc("The ore blocks to place. An empty palette generates nothing, so this must be set for the generator to have any effect.") - private IrisMaterialPalette palette = new IrisMaterialPalette().qclear(); - @Desc("The noise style sampled per block to decide where ore appears. STATIC gives independent random speckle; smoother styles give veiny clusters.") - private IrisGeneratorStyle chanceStyle = new IrisGeneratorStyle(NoiseStyle.STATIC); - @Desc("When true this generator also replaces surface-layer blocks (it runs before layers and fluid); when false it only replaces underground rock.") - private boolean generateSurface = false; - @MinNumber(0) - @MaxNumber(1) - @Desc("Noise cutoff: a block becomes ore when the sampled noise is at or below this value, so higher means more ore. 0 disables, 1 replaces everything in range.") - private double threshold = 0.5; - @Desc("Vertical band (min, max) this ore can generate in, in engine-local Y where 0 is the bottom of the dimension, not world Y.") - private IrisRange range = new IrisRange(30, 80); - - private transient AtomicCache chanceCache = new AtomicCache<>(); - - public void warm(RNG rng, IrisData data) { - chanceCache.aquire(() -> chanceStyle.create(rng, data)); - palette.getLayerGenerator(rng, data); - } - - public PlatformBlockState generate(int x, int y, int z, RNG rng, IrisData data) { - if (!range.contains(y)) { - return null; - } - - if (palette.getPalette().isEmpty()) { - return null; - } - - CNG chance = chanceCache.aquire(() -> chanceStyle.create(rng, data)); - - if (chance.noise(x, y, z) > threshold) { - return null; - } - - return palette.get(rng, x, y, z, data); - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisOreGeneratorBounds.java b/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisOreGeneratorBounds.java deleted file mode 100644 index aea87f2c0..000000000 --- a/src/main/java/art/arcane/iris/engine/object/terrain/deposit/IrisOreGeneratorBounds.java +++ /dev/null @@ -1,44 +0,0 @@ -package art.arcane.iris.engine.object.terrain.deposit; - -import art.arcane.iris.engine.object.value.IrisRange; -import art.arcane.volmlib.util.collection.KList; - -public final class IrisOreGeneratorBounds { - public static final IrisOreGeneratorBounds EMPTY = new IrisOreGeneratorBounds(false, 0D, 0D); - - private final boolean hasOres; - private final double min; - private final double max; - - private IrisOreGeneratorBounds(boolean hasOres, double min, double max) { - this.hasOres = hasOres; - this.min = min; - this.max = max; - } - - public static IrisOreGeneratorBounds of(KList ores) { - if (ores == null || ores.isEmpty()) { - return EMPTY; - } - - double min = Double.POSITIVE_INFINITY; - double max = Double.NEGATIVE_INFINITY; - int oreCount = ores.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = ores.get(oreIndex); - IrisRange range = oreGenerator.getRange(); - min = Math.min(min, range.getMin()); - max = Math.max(max, range.getMax()); - } - - return new IrisOreGeneratorBounds(true, min, max); - } - - public boolean hasOres() { - return hasOres; - } - - public boolean contains(int y) { - return hasOres && y >= min && y <= max; - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildren.java b/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildren.java index 2a7492f4c..dd2ad533e 100644 --- a/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildren.java +++ b/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingChildren.java @@ -19,8 +19,11 @@ package art.arcane.iris.engine.object.terrain.floating; 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.core.loader.IrisData; import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.object.world.biome.IrisBiome; import java.util.List; import java.util.Map; @@ -46,6 +49,16 @@ public final class FloatingChildren { return engine.getGeneration().state(FloatingChildren.class, FloatingChildren::new); } + /** The floating children {@code biome} declares, in the order it lists them; none when it declares none. */ + public static List declaredBy(IrisBiome biome) { + return biome.getModuleSettings().find(FloatingChildSettings.class).map(FloatingChildSettings::children).orElse(List.of()); + } + + /** Whether {@code biome} samples every floating child on its own and unions their islands instead of picking one per column. */ + public static boolean merges(IrisBiome biome) { + return biome.getModuleSettings().find(MergeFloatingChildrenSettings.class).map(MergeFloatingChildrenSettings::merge).orElse(false); + } + public ResolvedFloatingChild of(FloatingChildBiome settings) { return resolved.computeIfAbsent(settings, ResolvedFloatingChild::new); } diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSample.java b/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSample.java index 7fc7b6f1c..ae339e57f 100644 --- a/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSample.java +++ b/src/main/java/art/arcane/iris/engine/object/terrain/floating/FloatingIslandSample.java @@ -196,8 +196,8 @@ public final class FloatingIslandSample { } public static FloatingIslandSample sample(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) { - List settings = parent.getFloatingChildBiomes(); - if (settings == null || settings.isEmpty()) { + List settings = FloatingChildren.declaredBy(parent); + if (settings.isEmpty()) { return reject(REJECT_NO_ENTRIES); } KList entries = new KList<>(FloatingChildren.of(data).of(settings)); @@ -208,7 +208,7 @@ public final class FloatingIslandSample { int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, data, parent); int parentBoundaryDistance = boundarySampler.edgeDistance(parent, wx, wz, boundaryFieldWidth); - if (parent.isMergeFloatingChildBiomes()) { + if (FloatingChildren.merges(parent)) { return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler, parentBoundaryDistance, boundaryFieldWidth); } diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChild.java b/src/main/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChild.java index e50ec5226..518bb6fbc 100644 --- a/src/main/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChild.java +++ b/src/main/java/art/arcane/iris/engine/object/terrain/floating/ResolvedFloatingChild.java @@ -18,20 +18,22 @@ package art.arcane.iris.engine.object.terrain.floating; +import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.builtin.floating.FloatingChildBiome; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.core.modules.IrisValues; import art.arcane.iris.engine.data.cache.AtomicCache; import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.object.terrain.carving.CaveProfiles; import art.arcane.iris.engine.object.noise.IrisGeneratorStyle; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.engine.object.prefab.IrisObjectScale; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver; +import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry; +import art.arcane.iris.engine.object.terrain.carving.CarvingBands; +import art.arcane.iris.engine.object.terrain.carving.CarvingResolver; import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfileSampler; import art.arcane.iris.engine.object.value.IRare; import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.engine.object.world.dimension.IrisDimension; import art.arcane.iris.util.project.noise.CNG; import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.math.RNG; @@ -137,11 +139,12 @@ public final class ResolvedFloatingChild implements IRare { return carvingProfileSamplerCache.aquire(() -> { IrisBiome resolved = resolveCarvingBiome(settings.carving(), engine, data); - if (resolved == null || resolved.getCaveProfile() == null || !resolved.getCaveProfile().enabled()) { + CaveProfile profile = resolved == null ? null : CaveProfiles.declaredBy(resolved); + if (profile == null || !profile.enabled()) { return null; } - return new IrisCaveProfileSampler(engine, resolved.getCaveProfile()); + return new IrisCaveProfileSampler(engine, profile); }); } @@ -155,12 +158,9 @@ public final class ResolvedFloatingChild implements IRare { return null; } - IrisDimension dimension = engine.getDimension(); - if (dimension != null && dimension.getCarvingEntryIndex() != null) { - IrisDimensionCarvingEntry entry = dimension.getCarvingEntryIndex().get(carving); - if (entry != null) { - return IrisDimensionCarvingResolver.resolveEntryBiome(engine, entry); - } + ResolvedCarvingEntry entry = CarvingBands.of(engine).index().get(carving); + if (entry != null) { + return CarvingResolver.resolveEntryBiome(engine, entry); } if (data.getBiomeLoader() == null) { diff --git a/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java b/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java index aaca52db8..a664fa1b2 100644 --- a/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java +++ b/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java @@ -18,8 +18,6 @@ package art.arcane.iris.engine.object.world.biome; -import art.arcane.iris.builtin.floating.FloatingChildBiome; -import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.engine.object.entity.IrisEffect; import art.arcane.iris.engine.object.entity.spawn.IrisSpawner; import art.arcane.iris.engine.object.loot.IrisBlockDrops; @@ -29,10 +27,6 @@ import art.arcane.iris.engine.object.noise.NoiseStyle; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.engine.object.procedural.IrisProceduralObjects; import art.arcane.iris.engine.object.structure.IrisStructurePlacement; -import art.arcane.iris.engine.object.terrain.deposit.IrisBiomeOres; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; import art.arcane.iris.engine.object.value.IRare; import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom; import art.arcane.iris.engine.object.world.dimension.IrisDimension; @@ -76,7 +70,7 @@ import java.util.Objects; * Represents a biome in a pack. This type is Gson deserialized straight out of user pack JSON, so * the field block and the transient {@link AtomicCache} block below are load bearing and must not * move. Behavior lives in the same-package companions: - * {@link IrisBiomeDerivatives}, {@link IrisBiomeOres}, + * {@link IrisBiomeDerivatives}, * {@link IrisBiomeColorRenderer} and {@link IrisBiomeGenLinks}. */ @Accessors(chain = true) @@ -104,12 +98,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) private transient volatile SeededBiomeGenerator recentBiomeGenerator; - private final transient AtomicCache realCarveBiome = new AtomicCache<>(); private final transient AtomicCache> realChildren = new AtomicCache<>(); - private final transient AtomicCache> surfaceOreCache = new AtomicCache<>(); - private final transient AtomicCache> undergroundOreCache = new AtomicCache<>(); - private final transient AtomicCache surfaceOreBoundsCache = new AtomicCache<>(); - private final transient AtomicCache undergroundOreBoundsCache = new AtomicCache<>(); private final transient AtomicCache derivativeResolved = new AtomicCache<>(); private final transient AtomicCache vanillaDerivativeResolved = new AtomicCache<>(); private final transient AtomicCache> biomeScatterResolved = new AtomicCache<>(); @@ -136,8 +125,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { private KList blockDrops = new KList<>(); @Desc("Reference loot tables in this area") private IrisLootReference loot = new IrisLootReference(); - @Desc("Profile-driven 3D cave configuration") - private CaveProfile caveProfile = new CaveProfile(); @MinNumber(1) @MaxNumber(512) @Desc("The rarity of this biome (integer)") @@ -170,13 +157,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = String.class) @Desc("List any biome names (file names without.json) here as children. Portions of this biome can sometimes morph into their children. Iris supports cyclic relationships such as A > B > A > B. Iris will stop checking 4 biomes down the tree.") private KList children = new KList<>(); - @RegistryListResource(IrisBiome.class) - @Desc("Registers the referenced biome with this pack's reachable biome set. It is NOT applied as a substitute under carvings; cave biomes come from the region's caveBiomes list.") - private String carvingBiome = ""; - @MinNumber(0) - @MaxNumber(256) - @Desc("Minimum depth below terrain surface required before this cave biome can be selected.") - private int caveMinDepthBelowSurface = 0; @ArrayType(min = 1, type = IrisObjectPlacement.class) @Desc("Objects define what schematics (iob files) iris will place in this biome") private KList objects = new KList<>(); @@ -185,52 +165,13 @@ public class IrisBiome extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = IrisStructurePlacement.class) @Desc("Structures define jigsaw or vanilla/datapack structures iris will place in this biome") private KList structures = new KList<>(); - @ArrayType(min = 1, type = FloatingChildBiome.class) - @Desc("Floating child biomes that procedurally generate above this biome's terrain. Each entry references a target biome whose layers, decorators, and objects drive the floating island's visual design, while the config here drives size, shape, altitude, rarity, and water level. Multiple entries are supported and selected by rarity per column unless mergeFloatingChildBiomes is enabled.") - private KList floatingChildBiomes = new KList<>(); - @Desc("When true, every floating child entry is sampled independently and their solid masks are unioned, so multiple floating islands can stack, overlap, and collide instead of the picker choosing only one child per column.") - private boolean mergeFloatingChildBiomes = false; @ArrayType(min = 1, type = IrisBiomeGeneratorLink.class) @Desc("Generators for this biome. Multiple generators with different interpolation sizes will mix with other biomes how you would expect. This defines your biome height relative to the fluid height. Use negative for oceans.") private KList generators = new KList().qadd(new IrisBiomeGeneratorLink()); - @MinNumber(0) - @MaxNumber(1) - @Desc("Multiplier applied to the frequency of every ore deposit whose center is inside this biome. A value of 0.4 keeps 40% of ore veins while leaving non-ore deposits unchanged.") - private double oreDepositFrequencyMultiplier = 1D; - @MinNumber(0.01) - @MaxNumber(16) - @Desc("Multiplier applied to the block count of every ore deposit whose center is inside this biome. Non-ore deposits are unchanged.") - private double oreDepositSizeMultiplier = 1D; - @ArrayType(min = 1, type = IrisDepositVariant.class) - @Desc("Deposit ore remap rules scoped to this biome. Each entry declares a vertical band and a source->replacement block id map. Applied before regional and dimension rules; first matching biome rule wins.") - private KList depositVariants = new KList<>(); private transient volatile InferredType inferredType; @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) private final transient EnumMap inferredVariants = new EnumMap<>(InferredType.class); - @Desc("Collection of ores to be generated") - @ArrayType(type = IrisOreGenerator.class, min = 1) - private KList ores = new KList<>(); - - public PlatformBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) { - return IrisBiomeOres.generateOres(this, x, y, z, rng, data, surface); - } - - public PlatformBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) { - return IrisBiomeOres.generateSurfaceOres(this, x, y, z, rng, data); - } - - public PlatformBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) { - return IrisBiomeOres.generateUndergroundOres(this, x, y, z, rng, data); - } - - public boolean hasSurfaceOres() { - return IrisBiomeOres.hasSurfaceOres(this); - } - - public boolean hasUndergroundOres() { - return IrisBiomeOres.hasUndergroundOres(this); - } public synchronized IrisBiome setInferredType(InferredType inferredType) { this.inferredType = inferredType; @@ -274,34 +215,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { return variant; } - /** - * Hand written override of the Lombok setter. It must stay here because it invalidates the ore - * caches that {@link IrisBiomeOres} reads. - */ - public void setOres(KList ores) { - this.ores = ores == null ? new KList<>() : ores; - surfaceOreCache.reset(); - undergroundOreCache.reset(); - surfaceOreBoundsCache.reset(); - undergroundOreBoundsCache.reset(); - } - - public KList getSurfaceOreGenerators() { - return IrisBiomeOres.getSurfaceOreGenerators(this); - } - - public KList getUndergroundOreGenerators() { - return IrisBiomeOres.getUndergroundOreGenerators(this); - } - - public IrisOreGeneratorBounds getSurfaceOreGeneratorBounds() { - return IrisBiomeOres.getSurfaceOreGeneratorBounds(this); - } - - public IrisOreGeneratorBounds getUndergroundOreGeneratorBounds() { - return IrisBiomeOres.getUndergroundOreGeneratorBounds(this); - } - public Biome getDerivative() { Biome cached = derivativeResolved.getIfPresent(); @@ -367,19 +280,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { return IrisBiomeGenLinks.getGenLink(this, loadKey); } - public IrisBiome getRealCarvingBiome(IrisData data) { - return realCarveBiome.aquire(() -> - { - IrisBiome biome = data.getBiomeLoader().load(getCarvingBiome()); - - if (biome == null) { - biome = this; - } - - return biome; - }); - } - public KList getSurfaceObjects() { return getSurfaceObjectsCache().aquire(() -> { diff --git a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java b/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java index 591b46744..8049d835c 100644 --- a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java +++ b/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java @@ -18,8 +18,6 @@ package art.arcane.iris.engine.object.world.dimension; -import art.arcane.iris.builtin.floating.FloatingChildBiome; -import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.engine.object.decoration.IrisImportedFeatureControl; import art.arcane.iris.engine.object.entity.spawn.IrisSpawner; import art.arcane.iris.engine.object.image.IrisImageMap; @@ -33,10 +31,6 @@ import art.arcane.iris.engine.object.noise.NoiseStyle; import art.arcane.iris.engine.object.procedural.tree.IrisTreeSettings; import art.arcane.iris.engine.object.runtime.StudioMode; import art.arcane.iris.engine.object.structure.IrisStructurePlacement; -import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; import art.arcane.iris.engine.object.value.IrisRange; import art.arcane.iris.engine.object.world.IrisEnvironment; import art.arcane.iris.engine.object.world.IrisWorldBoundary; @@ -47,7 +41,6 @@ import art.arcane.iris.engine.object.world.region.IrisRegion; import art.arcane.iris.core.IrisDatapackCompiler.DimensionHeight; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.spi.IrisLogging; -import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.core.loader.IrisRegistrant; import art.arcane.iris.core.nms.datapack.DataVersion; import art.arcane.iris.core.nms.datapack.IDataFixer; @@ -86,7 +79,6 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.ArrayDeque; import java.util.Deque; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Locale; @@ -112,11 +104,6 @@ public class IrisDimension extends IrisRegistrant { private final transient AtomicCache cosr = new AtomicCache<>(); private final transient AtomicCache rad = new AtomicCache<>(); private final transient AtomicCache featuresUsed = new AtomicCache<>(); - private final transient AtomicCache> carvingEntryIndex = new AtomicCache<>(); - private final transient AtomicCache> surfaceOreCache = new AtomicCache<>(); - private final transient AtomicCache> undergroundOreCache = new AtomicCache<>(); - private final transient AtomicCache surfaceOreBoundsCache = new AtomicCache<>(); - private final transient AtomicCache undergroundOreBoundsCache = new AtomicCache<>(); @MinNumber(2) @Required @Desc("The human readable name of this dimension") @@ -175,15 +162,6 @@ public class IrisDimension extends IrisRegistrant { private boolean debugSmartBore = false; @Desc("Generate decorations or not") private boolean decorate = true; - @Desc("When true, every ore block the generator would place (terrain ores, deposits, ores inside objects) is replaced with its base material such as stone, deepslate or netherrack, so drop-control plugins like HiddenOre can manage ore rewards themselves") - private boolean hideOresForHiddenOre = false; - @Desc("Enable or disable all carving for this dimension") - private boolean carvingEnabled = true; - @ArrayType(type = IrisDimensionCarvingEntry.class, min = 1) - @Desc("Dimension-level cave biome carving overrides with absolute world Y ranges") - private KList carving = new KList<>(); - @Desc("Profile-driven 3D cave configuration") - private CaveProfile caveProfile = new CaveProfile(); @Desc("Refuse to place surface objects and trees over carved surface openings.") private boolean requireObjectSurfaceSupport = true; @MinNumber(0) @@ -268,15 +246,9 @@ public class IrisDimension extends IrisRegistrant { private boolean useMantle = true; @Desc("Prevent Leaf decay as if placed in creative mode") private boolean preventLeafDecay = false; - @ArrayType(min = 1, type = IrisDepositVariant.class) - @Desc("Dimension-wide deposit ore remap rules. Each entry declares a vertical band and a source->replacement block id map. Applied after biome and region rules; first matching dimension rule wins.") - private KList depositVariants = new KList<>(); @ArrayType(min = 1, type = IrisShapedGeneratorStyle.class) @Desc("Overlay additional noise on top of the interoplated terrain.") private KList overlayNoise = new KList<>(); - @Desc("Collection of ores to be generated") - @ArrayType(type = IrisOreGenerator.class, min = 1) - private KList ores = new KList<>(); @Desc("Dimension-wide Iris structure placements, independent of biome/region placements") @ArrayType(type = IrisStructurePlacement.class, min = 1) private KList structures = new KList<>(); @@ -302,122 +274,6 @@ public class IrisDimension extends IrisRegistrant { return (int) getDimensionHeight().getMin(); } - public Map getCarvingEntryIndex() { - return carvingEntryIndex.aquire(() -> { - Map index = new HashMap<>(); - KList entries = getCarving(); - if (entries == null || entries.isEmpty()) { - return index; - } - - for (IrisDimensionCarvingEntry entry : entries) { - if (entry == null) { - continue; - } - - String entryId = entry.getId(); - if (entryId == null || entryId.isBlank()) { - continue; - } - - index.put(entryId.trim(), entry); - } - - return index; - }); - } - - public void setCarving(KList carving) { - this.carving = carving == null ? new KList<>() : carving; - carvingEntryIndex.reset(); - } - - public PlatformBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) { - KList localOres = surface ? getSurfaceOres() : getUndergroundOres(); - return generateOres(localOres, x, y, z, rng, data); - } - - public PlatformBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) { - return generateOres(getSurfaceOres(), x, y, z, rng, data); - } - - public PlatformBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) { - return generateOres(getUndergroundOres(), x, y, z, rng, data); - } - - public boolean hasSurfaceOres() { - return !getSurfaceOres().isEmpty(); - } - - public boolean hasUndergroundOres() { - return !getUndergroundOres().isEmpty(); - } - - private PlatformBlockState generateOres(KList localOres, int x, int y, int z, RNG rng, IrisData data) { - if (localOres.isEmpty()) { - return null; - } - - int oreCount = localOres.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = localOres.get(oreIndex); - PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data); - if (ore != null) { - return ore; - } - } - return null; - } - - public void setOres(KList ores) { - this.ores = ores == null ? new KList<>() : ores; - surfaceOreCache.reset(); - undergroundOreCache.reset(); - surfaceOreBoundsCache.reset(); - undergroundOreBoundsCache.reset(); - } - - public KList getSurfaceOreGenerators() { - return getOres(true); - } - - public KList getUndergroundOreGenerators() { - return getOres(false); - } - - public IrisOreGeneratorBounds getSurfaceOreGeneratorBounds() { - return surfaceOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getSurfaceOres())); - } - - public IrisOreGeneratorBounds getUndergroundOreGeneratorBounds() { - return undergroundOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getUndergroundOres())); - } - - private KList getSurfaceOres() { - return getOres(true); - } - - private KList getUndergroundOres() { - return getOres(false); - } - - private KList getOres(boolean surface) { - AtomicCache> oreCache = surface ? surfaceOreCache : undergroundOreCache; - return oreCache.aquire(() -> { - KList filtered = new KList<>(); - KList localOres = ores; - int oreCount = localOres.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = localOres.get(oreIndex); - if (oreGenerator.isGenerateSurface() == surface) { - filtered.add(oreGenerator); - } - } - - return filtered; - }); - } - public int getFluidHeight() { return fluidHeight - (int) dimensionHeight.getMin(); } @@ -539,17 +395,9 @@ public class IrisDimension extends IrisRegistrant { } } - KList carvingEntries = getCarving(); - if (carvingEntries != null) { - for (IrisDimensionCarvingEntry entry : carvingEntries) { - if (entry != null && entry.isEnabled()) { - addReachableBiomeKey(pending, entry.getBiome()); - } - } - } + addReachableBiomeKeys(pending, getModuleSettings().usedBiomes(getModuleSettings())); Set visited = new HashSet<>(); - Map carvingEntryIndex = getCarvingEntryIndex(); while (!pending.isEmpty()) { String biomeKey = pending.removeFirst(); if (!visited.add(biomeKey)) { @@ -569,20 +417,8 @@ public class IrisDimension extends IrisRegistrant { visited.add(loadKey); biomes.put(loadKey, biome); addReachableBiomeKeys(pending, biome.getChildren()); - addReachableBiomeKey(pending, biome.getCarvingBiome()); - KList floatingChildren = biome.getFloatingChildBiomes(); - if (floatingChildren == null) { - continue; - } - for (FloatingChildBiome floatingChild : floatingChildren) { - if (floatingChild != null) { - addReachableBiomeKey(pending, floatingChild.biome()); - String carvingReference = floatingChild.carving(); - IrisDimensionCarvingEntry carvingEntry = carvingEntryIndex.get(carvingReference); - addReachableBiomeKey(pending, - carvingEntry == null ? carvingReference : carvingEntry.getBiome()); - } - } + addReachableBiomeKeys(pending, biome.getModuleSettings().treeBiomes()); + addReachableBiomeKeys(pending, biome.getModuleSettings().usedBiomes(getModuleSettings())); } return biomes.v(); diff --git a/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java b/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java index 8c03c3310..3bc2a7fd0 100644 --- a/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java +++ b/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java @@ -18,7 +18,6 @@ package art.arcane.iris.engine.object.world.region; -import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.engine.object.entity.IrisEffect; import art.arcane.iris.engine.object.entity.spawn.IrisSpawner; import art.arcane.iris.engine.object.loot.IrisBlockDrops; @@ -26,16 +25,12 @@ import art.arcane.iris.engine.object.loot.IrisLootReference; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.engine.object.procedural.IrisProceduralObjects; import art.arcane.iris.engine.object.structure.IrisStructurePlacement; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; -import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; import art.arcane.iris.engine.object.value.IRare; import art.arcane.iris.engine.object.world.biome.InferredType; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.framework.render.RenderType; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.spi.IrisLogging; -import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.core.loader.IrisRegistrant; import art.arcane.iris.engine.data.cache.AtomicCache; import art.arcane.iris.engine.object.annotations.ArrayType; @@ -77,10 +72,6 @@ public class IrisRegion extends IrisRegistrant implements IRare { private final transient AtomicCache> realShoreBiomes = new AtomicCache<>(); private final transient AtomicCache> realCaveBiomes = new AtomicCache<>(); private final transient AtomicCache cacheColor = new AtomicCache<>(); - private final transient AtomicCache> surfaceOreCache = new AtomicCache<>(); - private final transient AtomicCache> undergroundOreCache = new AtomicCache<>(); - private final transient AtomicCache surfaceOreBoundsCache = new AtomicCache<>(); - private final transient AtomicCache undergroundOreBoundsCache = new AtomicCache<>(); @MinNumber(2) @Required @Desc("The name of the region") @@ -130,8 +121,6 @@ public class IrisRegion extends IrisRegistrant implements IRare { @MinNumber(0.0001) @Desc("How large cave biomes are in this region") private double caveBiomeZoom = 1; - @Desc("Profile-driven 3D cave configuration") - private CaveProfile caveProfile = new CaveProfile(); @RegistryListResource(IrisBiome.class) @Required @ArrayType(min = 1, type = String.class) @@ -149,100 +138,8 @@ public class IrisRegion extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = String.class) @Desc("A list of root-level cave biomes in this region, used for carved cave interiors. Don't specify child biomes of other biomes here. Just the root parents.") private KList caveBiomes = new KList<>(); - @ArrayType(min = 1, type = IrisDepositVariant.class) - @Desc("Deposit ore remap rules scoped to this region. Each entry declares a vertical band and a source->replacement block id map. Applied after biome rules but before dimension rules; first matching region rule wins.") - private KList depositVariants = new KList<>(); @Desc("A color for visualizing this region with a color. I.e. #F13AF5. This will show up on the map.") private String color = null; - @Desc("Collection of ores to be generated") - @ArrayType(type = IrisOreGenerator.class, min = 1) - private KList ores = new KList<>(); - - public PlatformBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) { - KList localOres = surface ? getSurfaceOres() : getUndergroundOres(); - return generateOres(localOres, x, y, z, rng, data); - } - - public PlatformBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) { - return generateOres(getSurfaceOres(), x, y, z, rng, data); - } - - public PlatformBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) { - return generateOres(getUndergroundOres(), x, y, z, rng, data); - } - - public boolean hasSurfaceOres() { - return !getSurfaceOres().isEmpty(); - } - - public boolean hasUndergroundOres() { - return !getUndergroundOres().isEmpty(); - } - - private PlatformBlockState generateOres(KList localOres, int x, int y, int z, RNG rng, IrisData data) { - if (localOres.isEmpty()) { - return null; - } - - int oreCount = localOres.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = localOres.get(oreIndex); - PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data); - if (ore != null) { - return ore; - } - } - return null; - } - - public void setOres(KList ores) { - this.ores = ores == null ? new KList<>() : ores; - surfaceOreCache.reset(); - undergroundOreCache.reset(); - surfaceOreBoundsCache.reset(); - undergroundOreBoundsCache.reset(); - } - - public KList getSurfaceOreGenerators() { - return getOres(true); - } - - public KList getUndergroundOreGenerators() { - return getOres(false); - } - - public IrisOreGeneratorBounds getSurfaceOreGeneratorBounds() { - return surfaceOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getSurfaceOres())); - } - - public IrisOreGeneratorBounds getUndergroundOreGeneratorBounds() { - return undergroundOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getUndergroundOres())); - } - - private KList getSurfaceOres() { - return getOres(true); - } - - private KList getUndergroundOres() { - return getOres(false); - } - - private KList getOres(boolean surface) { - AtomicCache> oreCache = surface ? surfaceOreCache : undergroundOreCache; - return oreCache.aquire(() -> { - KList filtered = new KList<>(); - KList localOres = ores; - int oreCount = localOres.size(); - for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) { - IrisOreGenerator oreGenerator = localOres.get(oreIndex); - if (oreGenerator.isGenerateSurface() == surface) { - filtered.add(oreGenerator); - } - } - - return filtered; - }); - } public String getName() { return name; @@ -315,7 +212,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { continue; } - names.add(biome.getCarvingBiome()); + names.addAll(biome.getModuleSettings().treeBiomes()); b.put(biome.getLoadKey(), biome); names.addAll(biome.getChildren()); } @@ -412,7 +309,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { continue; } - names.add(biome.getCarvingBiome()); + names.addAll(biome.getModuleSettings().treeBiomes()); b.put(biome.getLoadKey(), biome); names.addAll(biome.getChildren()); }