mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Merge wave1/a1
This commit is contained in:
commit
f0f3c4d1b8
6 files changed
+133
-8
No files matched your search
@@ -21,6 +21,14 @@ pools and jigsaw pieces as resource kinds (`StructureResources`), from the folde
|
||||
used, and checks them with its validator (`StructureValidator`: assembly samples and vanilla structure
|
||||
replacement) wherever Iris validates a pack; Iris core has no loader or validator of its own for them any more.
|
||||
|
||||
Built-in modules answer Iris through IrisApi services instead of Iris reading their features: `iris:objects`
|
||||
provides `ObjectsAt` (the objects a chunk would get, for the object search and studio tools) and `iris:structure`
|
||||
provides `StructureLocator` (`StructureLocating`: the pack's structure keys for Iris's structure index, the ones a
|
||||
world places, and their nearest start for the find commands). `iris:structure` also has a lifecycle hook that drops a
|
||||
world's structure index when the world stops, which includes every reload of the pack's structure files.
|
||||
`iris:decorant` keeps its per-world `Decorating` in the world's state store (`context.world().state(...)`); the other
|
||||
built-ins still reach the same store through `IrisChunk.state(...)` / `engine.getGeneration().state(...)`.
|
||||
|
||||
Every built-in stage is a full port: the module owns its logic and per-engine state, and the mantle stages
|
||||
work out their reach from the pack when it loads. A dimension's `disabledComponents` turns a mantle stage off
|
||||
by its flag (`CARVED`, `OBJECT`, `FLOATING_OBJECT`, `JIGSAW`) or by its stage id.
|
||||
|
||||
@@ -20,6 +20,7 @@ package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaFloorDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisShoreLineDecorator;
|
||||
@@ -37,6 +38,7 @@ import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -60,10 +62,15 @@ public final class DecorantModule implements IrisModule {
|
||||
|
||||
private static void decorate(ChunkStageContext context) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
chunk.state(Decorating.class, Decorating::new).decorate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
|
||||
decorating(context.world()).decorate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
|
||||
}
|
||||
|
||||
/** What decorating keeps for one engine runtime: one decorator per kind of place. */
|
||||
/** The world's decorating, kept in its state store. */
|
||||
static Decorating decorating(PackWorld world) {
|
||||
return world.state(Decorating.class, Decorating::new);
|
||||
}
|
||||
|
||||
/** What decorating keeps for one world: one decorator per kind of place. */
|
||||
static final class Decorating {
|
||||
private static final Predicate<PlatformBlockState> PREDICATE_SOLID = (s) -> s != null && !B.isAirOrFluid(s);
|
||||
|
||||
@@ -73,6 +80,10 @@ public final class DecorantModule implements IrisModule {
|
||||
private final EngineDecorator seaFloorDecorator;
|
||||
private final EngineDecorator shoreLineDecorator;
|
||||
|
||||
Decorating(PackWorld world) {
|
||||
this(IrisPackWorld.of(world).engine());
|
||||
}
|
||||
|
||||
Decorating(Engine engine) {
|
||||
this.engine = engine;
|
||||
surfaceDecorator = new IrisSurfaceDecorator(engine);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.engine.framework.structure;
|
||||
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.service.LocateResult;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* How {@code iris:structure} lets Iris find its structures: the structures of the pack's {@code structures} folder,
|
||||
* the ones the world's placements assemble from jigsaw pools, and their nearest start, searched with
|
||||
* {@link IrisStructureLocator}. Vanilla structures that Iris places through native placements are not among them; the
|
||||
* host's vanilla structure handling finds those.
|
||||
*/
|
||||
public final class StructureLocating implements StructureLocator {
|
||||
@Override
|
||||
public Set<String> structures(PackResources pack) {
|
||||
return new LinkedHashSet<>(StructureResources.structureKeysOf(pack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> locatable(PackWorld world) {
|
||||
return IrisStructureLocator.locatableEditableKeys(engine(world));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks) {
|
||||
Engine engine = engine(world);
|
||||
IrisStructureLocator.LocateResult result = IrisStructureLocator.locate(engine, key, fromX, fromZ, maxRadiusChunks);
|
||||
return switch (result.status()) {
|
||||
case FOUND -> LocateResult.found(new BlockPosition(result.originX(), result.baseY() - engine.getMinHeight(), result.originZ()));
|
||||
case NOT_FOUND -> LocateResult.NOT_FOUND;
|
||||
case SEARCH_LIMIT_REACHED -> LocateResult.SEARCH_LIMIT_REACHED;
|
||||
};
|
||||
}
|
||||
|
||||
private static Engine engine(PackWorld world) {
|
||||
return IrisPackWorld.of(world).engine();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
|
||||
@@ -67,7 +68,12 @@ public final class StructureResources {
|
||||
|
||||
/** The key of every structure of the pack, in key order. */
|
||||
public static List<String> structureKeys(IrisData data) {
|
||||
return keys(data, STRUCTURES);
|
||||
return structureKeysOf(data.getPackResources());
|
||||
}
|
||||
|
||||
/** The key of every structure of the pack snapshot {@code pack}, in key order. */
|
||||
public static List<String> structureKeysOf(PackResources pack) {
|
||||
return keys(pack, STRUCTURES);
|
||||
}
|
||||
|
||||
/** The key of every jigsaw piece of the pack, in key order. */
|
||||
@@ -89,6 +95,10 @@ public final class StructureResources {
|
||||
|
||||
/** A key's id has the key as its path, so the path names the resource again wherever a key is expected. */
|
||||
private static List<String> keys(IrisData data, ResourceKind<?> kind) {
|
||||
return data.getPackResources().ids(kind.type()).stream().map(ResourceId::path).toList();
|
||||
return keys(data.getPackResources(), kind);
|
||||
}
|
||||
|
||||
private static List<String> keys(PackResources pack, ResourceKind<?> kind) {
|
||||
return pack.ids(kind.type()).stream().map(ResourceId::path).toList();
|
||||
}
|
||||
}
|
||||
@@ -21,17 +21,24 @@ package art.arcane.iris.engine.mantle.components;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.service.ObjectsAt;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Module {@code iris:objects}: the objects the dimension's regions and biomes place, written into the mantle
|
||||
* once the caves they may anchor in are planned. A port of what was Iris's object mantle component, its work
|
||||
* done by {@link ObjectPlacing}, one per engine runtime. Its reach is the pack's largest object placement.
|
||||
* done by {@link ObjectPlacing}, one per engine runtime. Its reach is the pack's largest object placement. It tells
|
||||
* Iris which objects a chunk would get ({@link ObjectsAt}), for the object search and studio tools.
|
||||
*/
|
||||
public final class ObjectModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
@@ -46,6 +53,11 @@ public final class ObjectModule implements IrisModule {
|
||||
graph.define(IrisStages.Objects.PLACE).requires(IrisStages.Carve.CAVES).reach(ObjectModule::reach).run(ObjectModule::place);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerService(ObjectsAt.class, ObjectModule::objectsAt);
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||
placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||
@@ -55,7 +67,12 @@ public final class ObjectModule implements IrisModule {
|
||||
return placing(IrisPackSettings.of(settings).engine()).reach();
|
||||
}
|
||||
|
||||
/** The engine runtime's object placing, which {@link Engine#getObjectsAt} also asks. */
|
||||
/** The keys of the objects the surface placements of the chunk's biome and region would place, guessed without generating it. */
|
||||
private static Set<String> objectsAt(PackWorld world, int chunkX, int chunkZ) {
|
||||
return placing(IrisPackWorld.of(world).engine()).guess(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
/** The engine runtime's object placing, which the module's {@link ObjectsAt} also asks. */
|
||||
public static ObjectPlacing placing(Engine engine) {
|
||||
return engine.getGeneration().state(ObjectPlacing.class, ObjectPlacing::new);
|
||||
}
|
||||
|
||||
@@ -21,15 +21,21 @@ package art.arcane.iris.engine.mantle.components;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||
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 com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
* Module {@code iris:structure}: Iris structures, written into the mantle after objects, whose trees they clear
|
||||
@@ -38,9 +44,11 @@ import com.volmit.stage.StageGraph;
|
||||
* <p>
|
||||
* The module 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.
|
||||
* {@link StructureValidator} wherever Iris validates a pack. It lets Iris find its structures through
|
||||
* {@link StructureLocating}, and forgets a world's structure index when the world stops, which includes every reload of
|
||||
* the pack's structure files.
|
||||
*/
|
||||
public final class StructureModule implements IrisModule {
|
||||
public final class StructureModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
@Override
|
||||
@@ -58,6 +66,14 @@ public final class StructureModule implements IrisModule {
|
||||
public void register(FeatureRegistry registry) {
|
||||
StructureResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerValidator(new StructureValidator());
|
||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
/** The structure index is still kept per engine rather than in the world's state, so a stopping world drops it. */
|
||||
@Override
|
||||
public void worldStopped(PackWorld world) {
|
||||
IrisStructureLocator.invalidate(IrisPackWorld.of(world).engine());
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
|
||||
Reference in new issue
Block a user