mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Structures generate from the built-ins jar
iris:structure moves into the jar as a thin module: it declares the structure placement settings and the mantle stage, and Iris places the structures through a StructureHost facade. The structure model, assembler, locator, fitting and placing stay host. The resource kinds become iris:structure-model/*, owned by Iris's own module. StructurePlacement names its structures with @Ref(Reference.PACK_STRUCTURE), so the exposed package names no host class. CaveProfiles had no users and is removed.
This commit is contained in:
1 parent
2ae16b9c9e
commit
c9058e0892
6 files changed
+73
-84
No files matched your search
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.builtin.structure;
|
||||
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
* What {@code iris:structure} asks of Iris: Iris places its jigsaw structures itself. The structure model (structures,
|
||||
* pools, pieces), the assembler that builds a structure from them and the locator that spreads them over the world are
|
||||
* Iris's, shared with the jigsaw studio and the structure importers and exporters. Iris's worlds implement it; a module
|
||||
* reaches it with {@link #of}.
|
||||
*/
|
||||
public interface StructureHost {
|
||||
/** The host of the world {@code settings} are the pack's of, which must be a world Iris generates. */
|
||||
static StructureHost of(PackSettings settings) {
|
||||
if (settings instanceof Source source) {
|
||||
return source.structures();
|
||||
}
|
||||
throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + settings);
|
||||
}
|
||||
|
||||
/** The host of {@code world}, which must be a world Iris generates. */
|
||||
static StructureHost of(PackWorld world) {
|
||||
if (world instanceof Source source) {
|
||||
return source.structures();
|
||||
}
|
||||
throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + world);
|
||||
}
|
||||
|
||||
/** Places the structures that start in the chunk whose mantle this thread is generating. */
|
||||
void placeChunk();
|
||||
|
||||
/** How far, in blocks along X and Z, a structure may write beyond the chunk it starts in. */
|
||||
int reach();
|
||||
|
||||
/** Iris's worlds answer for their structures. */
|
||||
interface Source {
|
||||
StructureHost structures();
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,12 @@
|
||||
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinItems;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.ResourceRef;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -34,13 +32,12 @@ import java.util.Optional;
|
||||
/**
|
||||
* Where and how often the structures of a dimension, region or biome start, written as one entry of its
|
||||
* {@code "structures": [...]}: the pack's own structures to assemble or the platform's to start natively, the
|
||||
* distribution of the starts, the height they anchor at, and how they meet the terrain. IrisApi types only, besides
|
||||
* the structure resource kind the {@code structures} keys name.
|
||||
* distribution of the starts, the height they anchor at, and how they meet the terrain. IrisApi types only.
|
||||
*/
|
||||
@Desc("Attaches structures to a biome, region or dimension and controls where and how often they generate. This is independent of a structure's own native generation, so you can add custom placements in tandem with native generation or instead of it.")
|
||||
public final class StructurePlacement {
|
||||
@MinItems(1)
|
||||
@ResourceRef(IrisStructure.class)
|
||||
@Ref(Reference.PACK_STRUCTURE)
|
||||
@Desc("Editable Iris assembly resources offered by this placement. Leave empty when nativeStructures supplies the source.")
|
||||
private List<String> structures = List.of();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.volmit.resource.ResourceKind;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The resource kinds of module {@code iris:structure}, which keep the folders and files Iris packs have always used,
|
||||
* The resource kinds of Iris's module {@code iris:structure-model}, which keep the folders and files Iris packs have always used,
|
||||
* and lookups by pack key for code that still names structures, pools and pieces by key. Every lookup goes through
|
||||
* the pack's {@link com.volmit.resource.PackResources}, so it sees the pack's current snapshot: a hotload, or
|
||||
* {@link IrisData#invalidateStructureResources()} after a tool rewrote the files, reads them again.
|
||||
@@ -40,16 +40,16 @@ import java.util.List;
|
||||
*/
|
||||
public final class StructureResources {
|
||||
/** Jigsaw structures, in {@code structures/}. */
|
||||
public static final ResourceKind<IrisStructure> STRUCTURES = ResourceKind.of("iris:structure/structure", "structures", IrisStructure.class);
|
||||
public static final ResourceKind<IrisStructure> STRUCTURES = ResourceKind.of("iris:structure-model/structure", "structures", IrisStructure.class);
|
||||
/** Jigsaw pools a structure starts from and connectors lead to, in {@code jigsaw-pools/}. */
|
||||
public static final ResourceKind<IrisJigsawPool> POOLS = ResourceKind.of("iris:structure/pool", "jigsaw-pools", IrisJigsawPool.class);
|
||||
public static final ResourceKind<IrisJigsawPool> POOLS = ResourceKind.of("iris:structure-model/pool", "jigsaw-pools", IrisJigsawPool.class);
|
||||
/** Jigsaw pieces pools hold, each an object with connectors, in {@code jigsaw-pieces/}. */
|
||||
public static final ResourceKind<IrisJigsawPiece> PIECES = ResourceKind.of("iris:structure/piece", "jigsaw-pieces", IrisJigsawPiece.class);
|
||||
public static final ResourceKind<IrisJigsawPiece> PIECES = ResourceKind.of("iris:structure-model/piece", "jigsaw-pieces", IrisJigsawPiece.class);
|
||||
|
||||
private StructureResources() {
|
||||
}
|
||||
|
||||
/** Every resource kind of the structure module. */
|
||||
/** Every resource kind of the structure model. */
|
||||
public static List<ResourceKind<?>> kinds() {
|
||||
return List.of(STRUCTURES, POOLS, PIECES);
|
||||
}
|
||||
|
||||
@@ -19,47 +19,25 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementSettings;
|
||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
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.ModuleLog;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:structure}: Iris structures, written into the mantle after objects, whose trees they clear
|
||||
* where they intersect, and after floating objects. A port of what was Iris's structure mantle component, its
|
||||
* work done by {@link StructurePlacing}, one per engine runtime. Its reach is the pack's largest structure.
|
||||
* <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. 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. The pack's structure placements are its
|
||||
* {@code "structures"} settings ({@link StructurePlacementSettings}) of the dimension, its regions and biomes.
|
||||
* Module {@code iris:structure}: the structure placements a pack declares, and the mantle stage that places the jigsaw
|
||||
* structures starting in each chunk. Iris builds and places the structures ({@link StructureHost}); the structure
|
||||
* resources, their validation, the locator and the platform structure answers are Iris's own module
|
||||
* {@code iris:structure-model}.
|
||||
*/
|
||||
public final class StructureModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
private ModuleLog log;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:structure", "Structures", VERSION);
|
||||
@@ -68,30 +46,20 @@ public final class StructureModule implements IrisModule {
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(IrisStages.Structure.PLACE).softAfter(IrisStages.Objects.PLACE.ref(), IrisStages.Floating.OBJECTS.ref())
|
||||
.reach(this::reach).run(StructureModule::place);
|
||||
.reach(StructureModule::reach).run(StructureModule::place);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
log = registry.log();
|
||||
registry.registerSettings(StructureSettings.class);
|
||||
registry.registerSettings(StructurePlacementSettings.class);
|
||||
StructureResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerValidator(new StructureValidator());
|
||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||
registry.registerService(VanillaStructures.class, new StructureVanillaStructures());
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||
placing(chunk.engine(), context.log()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||
StructureHost.of(context.world()).placeChunk();
|
||||
}
|
||||
|
||||
private int reach(PackSettings settings) {
|
||||
return placing(IrisPackSettings.of(settings).engine(), log).reach();
|
||||
}
|
||||
|
||||
private static StructurePlacing placing(Engine engine, ModuleLog log) {
|
||||
return engine.getGeneration().state(StructurePlacing.class, generating -> new StructurePlacing(generating, log));
|
||||
private static int reach(PackSettings settings) {
|
||||
return StructureHost.of(settings).reach();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
|
||||
/** The cave profiles dimensions, regions and biomes declare ({@code caveProfile}). */
|
||||
public final class CaveProfiles {
|
||||
private CaveProfiles() {
|
||||
}
|
||||
|
||||
/** The profile {@code owner}, a dimension, region or biome, declares; null when it declares none, which is as good as one that is not enabled. */
|
||||
public static CaveProfile declaredBy(IrisRegistrant owner) {
|
||||
return owner.getModuleSettings().find(CaveProfile.class).orElse(null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user