mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Read settings per column with every level as its own entry, add the mantle pipeline, host types and the one-option shorthand
Settings no longer resolve to one value per type. FeatureSettings.at(type, x, z) returns one entry per level that declares the type at that column (dimension, region, surface biome, placement), each with its level, source and value; levels stack and a module decides what several mean. Conditional stage bodies receive every configured entry. Chunk and mantle runners collect a chunk's settings themselves, so a stage runs when any column of the chunk configures it. Work that writes the mantle or reaches beyond its chunk moves to a new MANTLE pipeline (Stage.mantle, MantleRunner) that the host runs around a chunk before it generates. Chunk stages may no longer declare a reach or mantle writes and see the mantle read-only. Built-in settings may hold host types the host describes itself (ModuleHost.describingHostTypesIn, ValueKind.HostKind); pack modules cannot. FeatureSchema.shorthand() names the only option of settings packs may write as a bare value.
This commit is contained in:
1 parent
09df1af88e
commit
97ac2a2982
61 files changed
+1316
-184
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.FeatureAttachment;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** The settings one chunk's stages see: for every settings type the graph conditions on, each distinct
|
||||
* entry of the chunk's 16 by 16 columns. A stage is therefore active when any column of the chunk
|
||||
* configures its settings, also where a biome border crosses the chunk. Entries are distinct by level
|
||||
* and source and keep the order their first column was read in, columns by X and then Z.
|
||||
*/
|
||||
final class ChunkSettings {
|
||||
/** The chunk's width along X and Z, in blocks: the footprint of chunk and mantle stages. */
|
||||
static final int CHUNK_WIDTH = 16;
|
||||
|
||||
private ChunkSettings() {}
|
||||
|
||||
/** {@code settings} is asked only when the graph conditions a stage on settings. */
|
||||
static ConfiguredSettings collect(ResolvedGraph graph, Supplier<FeatureSettings> settings, int originX, int originZ) {
|
||||
if (graph.settingsTypes().isEmpty()) {
|
||||
return ConfiguredSettings.none();
|
||||
}
|
||||
var view = settings.get();
|
||||
var entries = new ArrayList<Entry<?>>();
|
||||
for (var type : graph.settingsTypes()) {
|
||||
entries.addAll(distinctEntries(type.asSubclass(IrisFeature.class), view, originX, originZ));
|
||||
}
|
||||
return ConfiguredSettings.of(entries);
|
||||
}
|
||||
|
||||
private static Collection<Entry<?>> distinctEntries(
|
||||
Class<? extends IrisFeature> type, FeatureSettings view, int originX, int originZ) {
|
||||
var distinct = new LinkedHashMap<Declaration, Entry<?>>();
|
||||
for (int x = 0; x < CHUNK_WIDTH; x++) {
|
||||
for (int z = 0; z < CHUNK_WIDTH; z++) {
|
||||
for (var entry : view.at(type, originX + x, originZ + z)) {
|
||||
distinct.putIfAbsent(new Declaration(entry.level(), entry.source()), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
return distinct.values();
|
||||
}
|
||||
|
||||
private record Declaration(FeatureAttachment.Target level, ResourceId source) {}
|
||||
}
|
||||
Reference in new issue
Block a user