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/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..ee0b330a4 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java @@ -0,0 +1,125 @@ +/* + * 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; + } + NoiseSampler sampler = chance.aquire(() -> noise.sampler(settings.chanceStyle(), terrainSeed)); + if (sampler.sample(x, y, z) > settings.threshold()) { + return null; + } + return pick(x, y, z); + } + + 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 7926c0357..3ebec481d 100644 --- a/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java +++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java @@ -19,14 +19,15 @@ package art.arcane.iris.engine.actuator; import art.arcane.iris.builtin.IrisStages; +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; @@ -63,6 +64,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { @Override public void register(FeatureRegistry registry) { + registry.registerSettings(OreSettings.class); + registry.registerSettings(HideOresSettings.class); registry.registerLifecycle(this); } @@ -86,10 +89,16 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { private static final PlatformBlockState BEDROCK = B.getState("BEDROCK"); private final Engine engine; + private final TerrainOres ores; private final RNG rng; TerrainShaper(Engine engine) { + this(engine, TerrainOres.of(engine)); + } + + TerrainShaper(Engine engine, TerrainOres ores) { this.engine = engine; + this.ores = ores; this.rng = new RNG(engine.getSeedManager().getTerrain()); } @@ -115,7 +124,7 @@ 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(); ChunkedDataCache fluidCache = context.getFluid(); @@ -123,11 +132,10 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { 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; @@ -143,16 +151,14 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle { PlatformBlockState fluid = fluidCache.get(xf, zf); PlatformBlockState rock = rockCache.get(xf, zf); 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; @@ -164,14 +170,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) { @@ -209,14 +215,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); } } @@ -264,22 +270,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..8dc6a9b0e --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java @@ -0,0 +1,53 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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. */ + ResolvedOres of(IrisRegistrant owner) { + OreSettings settings = owner.getModuleSettings().find(OreSettings.class).orElse(null); + if (settings == null) { + return ResolvedOres.NONE; + } + return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, engine)); + } +} 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..2a8906b69 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java +++ b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java @@ -21,10 +21,14 @@ 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; @@ -52,7 +56,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"); @@ -150,13 +157,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(); @@ -317,7 +324,7 @@ public class DepositPlacer extends EngineAssignedComponent { IrisBiome biome = getEngine().getCaveBiome(worldX, localY, worldZ, carvingState); if (biome != null) { - PlatformBlockState match = matchDepositVariant(biome.getDepositVariants(), ore, worldY); + PlatformBlockState match = matchDepositVariant(biome, ore, worldY); if (match != null) { return match; } @@ -325,14 +332,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 +348,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 +363,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/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/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/world/biome/IrisBiome.java b/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java index 2be388ff5..d6da53ad2 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 @@ -31,10 +31,6 @@ import art.arcane.iris.engine.object.procedural.IrisProceduralObjects; import art.arcane.iris.engine.object.structure.IrisStructurePlacement; import art.arcane.iris.engine.object.terrain.IrisBiomeLayerGenerator; import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer; -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; @@ -78,7 +74,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 IrisBiomeLayerGenerator}, {@link IrisBiomeDerivatives}, {@link IrisBiomeOres}, + * {@link IrisBiomeLayerGenerator}, {@link IrisBiomeDerivatives}, * {@link IrisBiomeColorRenderer} and {@link IrisBiomeGenLinks}. */ @Accessors(chain = true) @@ -112,10 +108,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { private final transient AtomicCache> realChildren = new AtomicCache<>(); private final transient AtomicCache> layerHeightGenerators = new AtomicCache<>(); private final transient AtomicCache> layerSeaHeightGenerators = 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<>(); @@ -217,44 +209,10 @@ public class IrisBiome extends IrisRegistrant implements IRare { @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; @@ -292,39 +250,12 @@ public class IrisBiome extends IrisRegistrant implements IRare { variant.setLoader(data); variant.setLoadKey(getLoadKey()); variant.setLoadFile(getLoadFile()); + variant.setModuleSettings(getModuleSettings()); variant.inferredType = type; inferredVariants.put(type, variant); 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(); 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 8f37e4768..b59850df2 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 @@ -35,9 +35,6 @@ 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; @@ -114,10 +111,6 @@ public class IrisDimension extends IrisRegistrant { 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") @@ -176,8 +169,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("Use post processing or not") private boolean postProcessing = true; @Desc("Add slabs in post processing") @@ -275,9 +266,6 @@ 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<>(); @@ -285,9 +273,6 @@ public class IrisDimension extends IrisRegistrant { private IrisMaterialPalette rockPalette = new IrisMaterialPalette().qclear().qadd("stone"); @Desc("The dimension fluid block palette used for ocean columns and cave aquifers.") private IrisMaterialPalette fluidPalette = new IrisMaterialPalette().qclear().qadd("water"); - @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<>(); @@ -343,92 +328,6 @@ public class IrisDimension extends IrisRegistrant { 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(); } 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..60b0583ce 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 @@ -26,9 +26,6 @@ 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; @@ -77,10 +74,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") @@ -149,100 +142,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;