mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Move the built-in modules to the batch 2 API
Settings are read as SettingsStacks (dimension(), mostSpecific(), values()) and levels are com.volmit.config.Level. Chunk coordinates and centres come from the context's chunk helpers, surface heights from TerrainSampler.surfaceHeight, and resources from the world. Settings types register in one varargs call, and ObjectModule takes its log from setup instead of keeping a field.
This commit is contained in:
1 parent
c3d175d8de
commit
b15a41094d
86 files changed
+267
-391
No files matched your search
@@ -47,7 +47,6 @@ import com.volmit.world.TerrainSampler;
|
||||
*/
|
||||
public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
@@ -59,8 +58,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
// Ordering only: iris:matter ships in the built-ins jar, which a pack may not have.
|
||||
setup.stages().define(IrisStages.Decorant.DECORATE).softAfter(IrisStages.Matter.INSERT).run(DecorantModule::decorate);
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(DecorantSettings.class);
|
||||
registry.registerSettings(DecorateSettings.class);
|
||||
registry.registerSettings(DecorantSettings.class, DecorateSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@@ -78,8 +76,8 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
|
||||
/** A dimension decorates unless it says {@code decorate: false}. */
|
||||
private static boolean decorates(ChunkStageContext context) {
|
||||
return context.settings().at(DecorateSettings.class, context.originX() + CHUNK_CENTRE, context.originZ() + CHUNK_CENTRE).stream()
|
||||
.allMatch(entry -> entry.value().decorate());
|
||||
return context.settings().at(DecorateSettings.class, context.centreX(), context.centreZ()).dimension()
|
||||
.map(DecorateSettings::decorate).orElse(true);
|
||||
}
|
||||
|
||||
/** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
|
||||
@@ -102,7 +100,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
if (!decorators.hasDecorators(biome)) {
|
||||
continue;
|
||||
}
|
||||
int height = (int) Math.round(terrain.surfaceY(realX, realZ));
|
||||
int height = terrain.surfaceHeight(realX, realZ);
|
||||
|
||||
if (height >= 0 && height < fluidHeight && scene.isSolid(output.get(i, height, j))
|
||||
&& height + 1 < output.getHeight() && scene.isWater(output.get(i, height + 1, j))) {
|
||||
|
||||
@@ -20,13 +20,13 @@ package art.arcane.iris.engine.actuator;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
@@ -55,15 +55,15 @@ final class OreWarmUp {
|
||||
void warm() {
|
||||
LongSupplier seeds = () -> root.nextParallelRNG(warmed++).getSeed();
|
||||
|
||||
List<Entry<OreSettings>> declared = world.settings().declared(OreSettings.class);
|
||||
warmLevel(declared, Target.BIOME, seeds);
|
||||
warmLevel(declared, Target.REGION, seeds);
|
||||
warmLevel(declared, Target.DIMENSION, seeds);
|
||||
SettingsStack<OreSettings> declared = world.settings().declared(OreSettings.class);
|
||||
warmLevel(declared, Level.BIOME, seeds);
|
||||
warmLevel(declared, Level.REGION, seeds);
|
||||
warmLevel(declared, Level.DIMENSION, seeds);
|
||||
}
|
||||
|
||||
/** The ores of every owner at {@code level}, ordered by the key of the biome, region or dimension that declares them. */
|
||||
private void warmLevel(List<Entry<OreSettings>> declared, Target level, LongSupplier seeds) {
|
||||
declared.stream()
|
||||
private void warmLevel(SettingsStack<OreSettings> declared, Level level, LongSupplier seeds) {
|
||||
declared.entries().stream()
|
||||
.filter(entry -> entry.level() == level)
|
||||
.sorted(Comparator.comparing((Entry<OreSettings> entry) -> key(entry.source())))
|
||||
.forEach(entry -> ores.of(entry.value()).warm(seeds));
|
||||
|
||||
@@ -59,20 +59,10 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(IrisStages.Terrain.SHAPE).run(TerrainModule::shape);
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(LayersSettings.class);
|
||||
registry.registerSettings(SeaLayersSettings.class);
|
||||
registry.registerSettings(CaveCeilingLayersSettings.class);
|
||||
registry.registerSettings(SlabSettings.class);
|
||||
registry.registerSettings(WallSettings.class);
|
||||
registry.registerSettings(LockLayersSettings.class);
|
||||
registry.registerSettings(LockLayersMaxSettings.class);
|
||||
registry.registerSettings(RockPaletteSettings.class);
|
||||
registry.registerSettings(FluidPaletteSettings.class);
|
||||
registry.registerSettings(OreSettings.class);
|
||||
registry.registerSettings(HideOresSettings.class);
|
||||
registry.registerSettings(BedrockSettings.class);
|
||||
registry.registerSettings(ExplodeBiomePalettesSettings.class);
|
||||
registry.registerSettings(ExplodeBiomePaletteSizeSettings.class);
|
||||
registry.registerSettings(LayersSettings.class, SeaLayersSettings.class, CaveCeilingLayersSettings.class, SlabSettings.class,
|
||||
WallSettings.class, LockLayersSettings.class, LockLayersMaxSettings.class, RockPaletteSettings.class, FluidPaletteSettings.class,
|
||||
OreSettings.class, HideOresSettings.class, BedrockSettings.class, ExplodeBiomePalettesSettings.class,
|
||||
ExplodeBiomePaletteSizeSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ import art.arcane.iris.builtin.terrain.PaletteExplosion;
|
||||
import art.arcane.iris.builtin.terrain.TerrainPalettes;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
@@ -41,15 +41,12 @@ import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.UpperDimension;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Function;
|
||||
|
||||
/** What shaping terrain keeps for one world: the terrain stream's random and the palettes, layers and ores the columns are filled from. */
|
||||
final class TerrainShaper {
|
||||
private static final BlockState BEDROCK = new BlockState("minecraft:bedrock");
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
|
||||
private final TerrainPalettes palettes;
|
||||
private final BiomeLayers layers;
|
||||
@@ -70,8 +67,8 @@ final class TerrainShaper {
|
||||
this.layers = layers;
|
||||
this.ores = ores;
|
||||
this.rng = new RNG(IrisSeed.TERRAIN.of(world));
|
||||
this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).stream()
|
||||
.anyMatch(entry -> entry.level() != Target.DIMENSION);
|
||||
this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).entries().stream()
|
||||
.anyMatch(entry -> entry.level() != Level.DIMENSION);
|
||||
}
|
||||
|
||||
/** Fills the 16 x 16 columns of the chunk, one slice along x at a time. */
|
||||
@@ -91,7 +88,7 @@ final class TerrainShaper {
|
||||
|
||||
for (int zf = 0; zf < chunkDepth; zf++) {
|
||||
int realZ = zf + chunk.originZ;
|
||||
int he = Math.min(chunkHeight, (int) Math.round(chunk.terrain.surfaceY(realX, realZ)));
|
||||
int he = Math.min(chunkHeight, chunk.terrain.surfaceHeight(realX, realZ));
|
||||
int hf = Math.max(chunk.clampedFluidHeight, he);
|
||||
if (hf < 0) {
|
||||
continue;
|
||||
@@ -238,7 +235,7 @@ final class TerrainShaper {
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature> S biomeLevel(FeatureSettings settings, Class<S> type, int worldX, int worldZ) {
|
||||
return settings.at(type, worldX, worldZ).stream().filter(entry -> entry.level() == Target.BIOME).map(Entry::value).findFirst().orElse(null);
|
||||
return settings.at(type, worldX, worldZ).level(Level.BIOME).orElse(null);
|
||||
}
|
||||
|
||||
/** A block the palette has none of leaves the column as it is. */
|
||||
@@ -276,15 +273,15 @@ final class TerrainShaper {
|
||||
this.originX = context.originX();
|
||||
this.originZ = context.originZ();
|
||||
this.clampedFluidHeight = Math.min(blocks.getHeight(), terrain.fluidHeight());
|
||||
int centreX = originX + CHUNK_CENTRE;
|
||||
int centreZ = originZ + CHUNK_CENTRE;
|
||||
this.bedrockEnabled = dimensionValue(settings.at(BedrockSettings.class, centreX, centreZ), BedrockSettings::bedrock, true);
|
||||
this.hideOres = dimensionValue(settings.at(HideOresSettings.class, centreX, centreZ), HideOresSettings::hide, false);
|
||||
int centreX = context.centreX();
|
||||
int centreZ = context.centreZ();
|
||||
this.bedrockEnabled = settings.at(BedrockSettings.class, centreX, centreZ).dimension().map(BedrockSettings::bedrock).orElse(true);
|
||||
this.hideOres = settings.at(HideOresSettings.class, centreX, centreZ).dimension().map(HideOresSettings::hide).orElse(false);
|
||||
this.explosion = PaletteExplosion.of(settings, centreX, centreZ);
|
||||
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
|
||||
this.upper = terrain.upperDimension();
|
||||
// Dimension-level ore lookups are chunk-invariant; resolving them per column paid the settings lookup times 256 per chunk for a constant.
|
||||
this.dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(levelValue(settings.at(OreSettings.class, centreX, centreZ), Target.DIMENSION));
|
||||
this.dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(settings.at(OreSettings.class, centreX, centreZ).dimension().orElse(null));
|
||||
}
|
||||
|
||||
/** What the upper dimension declares about exploded palettes: a setting of the dimension, so the same for every column of the chunk. */
|
||||
@@ -300,22 +297,8 @@ final class TerrainShaper {
|
||||
if (hideOres || !levelsBelowTheDimensionDeclareOres) {
|
||||
return ColumnOres.NONE;
|
||||
}
|
||||
List<Entry<OreSettings>> declared = settings.at(OreSettings.class, worldX, worldZ);
|
||||
return new ColumnOres(ores.of(levelValue(declared, Target.REGION)), ores.of(levelValue(declared, Target.BIOME)));
|
||||
SettingsStack<OreSettings> declared = settings.at(OreSettings.class, worldX, worldZ);
|
||||
return new ColumnOres(ores.of(declared.level(Level.REGION).orElse(null)), ores.of(declared.level(Level.BIOME).orElse(null)));
|
||||
}
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature, V> V dimensionValue(List<Entry<S>> entries, Function<S, V> read, V fallback) {
|
||||
S declared = levelValue(entries, Target.DIMENSION);
|
||||
return declared == null ? fallback : read.apply(declared);
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature> S levelValue(List<Entry<S>> entries, Target level) {
|
||||
for (Entry<S> entry : entries) {
|
||||
if (entry.level() == level) {
|
||||
return entry.value();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public final class BiomeDecorators {
|
||||
|
||||
/** The biome of the entry a column's settings gave, which is the column's surface biome; null when the biome declares nothing. */
|
||||
public static DecoratedBiome biomeOf(FeatureSettings settings, int worldX, int worldZ, com.volmit.world.BiomeKind kind) {
|
||||
List<Entry<DecorantSettings>> entries = settings.at(DecorantSettings.class, worldX, worldZ);
|
||||
List<Entry<DecorantSettings>> entries = settings.at(DecorantSettings.class, worldX, worldZ).entries();
|
||||
if (entries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public final class BiomeDecorators {
|
||||
|
||||
/** Resolves every decorator of every biome the dimension reaches and builds its noise, so that generation finds them ready. */
|
||||
public void warm() {
|
||||
List<Entry<DecorantSettings>> declared = new ArrayList<>(world.settings().declared(DecorantSettings.class));
|
||||
List<Entry<DecorantSettings>> declared = new ArrayList<>(world.settings().declared(DecorantSettings.class).entries());
|
||||
declared.sort(Comparator.comparing(entry -> biomeKey(entry.source())));
|
||||
for (Entry<DecorantSettings> entry : declared) {
|
||||
DecoratedBiome biome = new DecoratedBiome(biomeKey(entry.source()), entry.value(), null);
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class DecorationScene {
|
||||
/** The chunk of {@code context}, decorated with the world's decorators. */
|
||||
public static DecorationScene of(ChunkStageContext context) {
|
||||
Mantle mantle = context.mantle();
|
||||
return new DecorationScene(context.hunk(BlockState.class), context.resources().blocks(), context.terrain(),
|
||||
return new DecorationScene(context.hunk(BlockState.class), context.world().resources().blocks(), context.terrain(),
|
||||
mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), IrisSeed.COMPONENT.of(context.world()),
|
||||
context.log());
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public final class DecorationScene {
|
||||
|
||||
/** The height of the terrain at the column, rounded. */
|
||||
long roundedHeightAt(int worldX, int worldZ) {
|
||||
return Math.round(terrain.surfaceY(worldX, worldZ));
|
||||
return terrain.surfaceHeight(worldX, worldZ);
|
||||
}
|
||||
|
||||
/** The block a placement planned at the position, or air; positions the mantle does not cover read as air. */
|
||||
|
||||
@@ -22,7 +22,6 @@ import art.arcane.iris.builtin.RegistryKeyFamily;
|
||||
import art.arcane.iris.builtin.structure.StructureAdjustment;
|
||||
import art.arcane.iris.builtin.structure.StructureSetFrequency;
|
||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.vanilla.VanillaStructureSetup;
|
||||
@@ -46,8 +45,7 @@ public final class ImportedStructures {
|
||||
|
||||
/** The settings the dimension of {@code settings} declares, or the defaults when it declares none. */
|
||||
public static ImportedStructures of(PackSettings settings) {
|
||||
List<Entry<StructureSettings>> declared = settings.declared(StructureSettings.class);
|
||||
return new ImportedStructures(declared.isEmpty() ? new StructureSettings() : declared.getFirst().value());
|
||||
return new ImportedStructures(settings.declared(StructureSettings.class).dimension().orElseGet(StructureSettings::new));
|
||||
}
|
||||
|
||||
/** Whether the dimension disables the platform structure {@code key}, by family or by its exact key. */
|
||||
|
||||
+1
-4
@@ -20,13 +20,11 @@ package art.arcane.iris.engine.framework.vanillafeatures;
|
||||
|
||||
import art.arcane.iris.builtin.RegistryKeyFamily;
|
||||
import art.arcane.iris.builtin.vanillafeatures.ImportedFeaturesSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.VanillaFeatures;
|
||||
import com.volmit.vanilla.DecorationStep;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -61,7 +59,6 @@ public final class ImportedFeatures implements VanillaFeatures {
|
||||
}
|
||||
|
||||
private static ImportedFeaturesSettings settings(PackWorld world) {
|
||||
List<Entry<ImportedFeaturesSettings>> declared = world.settings().declared(ImportedFeaturesSettings.class);
|
||||
return declared.isEmpty() ? NONE : declared.getFirst().value();
|
||||
return world.settings().declared(ImportedFeaturesSettings.class).dimension().orElse(NONE);
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,7 @@ public final class LootModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(LootSettings.class);
|
||||
registry.registerSettings(BlockDropSettings.class);
|
||||
registry.registerSettings(LootSettings.class, BlockDropSettings.class);
|
||||
registry.registerHeldType(ObjectLoot.class);
|
||||
registry.registerHeldType(ObjectVanillaLoot.class);
|
||||
LootResources.kinds().forEach(registry::registerResourceKind);
|
||||
|
||||
@@ -23,8 +23,8 @@ import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.loot.LootMode;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.validation.Problem;
|
||||
@@ -70,7 +70,7 @@ public final class LootValidator implements Validator {
|
||||
private static List<Problem> checkReferences(ValidationContext pack) {
|
||||
Set<ResourceId> lootIds = Set.copyOf(pack.resources().ids(LootTable.class));
|
||||
List<Problem> problems = new ArrayList<>();
|
||||
List<Entry<LootSettings>> declared = new ArrayList<>(pack.settings().declared(LootSettings.class));
|
||||
List<Entry<LootSettings>> declared = new ArrayList<>(pack.settings().declared(LootSettings.class).entries());
|
||||
declared.sort(Comparator.comparing(Entry<LootSettings>::level).thenComparing(Entry::source));
|
||||
for (Entry<LootSettings> entry : declared) {
|
||||
String resourceKey = keyOf(entry);
|
||||
@@ -106,21 +106,21 @@ public final class LootValidator implements Validator {
|
||||
return path.substring(path.indexOf(LEVEL_FOLDER_SEPARATOR) + 1);
|
||||
}
|
||||
|
||||
private static String hostType(Target level) {
|
||||
private static String hostType(Level level) {
|
||||
return switch (level) {
|
||||
case DIMENSION -> "Dimension";
|
||||
case REGION -> "Region";
|
||||
case BIOME -> "Biome";
|
||||
case OBJECT_PLACEMENT -> "Resource";
|
||||
case PLACEMENT -> "Resource";
|
||||
};
|
||||
}
|
||||
|
||||
private static String folderOf(Target level) {
|
||||
private static String folderOf(Level level) {
|
||||
return switch (level) {
|
||||
case DIMENSION -> "dimensions";
|
||||
case REGION -> "regions";
|
||||
case BIOME -> "biomes";
|
||||
case OBJECT_PLACEMENT -> "placements";
|
||||
case PLACEMENT -> "placements";
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ final class CaveAnchors {
|
||||
if (known != null) {
|
||||
return known;
|
||||
}
|
||||
int surfaceY = (int) Math.round(terrain.surfaceY(x, z));
|
||||
int surfaceY = terrain.surfaceHeight(x, z);
|
||||
surfaceHeights.put(columnKey, surfaceY);
|
||||
return surfaceY;
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ public class CaveCarving {
|
||||
int worldX = baseX + localX;
|
||||
for (int localZ = 0; localZ < CHUNK_SIZE; localZ++) {
|
||||
int columnIndex = PowerOfTwoCoordinates.packLocal16(localX, localZ);
|
||||
scratch[columnIndex] = (int) Math.round(terrain.surfaceY(worldX, baseZ + localZ));
|
||||
scratch[columnIndex] = terrain.surfaceHeight(worldX, baseZ + localZ);
|
||||
}
|
||||
}
|
||||
return scratch;
|
||||
|
||||
@@ -38,10 +38,10 @@ import art.arcane.iris.builtin.objects.UpperObjectsForceSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsSettings;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
@@ -55,8 +55,8 @@ import java.util.OptionalInt;
|
||||
* and its procedural objects, in that order, all drawing from the one random of the chunk.
|
||||
*/
|
||||
final class ChunkObjectPlacing {
|
||||
private static final int CENTER_OFFSET_BLOCKS = 8;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
/** Objects read their chunk's settings at local 8, 8 as Iris always did, not at the API's centre column (local 7, 7): moving it would move objects. */
|
||||
private static final int OBJECT_COLUMN_OFFSET_BLOCKS = 8;
|
||||
private static final int CHUNK_WIDTH_BLOCKS = 16;
|
||||
private static final double CHANCE_JITTER = 0.005;
|
||||
private static final int[] CAVE_BIOME_SAMPLE_DEPTHS = {48, 80, 112};
|
||||
@@ -91,10 +91,10 @@ final class ChunkObjectPlacing {
|
||||
this.context = context;
|
||||
this.chunk = host.chunk();
|
||||
this.terrain = context.terrain();
|
||||
this.chunkX = context.originX() >> CHUNK_SHIFT;
|
||||
this.chunkZ = context.originZ() >> CHUNK_SHIFT;
|
||||
this.centerX = CENTER_OFFSET_BLOCKS + (chunkX << CHUNK_SHIFT);
|
||||
this.centerZ = CENTER_OFFSET_BLOCKS + (chunkZ << CHUNK_SHIFT);
|
||||
this.chunkX = context.chunkX();
|
||||
this.chunkZ = context.chunkZ();
|
||||
this.centerX = context.originX() + OBJECT_COLUMN_OFFSET_BLOCKS;
|
||||
this.centerZ = context.originZ() + OBJECT_COLUMN_OFFSET_BLOCKS;
|
||||
this.rng = host.chunkRandom(chunkX, chunkZ);
|
||||
this.traceRegen = Thread.currentThread().getName().startsWith(REGEN_THREAD_PREFIX) && host.debugging();
|
||||
this.golden = chunk.goldenDebug(chunkX, chunkZ);
|
||||
@@ -127,16 +127,12 @@ final class ChunkObjectPlacing {
|
||||
private Column readColumn() {
|
||||
ResourceId region = host.regionAt(centerX, centerZ);
|
||||
ResourceId surface = host.surfaceBiomeAt(centerX, centerZ);
|
||||
int surfaceY = surfaceY(centerX, centerZ);
|
||||
int surfaceY = terrain.surfaceHeight(centerX, centerZ);
|
||||
ResourceId cave = resolveCaveObjectBiome(surfaceY, surface);
|
||||
return new Column(region, surface, cave, surfaceY, objectsOf(cave, region, surface), proceduralOf(cave, region, surface),
|
||||
profilesOf(cave, region, surface));
|
||||
}
|
||||
|
||||
private int surfaceY(int x, int z) {
|
||||
return (int) Math.round(terrain.surfaceY(x, z));
|
||||
}
|
||||
|
||||
private ResourceId resolveCaveObjectBiome(int surfaceY, ResourceId surfaceBiome) {
|
||||
ResourceId legacy = caveBiomeAt(Math.max(1, surfaceY - LEGACY_CAVE_SAMPLE_DEPTH)).orElse(surfaceBiome);
|
||||
ResourceId ladderChoice = null;
|
||||
@@ -161,39 +157,37 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private ColumnObjects objectsOf(ResourceId cave, ResourceId region, ResourceId surface) {
|
||||
List<Entry<ObjectSettings>> entries = context.settings().at(ObjectSettings.class, centerX, centerZ);
|
||||
return new ColumnObjects(level(entries, Target.BIOME), caveSettings(cave, surface, entries, ObjectSettings.class), level(entries, Target.REGION));
|
||||
SettingsStack<ObjectSettings> declared = context.settings().at(ObjectSettings.class, centerX, centerZ);
|
||||
return new ColumnObjects(levelValue(declared, Level.BIOME), caveSettings(cave, surface, declared, ObjectSettings.class),
|
||||
levelValue(declared, Level.REGION));
|
||||
}
|
||||
|
||||
private ColumnProcedural proceduralOf(ResourceId cave, ResourceId region, ResourceId surface) {
|
||||
List<Entry<ProceduralObjectSettings>> entries = context.settings().at(ProceduralObjectSettings.class, centerX, centerZ);
|
||||
return new ColumnProcedural(level(entries, Target.BIOME),
|
||||
caveSettings(cave, surface, entries, ProceduralObjectSettings.class), level(entries, Target.REGION));
|
||||
SettingsStack<ProceduralObjectSettings> declared = context.settings().at(ProceduralObjectSettings.class, centerX, centerZ);
|
||||
return new ColumnProcedural(levelValue(declared, Level.BIOME),
|
||||
caveSettings(cave, surface, declared, ProceduralObjectSettings.class), levelValue(declared, Level.REGION));
|
||||
}
|
||||
|
||||
private ColumnProfiles profilesOf(ResourceId cave, ResourceId region, ResourceId surface) {
|
||||
List<Entry<CaveProfile>> entries = context.settings().at(CaveProfile.class, centerX, centerZ);
|
||||
return new ColumnProfiles(level(entries, Target.BIOME), caveSettings(cave, surface, entries, CaveProfile.class), level(entries, Target.REGION));
|
||||
SettingsStack<CaveProfile> declared = context.settings().at(CaveProfile.class, centerX, centerZ);
|
||||
return new ColumnProfiles(levelValue(declared, Level.BIOME), caveSettings(cave, surface, declared, CaveProfile.class),
|
||||
levelValue(declared, Level.REGION));
|
||||
}
|
||||
|
||||
private <F extends IrisFeature> F caveSettings(ResourceId cave, ResourceId surface, List<Entry<F>> entries, Class<F> type) {
|
||||
private <F extends IrisFeature> F caveSettings(ResourceId cave, ResourceId surface, SettingsStack<F> declared, Class<F> type) {
|
||||
if (cave.equals(surface)) {
|
||||
return level(entries, Target.BIOME);
|
||||
return levelValue(declared, Level.BIOME);
|
||||
}
|
||||
return host.biomeDeclaration(cave, type).orElse(null);
|
||||
}
|
||||
|
||||
private <F extends IrisFeature> F dimensionLevel(Class<F> type) {
|
||||
return level(context.settings().at(type, centerX, centerZ), Target.DIMENSION);
|
||||
return levelValue(context.settings().at(type, centerX, centerZ), Level.DIMENSION);
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature> F level(List<Entry<F>> entries, Target level) {
|
||||
for (Entry<F> entry : entries) {
|
||||
if (entry.level() == level) {
|
||||
return entry.value();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
/** The value {@code level} declares, or null: the column records below hold null for a level that declares nothing. */
|
||||
private static <F extends IrisFeature> F levelValue(SettingsStack<F> declared, Level level) {
|
||||
return declared.level(level).orElse(null);
|
||||
}
|
||||
|
||||
private boolean dimensionRequiresSurfaceSupport() {
|
||||
@@ -288,8 +282,8 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private void placeObject(Tally tally, ObjectPlacement placement, String scope) {
|
||||
int blockX = chunkX << CHUNK_SHIFT;
|
||||
int blockZ = chunkZ << CHUNK_SHIFT;
|
||||
int blockX = context.originX();
|
||||
int blockZ = context.originZ();
|
||||
int density = host.density(placement, rng, blockX, blockZ);
|
||||
for (int i = 0; i < density; i++) {
|
||||
tally.attempts++;
|
||||
@@ -329,8 +323,8 @@ final class ChunkObjectPlacing {
|
||||
|
||||
private void placeCaveObject(Tally tally, ObjectPlacement placement, CaveProfile profile, String scope,
|
||||
ResourceId expectedCaveBiome, CaveAnchors anchors) {
|
||||
int minX = chunkX << CHUNK_SHIFT;
|
||||
int minZ = chunkZ << CHUNK_SHIFT;
|
||||
int minX = context.originX();
|
||||
int minZ = context.originZ();
|
||||
int density = host.density(placement, rng, minX, minZ);
|
||||
CaveAnchors.Search search = caves.searchFor(placement, profile);
|
||||
for (int i = 0; i < density; i++) {
|
||||
@@ -408,8 +402,8 @@ final class ChunkObjectPlacing {
|
||||
if (placements.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int blockX = chunkX << CHUNK_SHIFT;
|
||||
int blockZ = chunkZ << CHUNK_SHIFT;
|
||||
int blockX = context.originX();
|
||||
int blockZ = context.originZ();
|
||||
CaveAnchors anchors = newAnchors();
|
||||
for (ProceduralPlacement placement : placements) {
|
||||
boolean chancePassed = passesProceduralChance(rng, placement.chance());
|
||||
@@ -521,8 +515,8 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private void placeUpperObject(ObjectPlacement placement, boolean forcePlace, String scope) {
|
||||
int minX = chunkX << CHUNK_SHIFT;
|
||||
int minZ = chunkZ << CHUNK_SHIFT;
|
||||
int minX = context.originX();
|
||||
int minZ = context.originZ();
|
||||
int density = host.density(placement, rng, minX, minZ);
|
||||
for (int i = 0; i < density; i++) {
|
||||
Optional<PlaceableObject> picked = host.pickScaled(placement, rng);
|
||||
|
||||
@@ -34,9 +34,9 @@ import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -60,7 +60,6 @@ import java.util.Set;
|
||||
public final class FloatingObjectPlacing {
|
||||
private static final int INVERTED_PICK_ATTEMPTS = 8;
|
||||
private static final long CHUNK_RANDOM_SALT = 0x0FA710BEL;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final int CHUNK_COLUMNS = 256;
|
||||
private static final int MIN_REACH_BLOCKS = 16;
|
||||
private static final int LARGE_REACH_WARNING_BLOCKS = 128;
|
||||
@@ -97,7 +96,7 @@ public final class FloatingObjectPlacing {
|
||||
int minZ = context.originZ();
|
||||
BlockBox bounds = context.terrain().bounds();
|
||||
int worldHeight = bounds.maxY() - bounds.minY();
|
||||
RNG chunkRng = new RNG(CacheKey.key(minX >> CHUNK_SHIFT, minZ >> CHUNK_SHIFT) + mantleSeed + CHUNK_RANDOM_SALT);
|
||||
RNG chunkRng = new RNG(CacheKey.key(context.chunkX(), context.chunkZ()) + mantleSeed + CHUNK_RANDOM_SALT);
|
||||
FloatingIslandSampleResolver samples = new FloatingIslandSampleResolver(world, worldHeight,
|
||||
new FloatingIslandBoundarySampler(host::surfaceBiome), log);
|
||||
|
||||
@@ -391,7 +390,7 @@ public final class FloatingObjectPlacing {
|
||||
int maxObjectExtent = MIN_REACH_BLOCKS;
|
||||
try {
|
||||
for (Entry<FloatingChildSettings> declared : settings.declared(FloatingChildSettings.class)) {
|
||||
if (declared.level() != Target.BIOME) {
|
||||
if (declared.level() != Level.BIOME) {
|
||||
continue;
|
||||
}
|
||||
ResourceId biome = biomeIdOf(declared.source());
|
||||
|
||||
@@ -22,7 +22,7 @@ import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.Declaration;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.service.ObjectsAt;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class ObjectLocating implements ObjectsAt {
|
||||
if (!placesObject(declaration.settings().objects(), objectKey)) {
|
||||
continue;
|
||||
}
|
||||
(declaration.level() == Target.BIOME ? biomes : regions).add(declaration.key());
|
||||
(declaration.level() == Level.BIOME ? biomes : regions).add(declaration.key());
|
||||
}
|
||||
return new PlacedBy(biomes, regions);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ import com.volmit.world.PackWorld;
|
||||
public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
private ModuleLog log;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:objects", "Objects", VERSION);
|
||||
@@ -58,19 +56,16 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
log = setup.log();
|
||||
ModuleLog log = setup.log();
|
||||
// Ordering only: iris:carve ships in the built-ins jar, which a pack may not have.
|
||||
setup.stages().define(IrisStages.Objects.PLACE).softAfter(IrisStages.Carve.CAVES).reach(this::reach).run(ObjectModule::place);
|
||||
setup.stages().define(IrisStages.Objects.PLACE).softAfter(IrisStages.Carve.CAVES).reach(settings -> reach(settings, log))
|
||||
.run(ObjectModule::place);
|
||||
var registry = setup.registry();
|
||||
registry.registerService(ObjectsAt.class, new ObjectLocating());
|
||||
registry.registerService(SaplingGrowth.class, new TreeGrowing());
|
||||
registry.registerSettings(ObjectSettings.class);
|
||||
registry.registerSettings(ProceduralObjectSettings.class);
|
||||
registry.registerSettings(TreeGrowthSettings.class);
|
||||
registry.registerSettings(RequireSurfaceSupportSettings.class);
|
||||
registry.registerSettings(SurfaceSupportBufferSettings.class);
|
||||
registry.registerSettings(UpperObjectsSettings.class);
|
||||
registry.registerSettings(UpperObjectsForceSettings.class);
|
||||
registry.registerSettings(ObjectSettings.class, ProceduralObjectSettings.class, TreeGrowthSettings.class,
|
||||
RequireSurfaceSupportSettings.class, SurfaceSupportBufferSettings.class, UpperObjectsSettings.class,
|
||||
UpperObjectsForceSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@@ -83,7 +78,7 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
ObjectPlacing.of(context.world()).place(context);
|
||||
}
|
||||
|
||||
private int reach(PackSettings settings) {
|
||||
private static int reach(PackSettings settings, ModuleLog log) {
|
||||
return new PlacementReach(ObjectHost.of(settings), log).ofPack(settings);
|
||||
}
|
||||
}
|
||||
@@ -23,15 +23,14 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -44,6 +43,8 @@ public final class ObjectPlacing {
|
||||
private static final int CHUNK_CENTER_OFFSET_BLOCKS = 8;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final double CHANCE_JITTER = 0.005;
|
||||
/** A guess draws from the biome's objects before the region's, as placing does. */
|
||||
private static final Level[] GUESSED_LEVELS = {Level.BIOME, Level.REGION};
|
||||
|
||||
private final ObjectHost host;
|
||||
private final ModuleLog log;
|
||||
@@ -68,14 +69,10 @@ public final class ObjectPlacing {
|
||||
RNG rng = host.chunkRandom(chunkX, chunkZ);
|
||||
int centerX = (chunkX << CHUNK_SHIFT) + CHUNK_CENTER_OFFSET_BLOCKS;
|
||||
int centerZ = (chunkZ << CHUNK_SHIFT) + CHUNK_CENTER_OFFSET_BLOCKS;
|
||||
List<Entry<ObjectSettings>> entries = host.columnSettings().at(ObjectSettings.class, centerX, centerZ);
|
||||
SettingsStack<ObjectSettings> declared = host.columnSettings().at(ObjectSettings.class, centerX, centerZ);
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (Target level : new Target[]{Target.BIOME, Target.REGION}) {
|
||||
for (Entry<ObjectSettings> entry : entries) {
|
||||
if (entry.level() == level) {
|
||||
guessFrom(entry.value(), rng, chunkX, chunkZ, keys);
|
||||
}
|
||||
}
|
||||
for (Level level : GUESSED_LEVELS) {
|
||||
declared.level(level).ifPresent(settings -> guessFrom(settings, rng, chunkX, chunkZ, keys));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -41,6 +41,7 @@ import java.util.List;
|
||||
*/
|
||||
final class ObjectWarmUp {
|
||||
private static final long ROOT_SEED_SALT = 7777L;
|
||||
private static final Level[] WARMED_LEVELS = {Level.BIOME, Level.REGION};
|
||||
|
||||
private final ObjectHost host;
|
||||
private final RNG root;
|
||||
@@ -54,7 +55,7 @@ final class ObjectWarmUp {
|
||||
void warm() {
|
||||
List<Declaration<ObjectSettings>> placements = byKey(host.declarations(ObjectSettings.class));
|
||||
List<Declaration<ProceduralObjectSettings>> procedural = byKey(host.declarations(ProceduralObjectSettings.class));
|
||||
for (Target level : new Target[]{Target.BIOME, Target.REGION}) {
|
||||
for (Level level : WARMED_LEVELS) {
|
||||
for (Declaration<ObjectSettings> declaration : placements) {
|
||||
if (declaration.level() == level) {
|
||||
warmPlacements(declaration.settings().objects());
|
||||
|
||||
@@ -47,8 +47,7 @@ public final class StructureModule implements IrisModule {
|
||||
setup.stages().define(IrisStages.Structure.PLACE).softAfter(IrisStages.Objects.PLACE, IrisStages.Floating.OBJECTS)
|
||||
.reach(StructureModule::reach).run(StructureModule::place);
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(StructureSettings.class);
|
||||
registry.registerSettings(StructurePlacementSettings.class);
|
||||
registry.registerSettings(StructureSettings.class, StructurePlacementSettings.class);
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
|
||||
@@ -29,8 +29,6 @@ import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeMode;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -92,12 +90,7 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
}
|
||||
|
||||
private static TreeGrowthSettings treeGrowth(ObjectHost host, BlockPosition at) {
|
||||
for (Entry<TreeGrowthSettings> entry : host.columnSettings().at(TreeGrowthSettings.class, at.x(), at.z())) {
|
||||
if (entry.level() == Target.DIMENSION) {
|
||||
return entry.value();
|
||||
}
|
||||
}
|
||||
return new TreeGrowthSettings();
|
||||
return host.columnSettings().at(TreeGrowthSettings.class, at.x(), at.z()).dimension().orElseGet(TreeGrowthSettings::new);
|
||||
}
|
||||
|
||||
/** One placement, picked at random, of the tree placements that grow {@code sapling}'s species. */
|
||||
|
||||
@@ -57,7 +57,7 @@ final class BuiltInCaveDressing implements CaveDressing {
|
||||
this.layers = BiomeLayers.of(context.world());
|
||||
this.palettes = TerrainPalettes.of(context.world());
|
||||
this.settings = context.settings();
|
||||
this.blocks = context.resources().blocks();
|
||||
this.blocks = context.world().resources().blocks();
|
||||
this.explosion = PaletteExplosion.of(settings, context.originX(), context.originZ());
|
||||
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
|
||||
this.scene = DecorationScene.of(context);
|
||||
|
||||
@@ -35,9 +35,7 @@ import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.generation.ChunkContext;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
@@ -61,9 +59,6 @@ public final class CarveModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
/** Blended cave walls reach one block past the chunk. */
|
||||
private static final int CAVE_REACH_BLOCKS = 1;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
/** The centre column of a chunk, where per-chunk settings are read. */
|
||||
private static final int CHUNK_CENTRE_BLOCKS = 7;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
@@ -73,13 +68,8 @@ public final class CarveModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(CaveProfile.class);
|
||||
registry.registerSettings(CarvingSettings.class);
|
||||
registry.registerSettings(CarvingEnabledSettings.class);
|
||||
registry.registerSettings(CarvingBiomeSettings.class);
|
||||
registry.registerSettings(CaveDepthSettings.class);
|
||||
registry.registerSettings(CaveLavaHeightSettings.class);
|
||||
registry.registerSettings(UpperDimensionCarvingSettings.class);
|
||||
registry.registerSettings(CaveProfile.class, CarvingSettings.class, CarvingEnabledSettings.class, CarvingBiomeSettings.class,
|
||||
CaveDepthSettings.class, CaveLavaHeightSettings.class, UpperDimensionCarvingSettings.class);
|
||||
registry.registerService(CaveBiomes.class, new CaveBiomeBands());
|
||||
|
||||
var graph = setup.stages();
|
||||
@@ -88,29 +78,27 @@ public final class CarveModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void planCaves(MantleStageContext context) {
|
||||
if (!carves(context.settings(), context.originX(), context.originZ())) {
|
||||
if (!carves(context)) {
|
||||
return;
|
||||
}
|
||||
MatterMantle mantle = MatterMantle.of(context.mantle());
|
||||
caveCarving(context.world(), context.terrain(), context.settings(), context.originX(), context.originZ())
|
||||
.carve(mantle, context.terrain(), context.originX() >> CHUNK_SHIFT, context.originZ() >> CHUNK_SHIFT);
|
||||
caveCarving(context).carve(mantle, context.terrain(), context.chunkX(), context.chunkZ());
|
||||
}
|
||||
|
||||
private static void applyCaves(ChunkStageContext context) {
|
||||
MatterMantle mantle = MatterMantle.of(context.mantle());
|
||||
Hunk<BlockState> blocks = context.hunk(BlockState.class);
|
||||
caveApplying(context.world(), context.terrain(), context.settings(), context.originX(), context.originZ())
|
||||
.apply(mantle, context.terrain(), context.originX() >> CHUNK_SHIFT, context.originZ() >> CHUNK_SHIFT, blocks, CaveDressing.of(context));
|
||||
caveApplying(context).apply(mantle, context.terrain(), context.chunkX(), context.chunkZ(), blocks, CaveDressing.of(context));
|
||||
}
|
||||
|
||||
private static CaveCarving caveCarving(PackWorld world, TerrainSampler terrain, FeatureSettings settings, int originX, int originZ) {
|
||||
return world.state(CaveCarving.class, generating -> new CaveCarving(generating, carveWorld(generating, terrain),
|
||||
upperDimensionCarving(settings, originX, originZ), fluidColumns(generating)));
|
||||
private static CaveCarving caveCarving(ChunkContext context) {
|
||||
return context.world().state(CaveCarving.class, generating -> new CaveCarving(generating, carveWorld(generating, context.terrain()),
|
||||
upperDimensionCarving(context), fluidColumns(generating)));
|
||||
}
|
||||
|
||||
private static CaveApplying caveApplying(PackWorld world, TerrainSampler terrain, FeatureSettings settings, int originX, int originZ) {
|
||||
return world.state(CaveApplying.class, generating -> new CaveApplying(generating, carveWorld(generating, terrain),
|
||||
upperDimensionCarving(settings, originX, originZ)));
|
||||
private static CaveApplying caveApplying(ChunkContext context) {
|
||||
return context.world().state(CaveApplying.class, generating -> new CaveApplying(generating, carveWorld(generating, context.terrain()),
|
||||
upperDimensionCarving(context)));
|
||||
}
|
||||
|
||||
/** The columns the dimension's fluid palette fills with a fluid. */
|
||||
@@ -130,26 +118,23 @@ public final class CarveModule implements IrisModule {
|
||||
world.minHeight());
|
||||
}
|
||||
|
||||
private static boolean upperDimensionCarving(FeatureSettings settings, int originX, int originZ) {
|
||||
return dimensionEntry(settings, UpperDimensionCarvingSettings.class, originX + CHUNK_CENTRE_BLOCKS, originZ + CHUNK_CENTRE_BLOCKS)
|
||||
.map(UpperDimensionCarvingSettings::enabled).orElse(false);
|
||||
private static boolean upperDimensionCarving(ChunkContext context) {
|
||||
return centreDimensionValue(context, UpperDimensionCarvingSettings.class).map(UpperDimensionCarvingSettings::enabled).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* A dimension turns carving off with {@code carvingEnabled}. Listing {@code CARVED} in {@code disabledComponents}
|
||||
* also does: Iris then skips this stage's mantle pass like any disabled component.
|
||||
*/
|
||||
private static boolean carves(FeatureSettings settings, int originX, int originZ) {
|
||||
return dimensionEntry(settings, CarvingEnabledSettings.class, originX + CHUNK_CENTRE_BLOCKS, originZ + CHUNK_CENTRE_BLOCKS)
|
||||
.map(CarvingEnabledSettings::enabled).orElse(true);
|
||||
private static boolean carves(ChunkContext context) {
|
||||
return centreDimensionValue(context, CarvingEnabledSettings.class).map(CarvingEnabledSettings::enabled).orElse(true);
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature> Optional<F> dimensionEntry(FeatureSettings settings, Class<F> type, int x, int z) {
|
||||
return settings.at(type, x, z).stream().filter(entry -> entry.level() == Target.DIMENSION).map(Entry::value).findFirst();
|
||||
private static <F extends IrisFeature> Optional<F> centreDimensionValue(ChunkContext context, Class<F> type) {
|
||||
return context.settings().at(type, context.centreX(), context.centreZ()).dimension();
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature, V> V dimensionSetting(PackWorld world, Class<F> type, Function<F, V> read, V fallback) {
|
||||
return world.settings().declared(type).stream().filter(entry -> entry.level() == Target.DIMENSION).map(Entry::value).map(read)
|
||||
.findFirst().orElse(fallback);
|
||||
return world.settings().declared(type).dimension().map(read).orElse(fallback);
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class CaveApplying {
|
||||
int localZ = columnIndex & 15;
|
||||
int worldX = localX + chunkBlockX;
|
||||
int worldZ = localZ + chunkBlockZ;
|
||||
surfaceHeights[columnIndex] = (int) Math.round(terrain.surfaceY(worldX, worldZ));
|
||||
surfaceHeights[columnIndex] = terrain.surfaceHeight(worldX, worldZ);
|
||||
if (protectUpper) {
|
||||
upperSurfaceHeights[columnIndex] = terrain.upperDimensionY(worldX, worldZ).getAsInt();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.List;
|
||||
*/
|
||||
public final class DepositModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
@@ -51,9 +50,7 @@ public final class DepositModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(DepositVariantSettings.class);
|
||||
registry.registerSettings(OreFrequencySettings.class);
|
||||
registry.registerSettings(OreSizeSettings.class);
|
||||
registry.registerSettings(DepositVariantSettings.class, OreFrequencySettings.class, OreSizeSettings.class);
|
||||
|
||||
setup.stages().define(IrisStages.Deposit.ORES)
|
||||
.when(DepositSettings.class)
|
||||
@@ -63,17 +60,17 @@ public final class DepositModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void place(ChunkStageContext context) {
|
||||
List<DepositGenerator> generators = generatorsAtCentre(context.settings(), context.originX(), context.originZ());
|
||||
List<DepositGenerator> generators = generatorsAt(context.settings(), context.centreX(), context.centreZ());
|
||||
if (generators.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
DepositPlacer.of(context.world()).generate(context, generators);
|
||||
}
|
||||
|
||||
/** Every level's generators at the centre column of the chunk whose first block is {@code originX}, {@code originZ}, in level order. */
|
||||
static List<DepositGenerator> generatorsAtCentre(FeatureSettings settings, int originX, int originZ) {
|
||||
return settings.at(DepositSettings.class, originX + CHUNK_CENTRE, originZ + CHUNK_CENTRE).stream()
|
||||
.flatMap(entry -> entry.value().generators().stream())
|
||||
/** Every level's generators at the column {@code x}, {@code z}, in level order. */
|
||||
static List<DepositGenerator> generatorsAt(FeatureSettings settings, int x, int z) {
|
||||
return settings.at(DepositSettings.class, x, z).values().stream()
|
||||
.flatMap(declared -> declared.generators().stream())
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,13 @@ import art.arcane.iris.builtin.deposit.OreSizeSettings;
|
||||
import art.arcane.iris.engine.modifier.ResolvedDeposit.BiomeIdentity;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.resource.PackResources;
|
||||
@@ -61,7 +61,6 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
final class DepositPlacer {
|
||||
private static final double UNCHANGED_ORE_MULTIPLIER = 1D;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final int CHUNK_WIDTH = 16;
|
||||
private static final long CHUNK_X_SEED_FACTOR = 341873128712L;
|
||||
private static final long CHUNK_Z_SEED_FACTOR = 132897987541L;
|
||||
@@ -100,9 +99,7 @@ final class DepositPlacer {
|
||||
/** Runs {@code generators}, in order, on the chunk of {@code context}. */
|
||||
void generate(ChunkStageContext context, List<DepositGenerator> generators) {
|
||||
Placing placing = new Placing(context);
|
||||
int chunkX = context.originX() >> CHUNK_SHIFT;
|
||||
int chunkZ = context.originZ() >> CHUNK_SHIFT;
|
||||
long seed = chunkX * CHUNK_X_SEED_FACTOR + chunkZ * CHUNK_Z_SEED_FACTOR;
|
||||
long seed = context.chunkX() * CHUNK_X_SEED_FACTOR + context.chunkZ() * CHUNK_Z_SEED_FACTOR;
|
||||
long mask = 0;
|
||||
for (DepositGenerator generator : generators) {
|
||||
long finalSeed = seed * ++mask;
|
||||
@@ -294,7 +291,7 @@ final class DepositPlacer {
|
||||
if (!surfaceKnown) {
|
||||
for (int x = 0; x < CHUNK_WIDTH; x++) {
|
||||
for (int z = 0; z < CHUNK_WIDTH; z++) {
|
||||
surfaceHeights[x * CHUNK_WIDTH + z] = (int) Math.round(terrain.surfaceY(originX + x, originZ + z));
|
||||
surfaceHeights[x * CHUNK_WIDTH + z] = terrain.surfaceHeight(originX + x, originZ + z);
|
||||
}
|
||||
}
|
||||
surfaceKnown = true;
|
||||
@@ -318,19 +315,13 @@ final class DepositPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
BlockState match = matchDepositVariant(levelSettings(Target.REGION, worldX, worldZ), ore, worldY);
|
||||
SettingsStack<DepositVariantSettings> declared = settings.at(DepositVariantSettings.class, worldX, worldZ);
|
||||
BlockState match = matchDepositVariant(declared.level(Level.REGION), ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return matchDepositVariant(levelSettings(Target.DIMENSION, worldX, worldZ), ore, worldY);
|
||||
}
|
||||
|
||||
private Optional<DepositVariantSettings> levelSettings(Target level, int worldX, int worldZ) {
|
||||
return settings.at(DepositVariantSettings.class, worldX, worldZ).stream()
|
||||
.filter(entry -> entry.level() == level)
|
||||
.map(Entry::value)
|
||||
.findFirst();
|
||||
return matchDepositVariant(declared.dimension(), ore, worldY);
|
||||
}
|
||||
|
||||
private BlockState matchDepositVariant(Optional<DepositVariantSettings> owner, BlockState ore, int y) {
|
||||
|
||||
@@ -68,7 +68,6 @@ final class FloatingIslands {
|
||||
private static final int FIRST_LAYER_GENERATOR_SEED = 7235;
|
||||
private static final int MIN_PALETTE_DEPTH = 4;
|
||||
private static final int CHUNK_WIDTH = 16;
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
private static final BlockState BARRIER = new BlockState("minecraft:barrier");
|
||||
private static final BlockState FALLBACK_SOLID = new BlockState("minecraft:stone");
|
||||
private static final String DEFAULT_FLUID = "minecraft:water";
|
||||
@@ -449,9 +448,9 @@ final class FloatingIslands {
|
||||
this.originZ = context.originZ();
|
||||
this.output = context.hunk(BlockState.class);
|
||||
this.height = output.getHeight();
|
||||
this.blocks = context.resources().blocks();
|
||||
this.blocks = context.world().resources().blocks();
|
||||
this.settings = context.settings();
|
||||
this.explosion = PaletteExplosion.of(settings, originX + CHUNK_CENTRE, originZ + CHUNK_CENTRE);
|
||||
this.explosion = PaletteExplosion.of(settings, context.centreX(), context.centreZ());
|
||||
TerrainSampler terrain = context.terrain();
|
||||
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
|
||||
this.boundarySampler = new FloatingIslandBoundarySampler(world.host()::surfaceBiome);
|
||||
|
||||
@@ -50,8 +50,7 @@ public final class FloatingModule implements IrisModule {
|
||||
public void setup(ModuleSetup setup) {
|
||||
log = setup.log();
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(FloatingChildSettings.class);
|
||||
registry.registerSettings(MergeFloatingChildrenSettings.class);
|
||||
registry.registerSettings(FloatingChildSettings.class, MergeFloatingChildrenSettings.class);
|
||||
|
||||
var graph = setup.stages();
|
||||
graph.define(IrisStages.Floating.OBJECTS).softAfter(IrisStages.Objects.PLACE).reach(this::objectReach)
|
||||
|
||||
@@ -44,7 +44,6 @@ import java.util.Map;
|
||||
public final class PerfectionModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final String HALF = "half";
|
||||
private static final int CENTER = 7;
|
||||
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||
private static final Map<ResourceId, BlockState> ORE_BASES = oreBases();
|
||||
|
||||
@@ -63,7 +62,7 @@ public final class PerfectionModule implements IrisModule {
|
||||
if (hidesOres(context)) {
|
||||
hideOres(blocks, new IdentityHashMap<>());
|
||||
}
|
||||
Surfaces surfaces = new Surfaces(blocks, context.resources().blocks(), new IdentityHashMap<>());
|
||||
Surfaces surfaces = new Surfaces(blocks, context.world().resources().blocks(), new IdentityHashMap<>());
|
||||
boolean removed;
|
||||
do {
|
||||
removed = surfaces.removeUnsupportedDecorants();
|
||||
@@ -72,8 +71,8 @@ public final class PerfectionModule implements IrisModule {
|
||||
|
||||
/** The dimension's {@code hideOresForHiddenOre}, which every column of the chunk shares. */
|
||||
private static boolean hidesOres(ChunkStageContext context) {
|
||||
return context.settings().at(HideOresSettings.class, context.originX() + CENTER, context.originZ() + CENTER).stream()
|
||||
.anyMatch(entry -> entry.value().hide());
|
||||
return context.settings().at(HideOresSettings.class, context.centreX(), context.centreZ()).dimension()
|
||||
.map(HideOresSettings::hide).orElse(false);
|
||||
}
|
||||
|
||||
/** {@code hidden} remembers per state instance what it is hidden as, itself for a block that is no ore. */
|
||||
|
||||
@@ -38,9 +38,7 @@ public final class PostModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(PostProcessingSettings.class);
|
||||
registry.registerSettings(PostProcessingSlabsSettings.class);
|
||||
registry.registerSettings(PostProcessingWallsSettings.class);
|
||||
registry.registerSettings(PostProcessingSettings.class, PostProcessingSlabsSettings.class, PostProcessingWallsSettings.class);
|
||||
// Ordering only: iris:carve ships in the built-ins jar, which a pack may not have.
|
||||
setup.stages().define(IrisStages.Post.SMOOTH).softAfter(IrisStages.Carve.APPLY).run(SurfaceSmoothing::smooth);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
@@ -54,7 +53,6 @@ final class SurfaceSmoothing {
|
||||
private static final String SLAB_SUFFIX = "_slab";
|
||||
private static final String WATERLOGGED = "waterlogged";
|
||||
private static final String TRUE = "true";
|
||||
private static final int CENTER = 7;
|
||||
/** A biome without a wall or slab picks no block. */
|
||||
private static final PaletteLayer NO_LAYER = PaletteLayer.withoutBlocks();
|
||||
/** Walls and slabs are picked once per column: the first signature of a layer's noise. */
|
||||
@@ -79,7 +77,7 @@ final class SurfaceSmoothing {
|
||||
|
||||
private SurfaceSmoothing(ChunkStageContext context) {
|
||||
this.blocks = context.hunk(BlockState.class);
|
||||
this.registry = context.resources().blocks();
|
||||
this.registry = context.world().resources().blocks();
|
||||
this.terrain = context.terrain();
|
||||
this.settings = context.settings();
|
||||
this.layerBlocks = LayerBlocks.of(context.world());
|
||||
@@ -88,8 +86,8 @@ final class SurfaceSmoothing {
|
||||
this.originZ = context.originZ();
|
||||
this.planeWidth = blocks.getWidth() + 2;
|
||||
this.heights = heightPlane();
|
||||
this.walls = enabled(PostProcessingWallsSettings.class, PostProcessingWallsSettings::enabled, PostProcessingWallsSettings.DEFAULT_ENABLED);
|
||||
this.slabs = enabled(PostProcessingSlabsSettings.class, PostProcessingSlabsSettings::enabled, PostProcessingSlabsSettings.DEFAULT_ENABLED);
|
||||
this.walls = enabled(context, PostProcessingWallsSettings.class, PostProcessingWallsSettings::enabled, PostProcessingWallsSettings.DEFAULT_ENABLED);
|
||||
this.slabs = enabled(context, PostProcessingSlabsSettings.class, PostProcessingSlabsSettings::enabled, PostProcessingSlabsSettings.DEFAULT_ENABLED);
|
||||
this.fluidHeight = terrain.fluidHeight();
|
||||
}
|
||||
|
||||
@@ -112,15 +110,13 @@ final class SurfaceSmoothing {
|
||||
* corners are never read, so they are left unresolved.
|
||||
*/
|
||||
/** A switch of the dimension, which every column of the chunk shares. */
|
||||
private <S extends IrisFeature> boolean enabled(Class<S> type, Function<S, Boolean> enabled, boolean byDefault) {
|
||||
List<Entry<S>> entries = settings.at(type, originX + CENTER, originZ + CENTER);
|
||||
return entries.isEmpty() ? byDefault : enabled.apply(entries.getFirst().value());
|
||||
private static <S extends IrisFeature> boolean enabled(ChunkStageContext context, Class<S> type, Function<S, Boolean> enabled, boolean byDefault) {
|
||||
return context.settings().at(type, context.centreX(), context.centreZ()).dimension().map(enabled).orElse(byDefault);
|
||||
}
|
||||
|
||||
/** The biome layer of the column's surface biome that {@code type} holds, or none. */
|
||||
private <S extends IrisFeature> PaletteLayer biomeLayer(Class<S> type, Function<S, PaletteLayer> layer, int x, int z) {
|
||||
List<Entry<S>> entries = settings.at(type, x, z);
|
||||
return entries.isEmpty() ? NO_LAYER : layer.apply(entries.getLast().value());
|
||||
return settings.at(type, x, z).mostSpecific().map(layer).orElse(NO_LAYER);
|
||||
}
|
||||
|
||||
/** The layer's block at the position, picked with the world's post-processing random, or null when it has none. */
|
||||
@@ -146,7 +142,7 @@ final class SurfaceSmoothing {
|
||||
}
|
||||
|
||||
private int surfaceHeight(int x, int z) {
|
||||
return (int) Math.round(terrain.surfaceY(x, z));
|
||||
return terrain.surfaceHeight(x, z);
|
||||
}
|
||||
|
||||
private void post(int localX, int localZ) {
|
||||
|
||||
@@ -104,7 +104,7 @@ public final class BlocksModule implements IrisModule {
|
||||
if (!settings.edit().isEmpty()) {
|
||||
ObjectEdits.Edited edited = ObjectEdits.apply(settings.edit(), data, blockEntity, new RNG(context.random().nextLong()),
|
||||
offset.x() + placement.x(), offset.y() + anchorY, offset.z() + placement.z(),
|
||||
ResolvedReplaces.of(context, prepared.terrain()), placement);
|
||||
ResolvedReplaces.of(context), placement);
|
||||
data = edited.data();
|
||||
blockEntity = edited.blockEntity();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.stage.PlacementStageContext;
|
||||
|
||||
@@ -35,11 +34,8 @@ final class ResolvedReplaces {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
/** The replacements of the world {@code context} places in, or of the pack alone when the placement has no world. */
|
||||
static ResolvedReplaces of(PlacementStageContext context, PlacementTerrain terrain) {
|
||||
if (!terrain.hasWorld()) {
|
||||
return new ResolvedReplaces(context.resources().blocks());
|
||||
}
|
||||
/** The replacements of the world {@code context} places in. */
|
||||
static ResolvedReplaces of(PlacementStageContext context) {
|
||||
return context.world().state(ResolvedReplaces.class, world -> new ResolvedReplaces(world.resources().blocks()));
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public final class StiltModule implements IrisModule {
|
||||
/** The block the settings' palette picks for this placement, the same for every column; null without a palette. */
|
||||
private BlockState paletteBlock(StiltSettings stilt) {
|
||||
return stilt.palette()
|
||||
.map(spec -> context.resources().blocks().palette(spec, rng.getSeed()))
|
||||
.map(spec -> context.world().resources().blocks().palette(spec, rng.getSeed()))
|
||||
.map(picker -> picker.at(placement.x(), anchorY, placement.z()))
|
||||
.orElse(null);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public final class StiltModule implements IrisModule {
|
||||
return state;
|
||||
}
|
||||
return ObjectEdits.apply(config.edit(), state, Optional.empty(), rng, offset.x() + placement.x(), offset.y() + anchorY,
|
||||
offset.z() + placement.z(), ResolvedReplaces.of(context, prepared.terrain()), placement).data();
|
||||
offset.z() + placement.z(), ResolvedReplaces.of(context), placement).data();
|
||||
}
|
||||
|
||||
private void growToSurface(BlockState state, BlockPosition offset, int x, int z) {
|
||||
|
||||
@@ -22,9 +22,7 @@ import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.carve.CarvingEntry;
|
||||
import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Range;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackBiome;
|
||||
@@ -72,13 +70,7 @@ public final class CarvingResolver {
|
||||
}
|
||||
|
||||
private static List<CarvingEntry> dimensionEntries(PackWorld world) {
|
||||
List<CarvingEntry> dimensionEntries = new ArrayList<>();
|
||||
for (Entry<CarvingSettings> entry : world.settings().declared(CarvingSettings.class)) {
|
||||
if (entry.level() == Target.DIMENSION) {
|
||||
dimensionEntries.addAll(entry.value().entries());
|
||||
}
|
||||
}
|
||||
return dimensionEntries;
|
||||
return world.settings().declared(CarvingSettings.class).dimension().map(CarvingSettings::entries).orElse(List.of());
|
||||
}
|
||||
|
||||
/** Every declared entry, enabled or not. */
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.terrain.carving;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
@@ -46,19 +47,17 @@ public final class DeclaredByLevel<F extends IrisFeature> {
|
||||
}
|
||||
|
||||
public static <F extends IrisFeature> DeclaredByLevel<F> of(PackWorld world, Class<F> type) {
|
||||
F dimension = null;
|
||||
SettingsStack<F> declared = world.settings().declared(type);
|
||||
Map<ResourceId, F> regions = new HashMap<>();
|
||||
Map<ResourceId, F> biomes = new HashMap<>();
|
||||
for (Entry<F> entry : world.settings().declared(type)) {
|
||||
if (entry.level() == Target.DIMENSION) {
|
||||
dimension = entry.value();
|
||||
} else if (entry.level() == Target.REGION) {
|
||||
for (Entry<F> entry : declared) {
|
||||
if (entry.level() == Level.REGION) {
|
||||
regions.putIfAbsent(sampleId(entry.source()), entry.value());
|
||||
} else if (entry.level() == Target.BIOME) {
|
||||
} else if (entry.level() == Level.BIOME) {
|
||||
biomes.putIfAbsent(sampleId(entry.source()), entry.value());
|
||||
}
|
||||
}
|
||||
return new DeclaredByLevel<>(dimension, regions, biomes);
|
||||
return new DeclaredByLevel<>(declared.dimension().orElse(null), regions, biomes);
|
||||
}
|
||||
|
||||
/** The dimension's declaration; null when it declares none. */
|
||||
|
||||
@@ -29,8 +29,6 @@ import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -78,10 +76,7 @@ public final class FloatingWorld {
|
||||
}
|
||||
|
||||
private static List<CarvingEntry> dimensionCarvingOf(PackWorld world) {
|
||||
return world.settings().declared(CarvingSettings.class).stream()
|
||||
.filter(entry -> entry.level() == Target.DIMENSION)
|
||||
.map(Entry::value)
|
||||
.findFirst()
|
||||
return world.settings().declared(CarvingSettings.class).dimension()
|
||||
.map(CarvingSettings::entries)
|
||||
.orElse(List.of());
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ public final class SpawnModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(SpawnerSettings.class);
|
||||
registry.registerSettings(EffectSettings.class);
|
||||
registry.registerSettings(SpawnerSettings.class, EffectSettings.class);
|
||||
registry.registerHeldType(PlacementMarker.class);
|
||||
SpawnResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerService(EntitySpawns.class, new EntitySpawning());
|
||||
|
||||
Reference in new issue
Block a user