mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 18:24:06 +00:00
Host side of the structure port: IrisStructureHost, iris:structure-model
Iris's worlds serve a StructureHost backed by the engine's StructurePlacing. The new host module iris:structure-model registers the structure resource kinds, the structure validator, the locator and the vanilla structure answers; iris:structure loads from the built-ins jar, so no generation module is compiled into Iris any more. The schema builder and the export closure read Reference.PACK_STRUCTURE. Test fixtures serve the model module next to the structure module, and the purity allowlist drops DecoratorCore, which no longer touches Bukkit.
This commit is contained in:
1 parent
40f042dc8e
commit
302166f115
15 files changed
+166
-27
No files matched your search
@@ -19,7 +19,6 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleLog;
|
||||
@@ -57,7 +56,7 @@ public final class IrisModuleHost {
|
||||
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter", "iris:loot",
|
||||
"iris:spawn", "iris:prepare", "iris:anchor", "iris:validate", "iris:bore", "iris:blocks", "iris:stilt", "iris:vacuum",
|
||||
"iris:snow", "iris:vanilla-features", "iris:carve", "iris:deposit", "iris:decorant", "iris:terrain", "iris:objects",
|
||||
"iris:floating");
|
||||
"iris:floating", "iris:structure");
|
||||
/** Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. */
|
||||
public static final String HOST_TYPE_PACKAGE = "art.arcane.iris.engine.object";
|
||||
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
|
||||
@@ -70,18 +69,14 @@ public final class IrisModuleHost {
|
||||
return Holder.HOST;
|
||||
}
|
||||
|
||||
/** The modules every pack loads before its own: Iris's own and the chunk generation every world runs. */
|
||||
/** The modules every pack loads before its own: Iris's own. */
|
||||
public static List<IrisModule> builtInModules() {
|
||||
return Stream.of(hostModules(), generationModules()).flatMap(List::stream).toList();
|
||||
return hostModules();
|
||||
}
|
||||
|
||||
/** Modules that are Iris itself, not features: they write the layout's platform biomes, record the platform's custom blocks and describe the classes Iris's placement settings hold. A pack never replaces them and the built-ins jar does not hold them. */
|
||||
/** Modules that are Iris itself, not features: they write the layout's platform biomes, record the platform's custom blocks, describe the classes Iris's placement settings hold and serve Iris's structure model. A pack never replaces them and the built-ins jar does not hold them. */
|
||||
private static List<IrisModule> hostModules() {
|
||||
return List.of(new BiomeModule(), new CustomModule(), new PlacementSettingsModule());
|
||||
}
|
||||
|
||||
private static List<IrisModule> generationModules() {
|
||||
return List.of(new StructureModule());
|
||||
return List.of(new BiomeModule(), new CustomModule(), new PlacementSettingsModule(), new StructureModelModule());
|
||||
}
|
||||
|
||||
/** Iris's own log, labelled {@code [iris]}, for host code that calls module classes outside any module's stage, service or hook. */
|
||||
|
||||
@@ -20,6 +20,7 @@ package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
@@ -40,7 +41,7 @@ import java.util.List;
|
||||
* 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, ObjectHost.Source, FloatingHost.Source {
|
||||
public final class IrisPackSettings implements PackSettings, ObjectHost.Source, FloatingHost.Source, StructureHost.Source {
|
||||
static final String DIMENSION = "dimension";
|
||||
static final String REGION = "region";
|
||||
static final String BIOME = "biome";
|
||||
@@ -76,6 +77,11 @@ public final class IrisPackSettings implements PackSettings, ObjectHost.Source,
|
||||
return new IrisFloatingHost(engine, IrisApiLogger.hostLog());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureHost structures() {
|
||||
return new IrisStructureHost(engine, IrisApiLogger.hostLog());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
return declaredBy(engine.getDimension(), engine, ids, featureType);
|
||||
|
||||
@@ -21,6 +21,7 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.SeedManager;
|
||||
@@ -38,7 +39,7 @@ import java.util.function.Function;
|
||||
* pack's resources reload under it. Iris's built-in modules reach the engine through {@link #of(PackWorld)}, as built-in
|
||||
* reaches do through {@link IrisPackSettings#of}.
|
||||
*/
|
||||
public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorld.Source, ObjectHost.Source, FloatingHost.Source {
|
||||
public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorld.Source, ObjectHost.Source, FloatingHost.Source, StructureHost.Source {
|
||||
private final Engine engine;
|
||||
private final IrisPackResources resources;
|
||||
private final WorldStates states;
|
||||
@@ -47,6 +48,7 @@ public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorl
|
||||
private final LiveWorld liveWorld;
|
||||
private volatile IrisObjectHost objectHost;
|
||||
private volatile IrisFloatingHost floatingHost;
|
||||
private volatile IrisStructureHost structureHost;
|
||||
|
||||
IrisPackWorld(Engine engine) {
|
||||
this(engine, engine.getData().getPackResources(), new WorldStates(), IrisApiLogger.hostLog(), new ConcurrentHashMap<>());
|
||||
@@ -154,6 +156,16 @@ public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorl
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureHost structures() {
|
||||
IrisStructureHost host = structureHost;
|
||||
if (host == null) {
|
||||
host = new IrisStructureHost(engine, log);
|
||||
structureHost = host;
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/** Whether the pack's resources were reloaded since this world was made, so it generates with an old snapshot. */
|
||||
boolean isStale() {
|
||||
return engine.getData().getPackResources() != resources;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.components.StructurePlacing;
|
||||
import com.volmit.ModuleLog;
|
||||
|
||||
/** Iris's {@link StructureHost}: the engine's {@link StructurePlacing}, one per engine runtime, places and sizes its structures. */
|
||||
final class IrisStructureHost implements StructureHost {
|
||||
private final Engine engine;
|
||||
private final ModuleLog log;
|
||||
|
||||
IrisStructureHost(Engine engine, ModuleLog log) {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeChunk() {
|
||||
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||
placing().place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int reach() {
|
||||
return placing().reach();
|
||||
}
|
||||
|
||||
private StructurePlacing placing() {
|
||||
return engine.getGeneration().state(StructurePlacing.class, generating -> new StructurePlacing(generating, log));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.structure.StructureLocating;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.framework.structure.StructureValidator;
|
||||
import art.arcane.iris.engine.framework.structure.StructureVanillaStructures;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:structure-model}: Iris's jigsaw structure model, which the structure placements of
|
||||
* {@code iris:structure} build from and the jigsaw studio, importers and exporters edit.
|
||||
* <p>
|
||||
* It owns the pack's structures, jigsaw pools and jigsaw pieces as resource kinds ({@link StructureResources}), read
|
||||
* from the folders packs have always used, and checks them with {@link StructureValidator} wherever Iris validates a
|
||||
* pack. It lets Iris find its structures through {@link StructureLocating}; a world's structure index lives in the
|
||||
* world's state, so a reload of the pack's structure files, which starts a new world, builds it again.
|
||||
* <p>
|
||||
* It decides over the platform's own structures through its {@link VanillaStructures} provider
|
||||
* ({@link StructureVanillaStructures}): the dimension's {@code importedStructures} settings disable, move, fit and set
|
||||
* them up, and the pack's structure placements replace them, place them alongside, start them where their
|
||||
* {@code nativeStructures} grids say and fit them into the terrain.
|
||||
*/
|
||||
public final class StructureModelModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:structure-model", "Structure model", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
StructureResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerValidator(new StructureValidator());
|
||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||
registry.registerService(VanillaStructures.class, new StructureVanillaStructures());
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,12 @@ import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.volmlib.util.io.IO;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.host.ResourceKindRegistration;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
@@ -171,6 +174,10 @@ public final class ModuleResourceClosure {
|
||||
if (reference != null) {
|
||||
return reference.value();
|
||||
}
|
||||
Ref packReference = field.getAnnotation(Ref.class);
|
||||
if (packReference != null && packReference.value() == Reference.PACK_STRUCTURE) {
|
||||
return IrisStructure.class;
|
||||
}
|
||||
RegistryListResource registry = field.getAnnotation(RegistryListResource.class);
|
||||
return registry == null ? null : registry.value();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ 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.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.framework.ListFunction;
|
||||
@@ -457,6 +458,7 @@ public class SchemaBuilder {
|
||||
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);
|
||||
case PACK_STRUCTURE -> putPackResourceRef(property, IrisStructure.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user