Merge wave1/a2

This commit is contained in:
piexel committed 2026-10-09 14:43:33 +02:00
commit 25fd24b7c2
28 files changed
+1294 -263

No files matched your search

@@ -18,26 +18,62 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.spi.PlatformFace;
import com.volmit.block.BlockFace;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
import com.volmit.block.BlockState;
import com.volmit.block.BlockTrait;
import com.volmit.object.BlockEntityData;
import com.volmit.resource.ResourceId;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
* IrisApi's view of the bound platform's blocks. States convert through their keys, as {@link PlatformBlockStates}
* does; the platform decides which blocks exist, so a key it does not know fails. Traits, tags and attachment to
* a face are the platform's own answers: its block tags, its falling blocks and its face support.
* <p>
* {@link BlockSpec}s resolve as Iris resolves the block data packs write ({@link IrisValues#blockData}): a block of
* the pack's {@code blocks} folder, the platform's block, the backup, then air. Each spec is converted once per
* pack snapshot, so its resolution is too.
*/
final class IrisBlockRegistry implements BlockRegistry {
private final IrisData data;
private final Map<BlockSpec, IrisBlockData> specs = new ConcurrentHashMap<>();
/** @param data the pack whose {@code blocks} folder custom blocks come from */
IrisBlockRegistry(IrisData data) {
this.data = data;
}
@Override
public BlockState resolve(String key) {
return BlockState.parse(PlatformBlockStates.namespaced(platformState(key).key()));
}
@Override
public BlockState resolve(BlockSpec spec) {
return BlockState.parse(PlatformBlockStates.namespaced(blockData(spec).getBlockData(data).key()));
}
@Override
public Optional<BlockEntityData> blockEntity(BlockSpec spec) {
TileData tile = blockData(spec).tryGetTile(data);
return tile == null ? Optional.empty() : Optional.of(BlockEntities.of(tile));
}
private IrisBlockData blockData(BlockSpec spec) {
return specs.computeIfAbsent(spec, IrisValues::blockData);
}
@Override
public boolean hasTrait(BlockState state, BlockTrait trait) {
PlatformBlockState platform = platformState(state.key());
@@ -0,0 +1,68 @@
/*
* 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 art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.noise.NoiseFactory;
import com.volmit.noise.NoiseSampler;
import com.volmit.noise.NoiseStyle;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Builds the noise of IrisApi noise styles with Iris's own generators: each style becomes the
* {@link IrisGeneratorStyle} that reads the same JSON ({@link IrisValues#generatorStyle}), once per pack snapshot, and
* builds its noise from an {@link RNG} of the seed exactly as Iris's own features do, with Iris's per-style cache of
* built generators.
*/
final class IrisNoiseFactory implements NoiseFactory {
private final IrisData data;
private final Map<NoiseStyle, IrisGeneratorStyle> styles = new ConcurrentHashMap<>();
IrisNoiseFactory(IrisData data) {
this.data = data;
}
@Override
public NoiseSampler sampler(NoiseStyle style, long seed) {
IrisGeneratorStyle iris = styles.computeIfAbsent(style, IrisValues::generatorStyle);
try {
return new CngSampler(iris.create(new RNG(seed), data));
} catch (RuntimeException failure) {
throw new IllegalArgumentException("Cannot build the noise of " + style + ": " + failure.getMessage(), failure);
}
}
/** Iris's noise as an IrisApi sampler; CNG is safe for the concurrent reads generation makes. */
private record CngSampler(CNG noise) implements NoiseSampler {
@Override
public double sample(double worldX, double worldZ) {
return noise.noise(worldX, worldZ);
}
@Override
public double sample(double worldX, double y, double worldZ) {
return noise.noise(worldX, y, worldZ);
}
}
}
@@ -26,6 +26,7 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import com.volmit.block.BlockRegistry;
import com.volmit.host.ResourceKindRegistration;
import com.volmit.noise.NoiseFactory;
import com.volmit.object.GeneratedObject;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
@@ -57,6 +58,9 @@ import java.util.function.Supplier;
* another namespace, is absent; any other type fails with {@link IllegalArgumentException}. A resource that exists
* but cannot be loaded fails with {@link IllegalStateException}. Each resource is built once and kept for the
* snapshot. The module kinds are looked up the first time one is asked for, which loads the pack's modules.
* <p>
* Blocks resolve through the platform and the pack's {@code blocks} folder ({@link IrisBlockRegistry}), and noise
* styles through Iris's generators, expressions and image maps ({@link IrisNoiseFactory}), both kept per snapshot.
*/
public final class IrisPackResources implements PackResources {
private static final String SERVED_TYPES = "GeneratedObject, PackBiome, PackRegion and the types of the pack's module resource kinds";
@@ -64,7 +68,8 @@ public final class IrisPackResources implements PackResources {
private final IrisData data;
private final PackResourceIds ids;
private final UUID snapshotId = UUID.randomUUID();
private final BlockRegistry blocks = new IrisBlockRegistry();
private final BlockRegistry blocks;
private final NoiseFactory noise;
private final Map<Class<?>, Kind<?>> irisKinds;
private final Supplier<List<ResourceKind<?>>> moduleKindList;
private volatile Map<Class<?>, Kind<?>> moduleKinds;
@@ -82,6 +87,8 @@ public final class IrisPackResources implements PackResources {
this.data = data;
this.ids = new PackResourceIds(data.getDataFolder());
this.moduleKindList = moduleKinds;
this.blocks = new IrisBlockRegistry(data);
this.noise = new IrisNoiseFactory(data);
this.irisKinds = Map.of(
GeneratedObject.class, Kind.<IrisObject, GeneratedObject>ofLoader(ids, data::getObjectLoader, (id, object) -> object.getGeometry()),
PackBiome.class, Kind.<IrisBiome, PackBiome>ofLoader(ids, data::getBiomeLoader, this::biomeOf),
@@ -115,6 +122,11 @@ public final class IrisPackResources implements PackResources {
return blocks;
}
@Override
public NoiseFactory noise() {
return noise;
}
@Override
@SuppressWarnings("unchecked") // The kinds are keyed by the type they serve.
public <T> Optional<T> find(ResourceKey<T> key) {
@@ -33,10 +33,9 @@ import java.util.ArrayList;
import java.util.List;
/**
* The settings an engine's pack declares, for working out mantle stage reaches when the pack loads: the
* engine's dimension, then every region it can reach, then every biome. Iris's built-in mantle stages size
* their reach from Iris's own pack data instead of module settings; they reach the engine through
* {@link #of(PackSettings)}.
* The settings an engine's pack declares, for working out mantle stage reaches when the pack loads and for vanilla
* structure hooks: the engine's dimension, then every region it can reach, then every biome. Iris's built-in modules
* decide from Iris's own pack data instead of module settings; they reach the engine through {@link #of(PackSettings)}.
*/
public final class IrisPackSettings implements PackSettings {
static final String DIMENSION = "dimension";
@@ -54,7 +53,7 @@ public final class IrisPackSettings implements PackSettings {
/** Iris's own view of {@code settings}, which Iris hands to every reach it works out. */
public static IrisPackSettings of(PackSettings settings) {
if (!(settings instanceof IrisPackSettings irisSettings)) {
throw new IllegalArgumentException("Built-in reaches are worked out from an Iris engine's pack, not " + settings);
throw new IllegalArgumentException("Built-in modules read an Iris engine's pack, not " + settings);
}
return irisSettings;
}
@@ -0,0 +1,105 @@
/*
* 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 art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.engine.object.noise.IrisStyledRange;
import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.value.IrisPosition;
import art.arcane.iris.engine.object.value.IrisRange;
import art.arcane.volmlib.util.collection.KMap;
import com.volmit.block.BlockSpec;
import com.volmit.config.Range;
import com.volmit.noise.StyledRange;
import com.volmit.world.BlockPosition;
import java.util.Map;
import java.util.Optional;
/**
* Iris's own classes for IrisApi's value types. Each pair reads the same pack JSON, so Iris resolves a value the way
* it resolves its own class (a {@link BlockSpec} as an {@link IrisBlockData}, a noise style as an
* {@link IrisGeneratorStyle}) and studio describes the value with Iris's own description of that class.
*/
public final class IrisValues {
private static final Map<String, Class<?>> IRIS_CLASSES = Map.of(
BlockSpec.class.getName(), IrisBlockData.class,
com.volmit.noise.NoiseStyle.class.getName(), IrisGeneratorStyle.class,
StyledRange.class.getName(), IrisStyledRange.class,
Range.class.getName(), IrisRange.class,
BlockPosition.class.getName(), IrisPosition.class);
private IrisValues() {
}
/** The Iris class that reads the same JSON as the IrisApi value type named {@code apiTypeName}, if it is one. */
public static Optional<Class<?>> irisClassOf(String apiTypeName) {
return Optional.ofNullable(IRIS_CLASSES.get(apiTypeName));
}
/** The IrisApi value types and the Iris classes that read the same JSON. */
static Map<String, Class<?>> irisClasses() {
return IRIS_CLASSES;
}
/** {@code spec} as the block data Iris resolves: its block, properties, weight, backup and tile data. */
static IrisBlockData blockData(BlockSpec spec) {
IrisBlockData block = new IrisBlockData(spec.block());
block.setData(irisMap(spec.data()));
block.setWeight(spec.weight());
block.setBackup(spec.backup().map(IrisValues::blockData).orElse(null));
block.setTileData(irisMap(spec.tileData()));
return block;
}
/** Iris's maps hold no null values; a JSON null in a map reads as absent, as it does for Iris's own fields. */
private static KMap<String, Object> irisMap(Map<String, ?> values) {
KMap<String, Object> map = new KMap<>();
values.forEach((key, value) -> {
if (value != null) {
map.put(key, value);
}
});
return map;
}
/** {@code style} as the generator style Iris builds noise from; a style name Iris does not know is flat. */
static IrisGeneratorStyle generatorStyle(com.volmit.noise.NoiseStyle style) {
IrisGeneratorStyle iris = new IrisGeneratorStyle(irisStyle(style.style()));
iris.setCellularFrequency(style.cellularFrequency());
iris.setCellularZoom(style.cellularZoom());
iris.setZoom(style.zoom());
iris.setExpression(style.expression().orElse(null));
iris.setImageMap(style.imageMap().orElse(null));
iris.setMultiplier(style.multiplier());
iris.setFracture(style.fracture().map(IrisValues::generatorStyle).orElse(null));
iris.setExponent(style.exponent());
iris.setCacheSize(style.cacheSize());
return iris;
}
private static NoiseStyle irisStyle(String name) {
try {
return NoiseStyle.valueOf(name);
} catch (IllegalArgumentException unknown) {
return NoiseStyle.FLAT;
}
}
}
@@ -57,7 +57,9 @@ import java.util.stream.Stream;
* Reads the module settings a dimension, region or biome declares: each settings feature of the pack at
* that target, under its id or, for built-ins, its alias. Settings are created with their no-argument
* constructor and the JSON is read into them, so an omitted option keeps its default. A {@link Snippet}
* type may be written as {@code "snippet/<name>"}, read from {@code snippet/<snippet folder>/<name>.json}.
* type may be written as {@code "snippet/<name>"} or, as Iris's own snippets are, {@code "snippet/<snippet folder>/<name>"},
* both read from {@code snippet/<snippet folder>/<name>.json}. IrisApi's value types ({@code BlockSpec},
* {@code NoiseStyle} and the rest) are read like settings, and an {@code Object} as Gson reads any JSON value.
* <p>
* Settings with exactly one option may be written as that option's value: {@code "snow": 0.5} reads as
* {@code "snow": {"amount": 0.5}}. Iris's own classes that built-in settings hold (see
@@ -244,13 +246,20 @@ public final class ModuleSettingsDecoder {
}
}
/** The file name below the snippet folder: {@code snippet/<name>} and {@code snippet/<snippet folder>/<name>} name the same file. */
private static String snippetName(String snippetFolder, String reference) {
String name = reference.substring(SNIPPET_PREFIX.length());
String folderPrefix = snippetFolder + "/";
return name.startsWith(folderPrefix) ? name.substring(folderPrefix.length()) : name;
}
private String readSnippet(String snippetFolder, String reference) {
if (!reference.startsWith(SNIPPET_PREFIX)) {
throw new JsonParseException("\"" + reference + "\" is neither an object nor a snippet reference; write the object,"
+ " or snippet/<name> for the file " + SNIPPET_FOLDER + "/" + snippetFolder + "/<name>" + JSON_EXTENSION);
}
Path folder = packFolder.resolve(SNIPPET_FOLDER).resolve(snippetFolder).normalize();
Path file = folder.resolve(reference.substring(SNIPPET_PREFIX.length()) + JSON_EXTENSION).normalize();
Path file = folder.resolve(snippetName(snippetFolder, reference) + JSON_EXTENSION).normalize();
if (!file.startsWith(folder) || !Files.isRegularFile(file)) {
throw new JsonParseException("Snippet " + reference + " has no file " + packFolder.relativize(file));
}
@@ -0,0 +1,107 @@
/*
* 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 art.arcane.iris.engine.framework.Engine;
import com.volmit.config.PackSettings;
import com.volmit.host.VanillaStructureHookRegistration;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.vanilla.VanillaStructureContext;
import com.volmit.vanilla.VanillaStructureRule;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
/**
* What the pack's modules want for each of the platform's own structures in one engine's world: every vanilla structure
* hook of the pack asked once per structure, the rules combined ({@link VanillaStructureRule#and}). Kept per engine and
* pack snapshot, so a hotload or a reload of the pack's resources asks the hooks again. The platform side
* ({@code NativeStructureGenerationPolicy}) applies the result on Bukkit and the modded platforms alike.
*/
public final class ModuleVanillaStructures {
private static final Map<Engine, ModuleVanillaStructures> WORLDS = Collections.synchronizedMap(new WeakHashMap<>());
private final PackResources snapshot;
private final List<VanillaStructureHookRegistration> hooks;
private final VanillaStructureContext world;
private final Map<String, VanillaStructureRule> rules = new ConcurrentHashMap<>();
private ModuleVanillaStructures(Engine engine, PackResources snapshot) {
this.snapshot = snapshot;
this.hooks = engine.getData().getModules().pack().catalog().vanillaStructureHooks();
this.world = new World(snapshot, new IrisPackSettings(engine));
}
/** The combined rule of the pack's modules for the platform structure {@code structureKey} in {@code engine}'s world. */
public static VanillaStructureRule ruleFor(Engine engine, String structureKey) {
return of(engine).rule(structureKey);
}
private static ModuleVanillaStructures of(Engine engine) {
PackResources current = engine.getData().getPackResources();
ModuleVanillaStructures known = WORLDS.get(engine);
if (known != null && known.snapshot == current) {
return known;
}
ModuleVanillaStructures fresh = new ModuleVanillaStructures(engine, current);
WORLDS.put(engine, fresh);
return fresh;
}
private VanillaStructureRule rule(String structureKey) {
return rules.computeIfAbsent(structureKey, this::askHooks);
}
/** A key that is no resource id names no structure a module could decide over. */
private VanillaStructureRule askHooks(String structureKey) {
ResourceId structure;
try {
structure = ResourceId.parse(structureKey);
} catch (IllegalArgumentException notAnId) {
return VanillaStructureRule.GENERATE;
}
VanillaStructureRule combined = VanillaStructureRule.GENERATE;
for (VanillaStructureHookRegistration registration : hooks) {
combined = combined.and(ask(registration, structure));
}
return combined;
}
private VanillaStructureRule ask(VanillaStructureHookRegistration registration, ResourceId structure) {
VanillaStructureRule rule;
try {
rule = registration.hook().rule(structure, world);
} catch (RuntimeException failure) {
throw new IllegalStateException("Module " + registration.module() + " failed deciding over vanilla structure "
+ structure + ": " + failure, failure);
}
if (rule == null) {
throw new IllegalStateException("Module " + registration.module() + " gave no rule for vanilla structure " + structure);
}
return rule;
}
/** The world the hooks decide for: the engine's pack snapshot and the settings its dimension reaches. */
private record World(PackResources resources, PackSettings settings) implements VanillaStructureContext {
}
}
@@ -21,6 +21,7 @@ package art.arcane.iris.core.project;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.IrisValues;
import art.arcane.iris.core.modules.PackModulesException;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.spi.IrisLogging;
@@ -230,6 +231,9 @@ public class IrisCodeWorkspace {
}
for (ObjectType type : dm.getModules().pack().schema().snippets()) {
if (IrisValues.irisClassOf(type.name()).isPresent()) {
continue;
}
schemaEntries.add(moduleSnippetSchema(dm, type, immediateSchemas));
}
schemaEntries.addAll(ModuleResourceSchemas.entries(dm, immediateSchemas));
@@ -252,7 +256,10 @@ public class IrisCodeWorkspace {
return ws;
}
/** A module's snippet type gets its own schema for the files under {@code snippet/<name>/}, as Iris's snippets do. */
/**
* A module's snippet type gets its own schema for the files under {@code snippet/<name>/}, as Iris's snippets do. IrisApi's
* value types share their snippet folders with the Iris classes that read the same JSON, whose schemas Iris writes.
*/
private static JSONObject moduleSnippetSchema(IrisData data, ObjectType type, boolean immediate) {
String name = type.snippet().orElseThrow();
JSONObject entry = snippetSchemaEntry(name);
@@ -41,7 +41,8 @@ import java.util.function.Function;
* schema studio writes: each feature as a property of its target under its id and, for built-ins, its
* alias, each settings class once as a definition, references as completion lists (resource references as the keys
* of the module resource kind they name). Settings with one option also accept that option's bare value; Iris's own
* classes in built-in settings use Iris's own definitions.
* classes in built-in settings use Iris's own definitions, and so do IrisApi's value types, which read the same JSON as
* an Iris class ({@code BlockSpec} as Iris's block data), with the snippet references their {@code @Snippet} allows.
*/
final class ModuleSchemaRenderer {
private static final String DEFINITION_PREFIX = "module-";
@@ -70,16 +71,22 @@ final class ModuleSchemaRenderer {
private final ReferenceCompletions references;
private final ResourceCompletions resources;
private final HostDefinitions hostDefinitions;
private final Function<String, Optional<String>> sameJsonHostTypes;
private final Function<String, List<String>> snippetFiles;
/** {@code snippetFiles} lists the snippet references a pack has for a snippet folder, such as {@code snippet/thick}. */
/**
* @param sameJsonHostTypes the Iris class that reads the same JSON as a module type, for IrisApi's value types
* @param snippetFiles lists the snippet references a pack has for a snippet folder, such as {@code snippet/thick}
*/
ModuleSchemaRenderer(PackSchema schema, Map<String, JSONObject> definitions, ReferenceCompletions references,
ResourceCompletions resources, HostDefinitions hostDefinitions, Function<String, List<String>> snippetFiles) {
ResourceCompletions resources, HostDefinitions hostDefinitions,
Function<String, Optional<String>> sameJsonHostTypes, Function<String, List<String>> snippetFiles) {
this.schema = schema;
this.definitions = definitions;
this.references = references;
this.resources = resources;
this.hostDefinitions = hostDefinitions;
this.sameJsonHostTypes = sameJsonHostTypes;
this.snippetFiles = snippetFiles;
}
@@ -137,22 +144,30 @@ final class ModuleSchemaRenderer {
}
definitions.put(key, new JSONObject());
ObjectType type = schema.type(typeName);
definitions.put(key, type.snippet().isPresent() ? objectOrSnippet(type) : objectSchema(type));
JSONObject object = describedObject(type);
definitions.put(key, type.snippet().isPresent() ? objectOrSnippet(object, type) : object);
return key;
}
private JSONObject objectOrSnippet(ObjectType type) {
/** Iris's own description where an Iris class reads the same JSON, otherwise the module's. */
private JSONObject describedObject(ObjectType type) {
return sameJsonHostTypes.apply(type.name())
.map(hostType -> new JSONObject().put("$ref", DEFINITION_REF + hostDefinitions.definition(hostType)))
.orElseGet(() -> objectSchema(type));
}
private JSONObject objectOrSnippet(JSONObject object, ObjectType type) {
String folder = type.snippet().orElseThrow();
JSONObject reference = new JSONObject();
reference.put("type", "string");
JSONArray files = new JSONArray(snippetFiles.apply(folder));
JSONArray files = new JSONArray(List.<Object>copyOf(snippetFiles.apply(folder)));
if (files.length() > 0) {
reference.put("examples", files);
}
reference.put("pattern", SNIPPET_PATTERN);
reference.put("description", "A snippet file under snippet/" + folder + "/, written as snippet/<name>");
JSONObject either = new JSONObject();
either.put("anyOf", new JSONArray(List.of(objectSchema(type), reference)));
either.put("anyOf", new JSONArray(List.of(object, reference)));
either.put("description", type.description());
return either;
}
@@ -207,8 +222,8 @@ final class ModuleSchemaRenderer {
}
case ValueKind.EnumKind enumKind -> {
value.put("type", "string");
value.put("enum", new JSONArray(enumKind.constants().stream().map(ValueKind.EnumConstant::name).toList()));
value.put("enumDescriptions", new JSONArray(enumKind.constants().stream().map(ValueKind.EnumConstant::description).toList()));
value.put("enum", new JSONArray(enumKind.constants().stream().<Object>map(ValueKind.EnumConstant::name).toList()));
value.put("enumDescriptions", new JSONArray(enumKind.constants().stream().<Object>map(ValueKind.EnumConstant::description).toList()));
}
case ValueKind.ListKind list -> {
value.put("type", "array");
@@ -223,6 +238,8 @@ final class ModuleSchemaRenderer {
}
case ValueKind.ObjectKind object -> value.put("$ref", DEFINITION_REF + definition(object.type()));
case ValueKind.HostKind host -> value.put("$ref", DEFINITION_REF + hostDefinitions.definition(host.type()));
case ValueKind.AnyKind ignored -> {
}
}
return value;
}
@@ -25,9 +25,13 @@ import art.arcane.iris.spi.PlatformNumericRange;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.IrisRegistrant;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.IrisValues;
import art.arcane.iris.core.modules.ModuleResourceFiles;
import art.arcane.iris.core.modules.ModuleTargets;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.object.image.IrisImageMap;
import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion;
@@ -391,7 +395,8 @@ public class SchemaBuilder {
private ModuleSchemaRenderer moduleSchemas() {
if (moduleSchemas == null) {
moduleSchemas = new ModuleSchemaRenderer(data.getModules().pack().schema(), definitions,
this::completeReference, this::completeResourceReference, this::hostDefinition, data::getPossibleSnippets);
this::completeReference, this::completeResourceReference, this::hostDefinition,
typeName -> IrisValues.irisClassOf(typeName).map(Class::getName), data::getPossibleSnippets);
}
return moduleSchemas;
}
@@ -439,6 +444,9 @@ public class SchemaBuilder {
case PACK_BIOME -> putPackResourceRef(property, IrisBiome.class);
case PACK_REGION -> putPackResourceRef(property, IrisRegion.class);
case PACK_OBJECT -> putPackResourceRef(property, IrisObject.class);
case NOISE_STYLE -> addEnum(NoiseStyle.class, property, new KList<>(), enumNames(NoiseStyle.class), Function.identity());
case PACK_EXPRESSION -> putPackResourceRef(property, IrisExpression.class);
case PACK_IMAGE_MAP -> putPackResourceRef(property, IrisImageMap.class);
}
}
@@ -18,13 +18,21 @@
package art.arcane.iris.engine.framework;
import art.arcane.iris.core.modules.ModuleVanillaStructures;
import art.arcane.iris.engine.object.structure.vanilla.IrisImportedStructureControl;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructureDecision;
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureGenerationStatus;
import com.volmit.vanilla.VanillaStructureRule;
import java.util.Objects;
/**
* Whether the platform generates one of its own structures in an engine's world, the same on every platform: the
* dimension's {@code importedStructures} settings first, then the rule the pack's modules give the structure through
* their vanilla structure hooks ({@link ModuleVanillaStructures}). A structure a module blocks does not generate; one a
* module places itself is reported as replaced, so find, goto and verify locate the module's placement.
*/
public final class NativeStructureGenerationPolicy {
private NativeStructureGenerationPolicy() {
}
@@ -38,20 +46,21 @@ public final class NativeStructureGenerationPolicy {
dimension.getImportedStructures(),
"Dimension importedStructures must not be null");
IrisNativeStructureDecision decision = control.resolve(structureKey, undergroundStep);
if (!decision.generate()) {
// A disabled key with an active Iris placement is the "blanket-disable, re-place
// explicitly" pattern: the placement planner ignores the disable list, so generation
// places it — report REPLACED_BY_IRIS so find/goto/verify locate the placement.
if (decision.status() == NativeStructureGenerationStatus.DISABLED_BY_PACK
&& IrisStructureLocator.isPlaced(activeEngine, structureKey)) {
return decision.withStatus(NativeStructureGenerationStatus.REPLACED_BY_IRIS);
}
if (decision.status() == NativeStructureGenerationStatus.INVALID_REGISTRY_KEY) {
return decision;
}
if (IrisStructureLocator.suppressesVanilla(activeEngine, structureKey)) {
return decision.withStatus(NativeStructureGenerationStatus.REPLACED_BY_IRIS);
VanillaStructureRule modules = ModuleVanillaStructures.ruleFor(activeEngine, structureKey);
if (!decision.generate()) {
// A key the dimension disables that a module places is the "blanket-disable, re-place explicitly"
// pattern: report REPLACED_BY_IRIS so find/goto/verify locate the module's placement.
return modules.placedByModule() ? decision.withStatus(NativeStructureGenerationStatus.REPLACED_BY_IRIS) : decision;
}
return decision;
if (!modules.blocksPlatform()) {
return decision;
}
return decision.withStatus(modules.placedByModule()
? NativeStructureGenerationStatus.REPLACED_BY_IRIS
: NativeStructureGenerationStatus.DISABLED_BY_PACK);
}
public static String generationStatusMessage(String structureKey,
@@ -60,7 +69,7 @@ public final class NativeStructureGenerationPolicy {
return switch (Objects.requireNonNull(status, "Native structure status must not be null")) {
case GENERATE_NATIVE -> "Native structure " + key + " generates natively.";
case DISABLED_BY_PACK -> "Native structure " + key
+ " is disabled by this dimension's importedStructures settings.";
+ " is disabled by this dimension's importedStructures settings or a module of the pack.";
case REPLACED_BY_IRIS -> "Native structure " + key
+ " is replaced by an Iris placement in this pack and locates through that explicit replacement.";
case INVALID_REGISTRY_KEY -> "Native structure registry key is invalid: " + key;