mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Host the batch 2 IrisApi: settings stacks, tool world, chunk scan
- ChunkModuleSettings returns SettingsStacks and keeps them per pack snapshot (SettingsStacks), so at() allocates nothing for a column whose region and biome were seen before. - declaredInChunk is answered from the chunk's distinct regions and biomes, each asked for its settings once. - A studio paste runs in a ToolWorld with the pack's resources and settings and its own state, so world() always answers. - Level replaces FeatureAttachment.Target across decoding, schema and packaging; IrisTerrainSampler gives surfaceHeight. - Tests: chunk scan parity and order, the stack cache, the tool world; engine mocks now serve pack resources as real engines do.
This commit is contained in:
1 parent
466d5149db
commit
7fc4445ab7
64 files changed
+844
-448
No files matched your search
@@ -39,7 +39,7 @@ import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import art.arcane.iris.core.modules.ModuleSettings;
|
||||
import art.arcane.iris.core.modules.ModuleTargets;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import art.arcane.iris.util.common.parallel.BurstExecutor;
|
||||
import art.arcane.iris.util.common.parallel.MultiBurst;
|
||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||
@@ -418,7 +418,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
rawText = IO.readAll(j);
|
||||
JSONObject parsed = new JSONObject(rawText);
|
||||
Optional<Target> moduleTarget = ModuleTargets.ofResource(objectClass);
|
||||
Optional<Level> moduleTarget = ModuleTargets.ofResource(objectClass);
|
||||
JsonSchemaValidator.validateTopLevelKeys(parsed, rawText, j, resourceTypeName, objectClass, moduleKeys(moduleTarget));
|
||||
T t = getManager().getGson()
|
||||
.fromJson(preprocess(parsed).toString(0), objectClass);
|
||||
@@ -438,11 +438,11 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
}
|
||||
|
||||
/** The keys the pack's modules read at {@code target}; none for resources that hold no module settings. */
|
||||
private Set<String> moduleKeys(Optional<Target> target) {
|
||||
private Set<String> moduleKeys(Optional<Level> target) {
|
||||
return target.map(found -> getManager().getModules().settings().keys(found)).orElse(Set.of());
|
||||
}
|
||||
|
||||
private ModuleSettings decodeModuleSettings(Target target, JSONObject json, String name) {
|
||||
private ModuleSettings decodeModuleSettings(Level target, JSONObject json, String name) {
|
||||
return getManager().getModules().settings().decode(target, json, resourceTypeName + " " + name);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,26 +21,31 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.generation.ChunkContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Module settings at world columns, for one engine: the dimension's entry, then the entry of the column's
|
||||
* region, then the one of its surface biome. Each level that declares the settings is its own entry; levels
|
||||
* stack and are never merged, so a module sees all of them and decides what several mean.
|
||||
* stack and are never merged, so a module sees all of them and decides what several mean. The stacks are kept
|
||||
* per pack snapshot ({@link SettingsStacks}), so a column whose region and biome were seen before costs no allocation.
|
||||
*/
|
||||
final class ChunkModuleSettings implements FeatureSettings {
|
||||
private static final String DIMENSION = "dimension";
|
||||
private static final String REGION = "region";
|
||||
private static final String BIOME = "biome";
|
||||
|
||||
/** The registrants whose settings stack at a column. */
|
||||
/** The registrants whose settings stack at a column, and the snapshot that keeps their stacks. */
|
||||
interface Levels {
|
||||
IrisRegistrant dimension();
|
||||
|
||||
@@ -50,10 +55,14 @@ final class ChunkModuleSettings implements FeatureSettings {
|
||||
|
||||
/** The biome a {@code BiomeSample} names by {@code id}, or null when the dimension has no such biome. */
|
||||
IrisBiome biome(ResourceId id);
|
||||
|
||||
/** The stacks of the snapshot the registrants belong to. */
|
||||
SettingsStacks stacks();
|
||||
}
|
||||
|
||||
private final Levels levels;
|
||||
private final PackResourceIds ids;
|
||||
private SettingsStacks stacks;
|
||||
|
||||
ChunkModuleSettings(Engine engine, PackResourceIds ids) {
|
||||
this(new EngineLevels(engine), ids);
|
||||
@@ -65,12 +74,49 @@ final class ChunkModuleSettings implements FeatureSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
List<Entry<F>> entries = new ArrayList<>(Target.values().length);
|
||||
addEntry(entries, featureType, Target.DIMENSION, DIMENSION, levels.dimension());
|
||||
addEntry(entries, featureType, Target.REGION, REGION, levels.region(worldX, worldZ));
|
||||
addEntry(entries, featureType, Target.BIOME, BIOME, levels.surfaceBiome(worldX, worldZ));
|
||||
return entries.isEmpty() ? List.of() : List.copyOf(entries);
|
||||
public <F extends IrisFeature> SettingsStack<F> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
IrisRegistrant dimension = levels.dimension();
|
||||
IrisRegistrant region = levels.region(worldX, worldZ);
|
||||
IrisRegistrant biome = levels.surfaceBiome(worldX, worldZ);
|
||||
ModuleSettings dimensionSettings = settingsOf(dimension);
|
||||
ModuleSettings regionSettings = settingsOf(region);
|
||||
ModuleSettings biomeSettings = settingsOf(biome);
|
||||
SettingsStacks snapshotStacks = snapshotStacks();
|
||||
SettingsStack<F> known = snapshotStacks.find(dimensionSettings, regionSettings, biomeSettings, featureType);
|
||||
if (known != null) {
|
||||
return known;
|
||||
}
|
||||
SettingsStack<F> stack = stackOf(featureType, dimension, region, biome);
|
||||
snapshotStacks.remember(dimensionSettings, regionSettings, biomeSettings, featureType, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
private SettingsStacks snapshotStacks() {
|
||||
if (stacks == null) {
|
||||
stacks = levels.stacks();
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
/** Answered from the distinct regions and surface biomes of the chunk's columns, each asked for its settings once. */
|
||||
@Override
|
||||
public <F extends IrisFeature> SettingsStack<F> declaredInChunk(Class<F> featureType, int chunkX, int chunkZ) {
|
||||
List<IrisRegistrant> regions = new ArrayList<>();
|
||||
List<IrisRegistrant> biomes = new ArrayList<>();
|
||||
int originX = chunkX * ChunkContext.CHUNK_WIDTH;
|
||||
int originZ = chunkZ * ChunkContext.CHUNK_WIDTH;
|
||||
for (int x = 0; x < ChunkContext.CHUNK_WIDTH; x++) {
|
||||
for (int z = 0; z < ChunkContext.CHUNK_WIDTH; z++) {
|
||||
addDistinct(regions, levels.region(originX + x, originZ + z));
|
||||
addDistinct(biomes, levels.surfaceBiome(originX + x, originZ + z));
|
||||
}
|
||||
}
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
Set<ResourceId> sources = new HashSet<>();
|
||||
addEntry(entries, sources, featureType, Level.DIMENSION, DIMENSION, levels.dimension());
|
||||
regions.forEach(region -> addEntry(entries, sources, featureType, Level.REGION, REGION, region));
|
||||
biomes.forEach(biome -> addEntry(entries, sources, featureType, Level.BIOME, BIOME, biome));
|
||||
return SettingsStack.of(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,13 +125,45 @@ final class ChunkModuleSettings implements FeatureSettings {
|
||||
return declared == null ? Optional.empty() : declared.getModuleSettings().find(featureType);
|
||||
}
|
||||
|
||||
private <F extends IrisFeature> void addEntry(List<Entry<F>> entries, Class<F> featureType, Target level, String kind,
|
||||
IrisRegistrant owner) {
|
||||
private <F extends IrisFeature> SettingsStack<F> stackOf(Class<F> featureType, IrisRegistrant dimension, IrisRegistrant region,
|
||||
IrisRegistrant biome) {
|
||||
List<Entry<F>> entries = new ArrayList<>(Level.values().length);
|
||||
Set<ResourceId> sources = new HashSet<>();
|
||||
addEntry(entries, sources, featureType, Level.DIMENSION, DIMENSION, dimension);
|
||||
addEntry(entries, sources, featureType, Level.REGION, REGION, region);
|
||||
addEntry(entries, sources, featureType, Level.BIOME, BIOME, biome);
|
||||
return entries.isEmpty() ? SettingsStack.empty() : SettingsStack.of(entries);
|
||||
}
|
||||
|
||||
private <F extends IrisFeature> void addEntry(List<Entry<F>> entries, Set<ResourceId> sources, Class<F> featureType, Level level,
|
||||
String kind, IrisRegistrant owner) {
|
||||
if (owner == null) {
|
||||
return;
|
||||
}
|
||||
owner.getModuleSettings().find(featureType)
|
||||
.ifPresent(value -> entries.add(new Entry<>(level, ids.of(kind, owner.getLoadKey()), value)));
|
||||
Optional<F> declared = owner.getModuleSettings().find(featureType);
|
||||
if (declared.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ResourceId source = ids.of(kind, owner.getLoadKey());
|
||||
if (sources.add(source)) {
|
||||
entries.add(new Entry<>(level, source, declared.get()));
|
||||
}
|
||||
}
|
||||
|
||||
private static ModuleSettings settingsOf(IrisRegistrant owner) {
|
||||
return owner == null ? ModuleSettings.NONE : owner.getModuleSettings();
|
||||
}
|
||||
|
||||
private static void addDistinct(List<IrisRegistrant> owners, IrisRegistrant owner) {
|
||||
if (owner == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisRegistrant known : owners) {
|
||||
if (known == owner) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
owners.add(owner);
|
||||
}
|
||||
|
||||
/** The dimension, region and surface biome the engine generates a column with. */
|
||||
@@ -107,7 +185,16 @@ final class ChunkModuleSettings implements FeatureSettings {
|
||||
|
||||
@Override
|
||||
public IrisBiome biome(ResourceId id) {
|
||||
return ((IrisPackResources) engine.getData().getPackResources()).irisBiome(id).orElse(null);
|
||||
return packResources().irisBiome(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStacks stacks() {
|
||||
return packResources().settingsStacks();
|
||||
}
|
||||
|
||||
private IrisPackResources packResources() {
|
||||
return (IrisPackResources) engine.getData().getPackResources();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,7 +43,7 @@ final class DimensionSettings implements PackSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return IrisPackSettings.declaredBy(dimension, () -> data, ids, featureType);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import com.volmit.generation.GenerationContext;
|
||||
import com.volmit.host.MantleRegistration;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
@@ -102,15 +101,6 @@ final class IrisGenerationContext implements GenerationContext {
|
||||
return (com.volmit.hunk.Hunk<T>) blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long worldSeed() {
|
||||
return engine.getSeedManager().getSeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return engine.getData().getPackResources();
|
||||
}
|
||||
|
||||
/** The world this invocation first asked for; it keeps it if the world restarts meanwhile. */
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.volmit.generation.MantleGenerationContext;
|
||||
import com.volmit.host.MantleRegistration;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
@@ -89,15 +88,6 @@ final class IrisMantleGenerationContext implements MantleGenerationContext {
|
||||
return mantle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long worldSeed() {
|
||||
return engine.getSeedManager().getSeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return engine.getData().getPackResources();
|
||||
}
|
||||
|
||||
/** The world this invocation first asked for; it keeps it if the world restarts meanwhile. */
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.iris.util.project.noise.NoiseType;
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
@@ -235,15 +235,15 @@ final class IrisObjectHost implements ObjectHost {
|
||||
public <F extends IrisFeature> List<Declaration<F>> declarations(Class<F> type) {
|
||||
List<Declaration<F>> found = new ArrayList<>();
|
||||
for (IrisRegion region : engine.getDimension().getAllRegions(engine)) {
|
||||
addDeclaration(found, Target.REGION, region, type);
|
||||
addDeclaration(found, Level.REGION, region, type);
|
||||
}
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
addDeclaration(found, Target.BIOME, biome, type);
|
||||
addDeclaration(found, Level.BIOME, biome, type);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private static <F extends IrisFeature> void addDeclaration(List<Declaration<F>> found, Target level, IrisRegistrant owner, Class<F> type) {
|
||||
private static <F extends IrisFeature> void addDeclaration(List<Declaration<F>> found, Level level, IrisRegistrant owner, Class<F> type) {
|
||||
if (owner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public final class IrisPackResources implements PackResources {
|
||||
private final IrisData data;
|
||||
private final PackResourceIds ids;
|
||||
private final UUID snapshotId = UUID.randomUUID();
|
||||
private final SettingsStacks settingsStacks = new SettingsStacks();
|
||||
private final BlockRegistry blocks;
|
||||
private final ItemRegistry items = new IrisItemRegistry();
|
||||
private final NoiseFactory noise;
|
||||
@@ -107,6 +108,11 @@ public final class IrisPackResources implements PackResources {
|
||||
return snapshotId;
|
||||
}
|
||||
|
||||
/** The settings stacks of this snapshot's columns, which every world generating with it shares. */
|
||||
SettingsStacks settingsStacks() {
|
||||
return settingsStacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs {@code announce}, which tells the pack's modules that this snapshot loaded, unless it ran successfully for
|
||||
* this snapshot before: modules hear of each snapshot once, however many worlds start with it.
|
||||
|
||||
@@ -27,10 +27,11 @@ 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;
|
||||
import art.arcane.iris.util.common.data.DataProvider;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -83,26 +84,26 @@ public final class IrisPackSettings implements PackSettings, ObjectHost.Source,
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
return declaredBy(engine.getDimension(), engine, ids, featureType);
|
||||
}
|
||||
|
||||
/** The settings of {@code featureType} that {@code dimension} and every region and biome it reaches declare, in that order. */
|
||||
static <F extends IrisFeature> List<Entry<F>> declaredBy(IrisDimension dimension, DataProvider data, PackResourceIds ids,
|
||||
static <F extends IrisFeature> SettingsStack<F> declaredBy(IrisDimension dimension, DataProvider data, PackResourceIds ids,
|
||||
Class<F> featureType) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntry(entries, featureType, Target.DIMENSION, ids.of(DIMENSION, dimension.getLoadKey()), dimension);
|
||||
addEntry(entries, featureType, Level.DIMENSION, ids.of(DIMENSION, dimension.getLoadKey()), dimension);
|
||||
for (IrisRegion region : dimension.getAllRegions(data)) {
|
||||
addEntry(entries, featureType, Target.REGION, ids.of(REGION, region.getLoadKey()), region);
|
||||
addEntry(entries, featureType, Level.REGION, ids.of(REGION, region.getLoadKey()), region);
|
||||
}
|
||||
for (IrisBiome biome : dimension.getReachableBiomes(data)) {
|
||||
addEntry(entries, featureType, Target.BIOME, ids.of(BIOME, biome.getLoadKey()), biome);
|
||||
addEntry(entries, featureType, Level.BIOME, ids.of(BIOME, biome.getLoadKey()), biome);
|
||||
}
|
||||
return List.copyOf(entries);
|
||||
return SettingsStack.of(entries);
|
||||
}
|
||||
|
||||
/** Adds {@code owner}'s settings of {@code featureType}, if it declares them, as an entry from {@code source}. */
|
||||
static <F extends IrisFeature> void addEntry(List<Entry<F>> entries, Class<F> featureType, Target level, ResourceId source,
|
||||
static <F extends IrisFeature> void addEntry(List<Entry<F>> entries, Class<F> featureType, Level level, ResourceId source,
|
||||
IrisRegistrant owner) {
|
||||
owner.getModuleSettings().find(featureType).ifPresent(value -> entries.add(new Entry<>(level, source, value)));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.object.ObjectTransformer;
|
||||
import com.volmit.placement.PlacementContext;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.BiomeSample;
|
||||
import com.volmit.world.BlockView;
|
||||
@@ -32,27 +31,28 @@ import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** The read-only IrisApi inputs of one Iris object placement. */
|
||||
final class IrisPlacementInputs implements PlacementContext {
|
||||
private final ObjectTransformer objects = new IrisObjectTransformer();
|
||||
private final long worldSeed;
|
||||
private final TerrainSampler terrain;
|
||||
private final FeatureSettings settings;
|
||||
private final BlockView blocks;
|
||||
private final PackResources resources;
|
||||
private final Engine engine;
|
||||
private final Supplier<PackWorld> worldSource;
|
||||
private PackWorld world;
|
||||
|
||||
/** @param engine the engine whose world the placement generates in, or null for a placement without one */
|
||||
IrisPlacementInputs(long worldSeed, TerrainSampler terrain, FeatureSettings settings, BlockView blocks, PackResources resources,
|
||||
Engine engine) {
|
||||
this.resources = resources;
|
||||
this.engine = engine;
|
||||
this.worldSeed = worldSeed;
|
||||
/** @param worldSource the world the placement generates in, asked for the first time a stage needs it */
|
||||
IrisPlacementInputs(TerrainSampler terrain, FeatureSettings settings, BlockView blocks, Supplier<PackWorld> worldSource) {
|
||||
this.terrain = terrain;
|
||||
this.settings = settings;
|
||||
this.blocks = blocks;
|
||||
this.worldSource = worldSource;
|
||||
}
|
||||
|
||||
/** The world of the engine's runtime, as it is when the placement first asks. */
|
||||
static Supplier<PackWorld> worldOf(Engine engine) {
|
||||
return () -> engine.getGeneration().world();
|
||||
}
|
||||
|
||||
/** For placements without an engine, such as pasting an object into a world Iris does not generate. */
|
||||
@@ -119,24 +119,11 @@ final class IrisPlacementInputs implements PlacementContext {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long worldSeed() {
|
||||
return worldSeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
/** The world this placement first asked for; it keeps it if the world restarts meanwhile. */
|
||||
@Override
|
||||
public PackWorld world() {
|
||||
if (engine == null) {
|
||||
throw new IllegalStateException("This placement runs without an Iris engine, so it is not part of a world");
|
||||
}
|
||||
if (world == null) {
|
||||
world = engine.getGeneration().world();
|
||||
world = worldSource.get();
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,11 @@ final class IrisTerrainSampler implements TerrainSampler {
|
||||
return engine.getComplex().getHeightStream().get(worldX, worldZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int surfaceHeight(int worldX, int worldZ) {
|
||||
return (int) Math.round(surfaceY(worldX, worldZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeSample biome(int worldX, int y, int worldZ) {
|
||||
requireInside(worldX, y, worldZ);
|
||||
|
||||
@@ -86,7 +86,16 @@ final class IrisUpperDimension implements UpperDimension {
|
||||
|
||||
@Override
|
||||
public IrisBiome biome(ResourceId id) {
|
||||
return ((IrisPackResources) upper.getData().getPackResources()).irisBiome(id).orElse(null);
|
||||
return packResources().irisBiome(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStacks stacks() {
|
||||
return packResources().settingsStacks();
|
||||
}
|
||||
|
||||
private IrisPackResources packResources() {
|
||||
return (IrisPackResources) upper.getData().getPackResources();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,8 @@ import java.util.function.BiConsumer;
|
||||
* rejects the placement.
|
||||
* <p>
|
||||
* Each stage draws from its own stream of one seed per placement, from the world seed and the placement's
|
||||
* identity: the object and the requested position. Without an engine there is no world seed, so one draw
|
||||
* from the caller's random stands in for it.
|
||||
* identity: the object and the requested position. Without an engine, such as for a studio paste, the placement
|
||||
* runs in a {@link ToolWorld} of its own, whose seed is one draw from the caller's random.
|
||||
*/
|
||||
public final class ModuleObjectPlacement {
|
||||
private static final String UNNAMED_OBJECT = "unnamed";
|
||||
@@ -85,16 +85,18 @@ public final class ModuleObjectPlacement {
|
||||
ResourceId source = ids.of("object", objectKey);
|
||||
PlacementRequest request = new PlacementRequest(ids.of("placement/" + objectKey + "/" + x + "/" + requestedY + "/" + z),
|
||||
geometry, new BlockPosition(x, requestedY, z));
|
||||
IrisPlacementInputs inputs = new IrisPlacementInputs(worldSeed, terrain(engine, ids, area),
|
||||
new PlacementModuleSettings(worldSettings(engine, ids), config.getModuleSettings(), source),
|
||||
new PlacerBlockView(placer, area, states), data.getPackResources(), engine);
|
||||
long seed = ModuleSeeds.placement(worldSeed, objectKey, x, requestedY, z);
|
||||
StageMetrics metrics = new StageMetrics(engine != null ? engine.getMetrics() : null);
|
||||
PlacementOutcome outcome = placement.runBound(() -> new PlacementRunner(graph)
|
||||
.place(request, edit, inputs, seed, config.getModuleSettings().placement(source), metrics));
|
||||
return outcome.isPlaced()
|
||||
? ObjectPlacementResult.placed(placement.anchorY())
|
||||
: ObjectPlacementResult.rejected(outcome.rejection().orElseThrow());
|
||||
try (ToolWorld toolWorld = engine == null ? new ToolWorld(worldSeed, data.getPackResources(), new PackDeclaredSettings(data)) : null) {
|
||||
IrisPlacementInputs inputs = new IrisPlacementInputs(terrain(engine, ids, area),
|
||||
new PlacementModuleSettings(worldSettings(engine, ids), config.getModuleSettings(), source),
|
||||
new PlacerBlockView(placer, area, states), engine != null ? IrisPlacementInputs.worldOf(engine) : () -> toolWorld);
|
||||
PlacementOutcome outcome = placement.runBound(() -> new PlacementRunner(graph)
|
||||
.place(request, edit, inputs, seed, config.getModuleSettings().placement(source), metrics));
|
||||
return outcome.isPlaced()
|
||||
? ObjectPlacementResult.placed(placement.anchorY())
|
||||
: ObjectPlacementResult.rejected(outcome.rejection().orElseThrow());
|
||||
}
|
||||
}
|
||||
|
||||
/** Smart boring adds the object's bored air, so it has to happen before the geometry is read. */
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.OptionsMetadata;
|
||||
@@ -73,8 +73,8 @@ public final class ModuleSettingsDecoder {
|
||||
private static final String SNIPPET_FOLDER = "snippet";
|
||||
private static final String JSON_EXTENSION = ".json";
|
||||
|
||||
private final Map<Target, List<FeatureDescriptor<?>>> settings = new EnumMap<>(Target.class);
|
||||
private final Map<Target, Set<String>> keys = new EnumMap<>(Target.class);
|
||||
private final Map<Level, List<FeatureDescriptor<?>>> settings = new EnumMap<>(Level.class);
|
||||
private final Map<Level, Set<String>> keys = new EnumMap<>(Level.class);
|
||||
private final Path packFolder;
|
||||
private final Gson gson;
|
||||
private final Supplier<Gson> irisGson;
|
||||
@@ -89,14 +89,14 @@ public final class ModuleSettingsDecoder {
|
||||
.registerTypeAdapterFactory(new HostTypes())
|
||||
.registerTypeAdapterFactory(new SnippetReferences())
|
||||
.create();
|
||||
for (Target target : Target.values()) {
|
||||
for (Level target : Level.values()) {
|
||||
settings.put(target, settingsAt(catalog, target));
|
||||
keys.put(target, keysAt(catalog, target));
|
||||
}
|
||||
}
|
||||
|
||||
/** Every JSON key the pack's modules read at {@code target}: the keys of their features, object generators' included. */
|
||||
public Set<String> keys(Target target) {
|
||||
public Set<String> keys(Level target) {
|
||||
return keys.get(target);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class ModuleSettingsDecoder {
|
||||
* @param resource names the file in errors, such as {@code biome desert/dunes}
|
||||
* @throws IllegalArgumentException when a value does not decode into its settings type
|
||||
*/
|
||||
public ModuleSettings decode(Target target, JSONObject json, String resource) {
|
||||
public ModuleSettings decode(Level target, JSONObject json, String resource) {
|
||||
Map<Class<? extends IrisFeature>, IrisFeature> values = new LinkedHashMap<>();
|
||||
for (FeatureDescriptor<?> feature : settings.get(target)) {
|
||||
if (json.has(feature.key())) {
|
||||
@@ -135,7 +135,7 @@ public final class ModuleSettingsDecoder {
|
||||
* The JSON that declares {@code values} at {@code target}: each settings feature under its key, in the shape the
|
||||
* feature is written in (a rooted feature as its root option's value), the inverse of {@link #decode}.
|
||||
*/
|
||||
public JSONObject encode(Target target, ModuleSettings values) {
|
||||
public JSONObject encode(Level target, ModuleSettings values) {
|
||||
JSONObject json = new JSONObject();
|
||||
for (FeatureDescriptor<?> feature : settings.get(target)) {
|
||||
values.find(feature.type()).ifPresent(value -> json.put(feature.key(), writtenShape(feature, value)));
|
||||
@@ -210,17 +210,17 @@ public final class ModuleSettingsDecoder {
|
||||
.orElseThrow(() -> new IllegalStateException("Root " + root + " is no option of " + feature.type().getName()));
|
||||
}
|
||||
|
||||
private static List<FeatureDescriptor<?>> settingsAt(FeatureCatalog catalog, Target target) {
|
||||
private static List<FeatureDescriptor<?>> settingsAt(FeatureCatalog catalog, Level target) {
|
||||
return catalog.settings().stream()
|
||||
.filter(feature -> feature.attachment().targets().contains(target))
|
||||
.filter(feature -> feature.targets().contains(target))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static Set<String> keysAt(FeatureCatalog catalog, Target target) {
|
||||
private static Set<String> keysAt(FeatureCatalog catalog, Level target) {
|
||||
Stream<FeatureDescriptor<?>> objects = catalog.objects().stream().map(ObjectRegistration::descriptor);
|
||||
Set<String> found = new TreeSet<>();
|
||||
Stream.concat(catalog.settings().stream(), objects)
|
||||
.filter(feature -> feature.attachment().targets().contains(target))
|
||||
.filter(feature -> feature.targets().contains(target))
|
||||
.forEach(feature -> found.add(feature.key()));
|
||||
return Set.copyOf(found);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
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;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
@@ -34,17 +34,17 @@ import java.util.Set;
|
||||
* Which Iris class holds the JSON of each attachment target that module settings can appear in.
|
||||
*/
|
||||
public final class ModuleTargets {
|
||||
private static final Map<Target, Class<?>> HOLDERS = Map.of(
|
||||
Target.DIMENSION, IrisDimension.class,
|
||||
Target.REGION, IrisRegion.class,
|
||||
Target.BIOME, IrisBiome.class,
|
||||
Target.OBJECT_PLACEMENT, IrisObjectPlacement.class);
|
||||
private static final Map<Level, Class<?>> HOLDERS = Map.of(
|
||||
Level.DIMENSION, IrisDimension.class,
|
||||
Level.REGION, IrisRegion.class,
|
||||
Level.BIOME, IrisBiome.class,
|
||||
Level.PLACEMENT, IrisObjectPlacement.class);
|
||||
|
||||
private ModuleTargets() {
|
||||
}
|
||||
|
||||
/** The target whose JSON a resource of {@code resourceType} is, if module settings can appear in it. */
|
||||
public static Optional<Target> ofResource(Class<?> resourceType) {
|
||||
public static Optional<Level> ofResource(Class<?> resourceType) {
|
||||
return HOLDERS.entrySet().stream()
|
||||
.filter(entry -> entry.getValue() == resourceType)
|
||||
.map(Map.Entry::getKey)
|
||||
@@ -52,8 +52,8 @@ public final class ModuleTargets {
|
||||
}
|
||||
|
||||
/** Iris's own JSON fields per target, which no settings key may take. */
|
||||
static Map<Target, Set<String>> reservedFields() {
|
||||
Map<Target, Set<String>> fields = new EnumMap<>(Target.class);
|
||||
static Map<Level, Set<String>> reservedFields() {
|
||||
Map<Level, Set<String>> fields = new EnumMap<>(Level.class);
|
||||
HOLDERS.forEach((target, holder) -> fields.put(target, JsonFieldNames.of(holder)));
|
||||
return fields;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Supplier;
|
||||
@@ -66,7 +66,7 @@ public final class ObjectPlacementSettingsReader implements TypeAdapterFactory {
|
||||
JsonElement json = elements.read(in);
|
||||
IrisObjectPlacement placement = placements.fromJsonTree(json);
|
||||
if (placement != null && json.isJsonObject()) {
|
||||
placement.setModuleSettings(decoder.get().decode(Target.OBJECT_PLACEMENT,
|
||||
placement.setModuleSettings(decoder.get().decode(Level.PLACEMENT,
|
||||
new JSONObject(json.toString()), "object placement at " + path));
|
||||
}
|
||||
return placement;
|
||||
|
||||
@@ -21,10 +21,11 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -45,16 +46,16 @@ final class PackDeclaredSettings implements PackSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntries(entries, featureType, Target.DIMENSION, IrisPackSettings.DIMENSION, data.getDimensionLoader());
|
||||
addEntries(entries, featureType, Target.REGION, IrisPackSettings.REGION, data.getRegionLoader());
|
||||
addEntries(entries, featureType, Target.BIOME, IrisPackSettings.BIOME, data.getBiomeLoader());
|
||||
return List.copyOf(entries);
|
||||
addEntries(entries, featureType, Level.DIMENSION, IrisPackSettings.DIMENSION, data.getDimensionLoader());
|
||||
addEntries(entries, featureType, Level.REGION, IrisPackSettings.REGION, data.getRegionLoader());
|
||||
addEntries(entries, featureType, Level.BIOME, IrisPackSettings.BIOME, data.getBiomeLoader());
|
||||
return SettingsStack.of(entries);
|
||||
}
|
||||
|
||||
private <F extends IrisFeature, R extends IrisRegistrant> void addEntries(List<Entry<F>> entries, Class<F> featureType,
|
||||
Target level, String kind, ResourceLoader<R> loader) {
|
||||
Level level, String kind, ResourceLoader<R> loader) {
|
||||
for (String key : Arrays.stream(loader.getPossibleKeys()).sorted().toList()) {
|
||||
R owner = loader.load(key, false);
|
||||
if (owner != null) {
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -34,8 +35,8 @@ import java.util.Optional;
|
||||
final class PlacementModuleSettings implements FeatureSettings {
|
||||
private static final FeatureSettings NO_WORLD = new FeatureSettings() {
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
return List.of();
|
||||
public <F extends IrisFeature> SettingsStack<F> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
return SettingsStack.empty();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,14 +56,14 @@ final class PlacementModuleSettings implements FeatureSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
List<Entry<F>> worldEntries = world.at(featureType, worldX, worldZ);
|
||||
public <F extends IrisFeature> SettingsStack<F> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
SettingsStack<F> worldEntries = world.at(featureType, worldX, worldZ);
|
||||
Optional<F> own = placement.find(featureType);
|
||||
if (own.isEmpty()) {
|
||||
return worldEntries;
|
||||
}
|
||||
List<Entry<F>> entries = new ArrayList<>(worldEntries);
|
||||
entries.add(new Entry<>(Target.OBJECT_PLACEMENT, source, own.get()));
|
||||
return List.copyOf(entries);
|
||||
List<Entry<F>> entries = new ArrayList<>(worldEntries.entries());
|
||||
entries.add(new Entry<>(Level.PLACEMENT, source, own.get()));
|
||||
return SettingsStack.of(entries);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.SettingsStack;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* The settings stacks of one pack snapshot, kept per settings type and per the module settings of the dimension, region
|
||||
* and surface biome that make each one, so that a column whose combination was seen before gets its stack without
|
||||
* allocating. Every registrant of a snapshot decodes its own module settings, so the instances, compared by identity,
|
||||
* stand for the registrants; a missing level is {@link ModuleSettings#NONE}, which declares nothing either.
|
||||
*/
|
||||
final class SettingsStacks {
|
||||
private final Map<ModuleSettings, Map<ModuleSettings, Map<ModuleSettings, Map<Class<?>, SettingsStack<?>>>>> byDimension =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
/** The stack remembered for the combination, or null when none was yet. */
|
||||
@SuppressWarnings("unchecked")
|
||||
<F extends IrisFeature> SettingsStack<F> find(ModuleSettings dimension, ModuleSettings region, ModuleSettings biome, Class<F> type) {
|
||||
var byRegion = byDimension.get(dimension);
|
||||
if (byRegion == null) {
|
||||
return null;
|
||||
}
|
||||
var byBiome = byRegion.get(region);
|
||||
if (byBiome == null) {
|
||||
return null;
|
||||
}
|
||||
var byType = byBiome.get(biome);
|
||||
return byType == null ? null : (SettingsStack<F>) byType.get(type);
|
||||
}
|
||||
|
||||
<F extends IrisFeature> void remember(ModuleSettings dimension, ModuleSettings region, ModuleSettings biome, Class<F> type,
|
||||
SettingsStack<F> stack) {
|
||||
byDimension.computeIfAbsent(dimension, ignored -> new ConcurrentHashMap<>())
|
||||
.computeIfAbsent(region, ignored -> new ConcurrentHashMap<>())
|
||||
.computeIfAbsent(biome, ignored -> new ConcurrentHashMap<>())
|
||||
.put(type, stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.host.WorldStates;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* The world of one placement a tool makes outside the worlds Iris generates, such as a studio paste: the pack's
|
||||
* resources and settings, the seed the placement draws, and state that lives as long as the placement. It has no
|
||||
* dimension, so its bottom is Y 0, and no lifecycle hook runs for it. Closing it closes the state modules kept.
|
||||
*/
|
||||
final class ToolWorld implements PackWorld, AutoCloseable {
|
||||
private final long seed;
|
||||
private final PackResources resources;
|
||||
private final PackSettings settings;
|
||||
private final WorldStates states;
|
||||
private final ModuleLog log;
|
||||
private final Map<ModuleLog, ToolWorld> viewsByLog;
|
||||
|
||||
ToolWorld(long seed, PackResources resources, PackSettings settings) {
|
||||
this(seed, resources, settings, new WorldStates(), IrisApiLogger.hostLog(), new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
private ToolWorld(long seed, PackResources resources, PackSettings settings, WorldStates states, ModuleLog log,
|
||||
Map<ModuleLog, ToolWorld> viewsByLog) {
|
||||
this.seed = seed;
|
||||
this.resources = resources;
|
||||
this.settings = settings;
|
||||
this.states = states;
|
||||
this.log = log;
|
||||
this.viewsByLog = viewsByLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackSettings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T state(Class<T> type, Function<? super PackWorld, ? extends T> create) {
|
||||
return states.state(type, () -> create.apply(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackWorld withLog(ModuleLog log) {
|
||||
return viewsByLog.computeIfAbsent(log, moduleLog -> new ToolWorld(seed, resources, settings, states, moduleLog, viewsByLog));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
states.close();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||
import art.arcane.volmlib.util.scheduling.O;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -201,7 +201,7 @@ public class IrisPackageCompiler {
|
||||
}
|
||||
b.append(structureClosure.writeTo(folder, minify));
|
||||
b.append(ImageMapPackageClosure.writeAll(dm, folder, minify));
|
||||
a = withModuleSettings(dimension, Target.DIMENSION, dm).toString(minify ? 0 : 4);
|
||||
a = withModuleSettings(dimension, Level.DIMENSION, dm).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
|
||||
@@ -215,7 +215,7 @@ public class IrisPackageCompiler {
|
||||
b = new StringBuilder();
|
||||
|
||||
for (IrisRegion i : regions) {
|
||||
a = withModuleSettings(i, Target.REGION, dm).toString(minify ? 0 : 4);
|
||||
a = withModuleSettings(i, Level.REGION, dm).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class IrisPackageCompiler {
|
||||
}
|
||||
|
||||
for (IrisBiome i : biomes) {
|
||||
a = withModuleSettings(i, Target.BIOME, dm).toString(minify ? 0 : 4);
|
||||
a = withModuleSettings(i, Level.BIOME, dm).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class IrisPackageCompiler {
|
||||
}
|
||||
|
||||
/** The JSON of a dimension, region or biome with the settings its modules declare, which the resource itself does not hold. */
|
||||
private static JSONObject withModuleSettings(IrisRegistrant resource, Target target, IrisData data) {
|
||||
private static JSONObject withModuleSettings(IrisRegistrant resource, Level target, IrisData data) {
|
||||
JSONObject json = new JSONObject(new Gson().toJson(resource));
|
||||
JSONObject settings = data.getModules().settings().encode(target, resource.getModuleSettings());
|
||||
settings.keySet().forEach(key -> json.put(key, settings.get(key)));
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.core.project;
|
||||
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.host.schema.FeatureSchema;
|
||||
import com.volmit.host.schema.ObjectType;
|
||||
@@ -90,7 +90,7 @@ final class ModuleSchemaRenderer {
|
||||
}
|
||||
|
||||
/** Adds every feature at {@code target} to {@code properties} under its key. */
|
||||
void addFeatures(Target target, JSONObject properties) {
|
||||
void addFeatures(Level target, JSONObject properties) {
|
||||
for (FeatureSchema feature : schema.fields(target)) {
|
||||
properties.put(feature.key(), featureProperty(feature));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user