mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
importedStructures becomes iris:structure settings; the native structure planner moves into the module's vanilla hook
builtin.structure: StructureSettings (feature iris:structure, target DIMENSION, the JSON of IrisImportedStructureControl: disabled, disabledExact, undergroundYShift, datapackOverrides, frequencyOverrides, adjustments), StructureSetFrequency, StructureAdjustment, IrisApi types only (fits are StructureTerrain, StructureStilts, YBand). ImportedStructures reads them: disables (family and exact keys), adjustment per structure and underground step, setup (frequencies, protecting vanilla definitions), matchesKey. NativeStartPlanner is the planner that was core's (selectSource, resolveBaseY, priority by placementIdentity, same RNG domain). StructureVanillaHook answers rule (REPLACE/BLOCK/ALSO_PLACE from placements and settings), adjustment, starts (planner plans as VanillaStructureStarts, heights above the bottom) and setup; StructureModule registers it and its settings. Deleted: IrisDimension.importedStructures, IrisImportedStructureControl, IrisVanillaStructureAdjustment, IrisStructureSetFrequencyOverride, RegistryListVanillaStructureSet, RegistryListVanillaStructure.prefixes.
This commit is contained in:
1 parent
c1f23830a2
commit
8a6bc5bfc0
13 files changed
+643
-304
No files matched your search
+59
-34
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -16,32 +16,28 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.structure.vanilla;
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureStiltSettings;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureYBand;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
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.vanilla.StructureStilts;
|
||||
import com.volmit.vanilla.StructureTerrain;
|
||||
import com.volmit.vanilla.YBand;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** One entry of {@link StructureSettings#adjustments()}: how the platform's own starts of the structures it matches are moved and fitted. */
|
||||
@Desc("A per-structure adjustment applied to vanilla, mod, and datapack structures that still generate natively (those NOT suppressed by an Iris 'structures' placement). Vertical shifts move the structure start, pieces, bounds, and jigsaw metadata together before references and placement. Intersecting trees are cleared automatically inside structure piece envelopes; optional postprocessing can build palette-driven foundation columns.")
|
||||
@Data
|
||||
public class IrisVanillaStructureAdjustment {
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
@RegistryListVanillaStructure(prefixes = true)
|
||||
public final class StructureAdjustment {
|
||||
@MinItems(1)
|
||||
@Ref(Reference.STRUCTURE_PREFIX)
|
||||
@Desc("Structure keys this adjustment applies to, e.g. 'minecraft:stronghold'. A namespace:path prefix also matches, so 'minecraft:village' adjusts every village variant and 'minecraft:ruined_portal' adjusts every ruined portal. Empty matches nothing.")
|
||||
private KList<String> match = new KList<>();
|
||||
private List<String> match = List.of();
|
||||
|
||||
@MinNumber(-512)
|
||||
@MaxNumber(512)
|
||||
@@ -49,23 +45,52 @@ public class IrisVanillaStructureAdjustment {
|
||||
private int yShift = 0;
|
||||
|
||||
@Desc("Optional absolute world Y band. The structure is relocated so its vertical midpoint lands inside the band, deterministically from its start chunk and clamped to the world's build bounds. Precedence: preserveSourceY wins over yBand, and yBand wins over both yShift and Iris burial repositioning. Structures with a fixed vanilla alignment (ocean monument sea level, desert and jungle pyramid surface fit) ignore it.")
|
||||
private IrisStructureYBand yBand = null;
|
||||
private YBand yBand = null;
|
||||
|
||||
@Desc("When true, skip Iris burial repositioning so the structure keeps the Y its own vanilla placement chose. Underground structures are otherwise pushed below the lowest solid column across their whole footprint, which hides terrain-aware structures such as mineshafts that intentionally breach cliffs and surfaces. Vertical shifts still apply on top of the preserved Y: this dimension's undergroundYShift plus every matching adjustment's yShift.")
|
||||
private boolean preserveSourceY = false;
|
||||
|
||||
@Desc("Optional foundation columns placed beneath the native structure piece bases after placement.")
|
||||
private IrisStructureStiltSettings stilt = null;
|
||||
private StructureStilts stilt = null;
|
||||
|
||||
@Desc("Optional terrain integration override. VACUUM raises surface terrain from processed solid rigid-template foundations at or below each authored ground plane with a 12-block falloff without lowering existing ground. BORE and FORCE_CARVE clear every intersecting chunk before native pieces are placed, while ENCASE fills it with solid blocks instead. Left unset, SOURCE replays the registered structure's authored terrain adaptation, including surface fitting, burial, and encapsulation.")
|
||||
private IrisStructureTerrain terrain = null;
|
||||
private StructureTerrain terrain = null;
|
||||
|
||||
public boolean matches(String key) {
|
||||
for (String entry : match) {
|
||||
if (IrisImportedStructureControl.matchesKey(entry, key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public StructureAdjustment() {
|
||||
}
|
||||
|
||||
public StructureAdjustment(List<String> match, int yShift, YBand yBand, boolean preserveSourceY, StructureStilts stilt,
|
||||
StructureTerrain terrain) {
|
||||
this.match = List.copyOf(match);
|
||||
this.yShift = yShift;
|
||||
this.yBand = yBand;
|
||||
this.preserveSourceY = preserveSourceY;
|
||||
this.stilt = stilt;
|
||||
this.terrain = terrain;
|
||||
}
|
||||
|
||||
/** Family patterns of the structures this adjustment applies to. */
|
||||
public List<String> match() {
|
||||
return StructureSettings.listOrEmpty(match);
|
||||
}
|
||||
|
||||
public int yShift() {
|
||||
return yShift;
|
||||
}
|
||||
|
||||
public Optional<YBand> yBand() {
|
||||
return Optional.ofNullable(yBand);
|
||||
}
|
||||
|
||||
public boolean preserveSourceY() {
|
||||
return preserveSourceY;
|
||||
}
|
||||
|
||||
public Optional<StructureStilts> stilt() {
|
||||
return Optional.ofNullable(stilt);
|
||||
}
|
||||
|
||||
public Optional<StructureTerrain> terrain() {
|
||||
return Optional.ofNullable(terrain);
|
||||
}
|
||||
}
|
||||
+25
-15
@@ -16,24 +16,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.structure.vanilla;
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructureSet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/** One entry of {@link StructureSettings#frequencyOverrides()}: how often the structures of one platform structure set start. */
|
||||
@Desc("An exact registered structure-set frequency multiplier. Iris retains the set's structures, weights, biome eligibility, placement algorithm, salt, exclusion zone, starts, processors, mobs, loot, and locate behavior while scaling only its native placement density.")
|
||||
@Data
|
||||
public class IrisStructureSetFrequencyOverride {
|
||||
@RegistryListVanillaStructureSet
|
||||
public final class StructureSetFrequency {
|
||||
@Ref(Reference.STRUCTURE_SET)
|
||||
@Desc("Exact registered structure-set key, for example 'minecraft:nether_complexes'. Structure keys such as 'minecraft:fortress' are not valid here.")
|
||||
private String structureSet = "";
|
||||
|
||||
@@ -41,4 +35,20 @@ public class IrisStructureSetFrequencyOverride {
|
||||
@MaxNumber(16)
|
||||
@Desc("Requested placement-density multiplier. Random-spread sets scale their placement frequency first and then their integer chunk spacing; integer spacing and separation constraints can make the realized increase slightly lower or higher. The default 1 leaves the registered placement unchanged.")
|
||||
private double multiplier = 1D;
|
||||
|
||||
public StructureSetFrequency() {
|
||||
}
|
||||
|
||||
public StructureSetFrequency(String structureSet, double multiplier) {
|
||||
this.structureSet = structureSet;
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
public String structureSet() {
|
||||
return structureSet == null ? "" : structureSet;
|
||||
}
|
||||
|
||||
public double multiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
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 java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* How a dimension treats the platform's own structures (vanilla, data pack and mod structures), written as
|
||||
* {@code "iris:structure": {"disabled": [...], "adjustments": [...]}}: which ones it disables, how the ones that still
|
||||
* generate are moved and fitted, how often structure sets start, and whether installed data packs may replace the
|
||||
* platform's own definitions. The JSON packs wrote as {@code importedStructures}. IrisApi types only.
|
||||
*/
|
||||
@Desc("Controls native vanilla, mod, and ingested datapack structure generation for this dimension. Every registered structure generates through its native placement unless its key matches 'disabled', equals a key in 'disabledExact', or a viable dimension-level Iris placement explicitly replaces its source. Family matching uses namespace, slash, or underscore boundaries, while exact matching compares normalized complete keys only. Run '/iris structure list <dimension>' to dump every valid key. Only affects newly generated chunks and is separate from Iris structure placements.")
|
||||
@Feature(id = "iris:structure", name = "Structures", targets = Target.DIMENSION)
|
||||
public final class StructureSettings implements IrisFeature {
|
||||
@MinItems(1)
|
||||
@Ref(Reference.STRUCTURE_PREFIX)
|
||||
@Desc("Structure keys to deny explicitly, e.g. 'minecraft:stronghold'. A namespace:path prefix also matches, so 'minecraft:village' disables every village variant and 'minecraft:ruined_portal' disables every ruined portal. Every key not matched here remains enabled.")
|
||||
private List<String> disabled = List.of();
|
||||
|
||||
@MinItems(1)
|
||||
@Ref(Reference.STRUCTURE)
|
||||
@Desc("Exact structure keys to deny after trimming and case normalization. Unlike 'disabled', entries never match key families, so 'minecraft:ruined_portal' does not disable 'minecraft:ruined_portal_nether'.")
|
||||
private List<String> disabledExact = List.of();
|
||||
|
||||
@MinNumber(-512)
|
||||
@MaxNumber(512)
|
||||
@Desc("Vertical block offset applied only to UNDERGROUND vanilla structures (the UNDERGROUND_STRUCTURES, UNDERGROUND_DECORATION, and STRONGHOLDS generation steps: strongholds, trial chambers, mineshafts, ancient cities, etc.). Surface structures (villages, outposts, etc.) are never shifted. Use a negative value to push deep structures lower when your dimension's sea/terrain level differs from vanilla's (e.g. -64 if you lowered the fluid height to 0). 0 = no shift.")
|
||||
private int undergroundYShift = 0;
|
||||
|
||||
@Desc("Controls whether ingested datapacks may replace minecraft-namespaced structure definitions, sets, pools, and templates. When false, those overrides are stripped from installed datapack copies so vanilla definitions stay intact. Non-minecraft structures from datapacks and mods remain governed by disabled because namespace alone cannot identify their origin. Resolved globally across loaded packs: if any dimension sets this false, minecraft-namespaced overrides are stripped from every installed datapack copy.")
|
||||
private boolean datapackOverrides = true;
|
||||
|
||||
@MinItems(1)
|
||||
@Desc("Exact registered structure-set frequency overrides for native generation. The last entry for a normalized structure-set key wins. These do not convert native structures into Iris placements and affect only newly generated chunks.")
|
||||
private List<StructureSetFrequency> frequencyOverrides = List.of();
|
||||
|
||||
@MinItems(1)
|
||||
@Desc("Per-structure adjustments applied to vanilla, mod, and datapack structures that still generate natively. Vertical shifts from every matching entry stack. A matching preserveSourceY option disables Iris burial repositioning for that structure. The last matching entry with stilt settings controls foundation columns, and likewise for terrain and yBand settings. A structure suppressed by an Iris placement is unaffected.")
|
||||
private List<StructureAdjustment> adjustments = List.of();
|
||||
|
||||
public StructureSettings() {
|
||||
}
|
||||
|
||||
public StructureSettings(List<String> disabled, List<String> disabledExact, int undergroundYShift, boolean datapackOverrides,
|
||||
List<StructureSetFrequency> frequencyOverrides, List<StructureAdjustment> adjustments) {
|
||||
this.disabled = List.copyOf(disabled);
|
||||
this.disabledExact = List.copyOf(disabledExact);
|
||||
this.undergroundYShift = undergroundYShift;
|
||||
this.datapackOverrides = datapackOverrides;
|
||||
this.frequencyOverrides = List.copyOf(frequencyOverrides);
|
||||
this.adjustments = List.copyOf(adjustments);
|
||||
}
|
||||
|
||||
/** Family patterns of the structures the dimension disables. */
|
||||
public List<String> disabled() {
|
||||
return listOrEmpty(disabled);
|
||||
}
|
||||
|
||||
/** Complete keys of the structures the dimension disables. */
|
||||
public List<String> disabledExact() {
|
||||
return listOrEmpty(disabledExact);
|
||||
}
|
||||
|
||||
public int undergroundYShift() {
|
||||
return undergroundYShift;
|
||||
}
|
||||
|
||||
public boolean datapackOverrides() {
|
||||
return datapackOverrides;
|
||||
}
|
||||
|
||||
public List<StructureSetFrequency> frequencyOverrides() {
|
||||
return listOrEmpty(frequencyOverrides);
|
||||
}
|
||||
|
||||
public List<StructureAdjustment> adjustments() {
|
||||
return listOrEmpty(adjustments);
|
||||
}
|
||||
|
||||
static <T> List<T> listOrEmpty(List<T> list) {
|
||||
return list == null ? List.of() : Collections.unmodifiableList(list);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.engine.framework.structure.NativeStartPlanner;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
|
||||
@@ -479,7 +480,7 @@ public final class IrisStructureLocator {
|
||||
if (engine == null || engine.getData() == null || engine.getSeedManager() == null) {
|
||||
throw new IllegalStateException("Iris structure placement requires a fully bound engine");
|
||||
}
|
||||
NativeStructurePlacementPlanner.validateBackend(placement);
|
||||
NativeStartPlanner.validateBackend(placement);
|
||||
if (!placement.hasIrisStructures() || placement.getDistribution() == null) {
|
||||
throw new IllegalStateException("Iris structure placement is missing its distribution or structure list");
|
||||
}
|
||||
@@ -600,7 +601,7 @@ public final class IrisStructureLocator {
|
||||
IrisData data = engine.getData();
|
||||
String normalizedKey = normalize(key);
|
||||
if (hasNativePlacement(engine, key)) {
|
||||
for (NativeStructureStartPlan plan : NativeStructurePlacementPlanner.plansAt(engine, cx, cz)) {
|
||||
for (NativeStartPlanner.Plan plan : NativeStartPlanner.plansAt(engine, cx, cz)) {
|
||||
if (normalize(plan.source().getStructure()).equals(normalizedKey)) {
|
||||
return new ResolvedStart(cx << 4, plan.baseY(), cz << 4);
|
||||
}
|
||||
@@ -648,7 +649,7 @@ public final class IrisStructureLocator {
|
||||
return null;
|
||||
}
|
||||
if (!placement.isUnderwater()
|
||||
&& NativeStructurePlacementPlanner.isSubmerged(engine, originX, originZ)) {
|
||||
&& NativeStartPlanner.isSubmerged(engine, originX, originZ)) {
|
||||
return null;
|
||||
}
|
||||
if (placement.resolvedAnchor() == IrisStructureAnchorMode.SURFACE) {
|
||||
@@ -1180,7 +1181,7 @@ public final class IrisStructureLocator {
|
||||
if (placement.getDistribution() == null) {
|
||||
throw new IllegalStateException("Iris structure placement is missing its distribution");
|
||||
}
|
||||
NativeStructurePlacementPlanner.validateBackend(placement);
|
||||
NativeStartPlanner.validateBackend(placement);
|
||||
boolean replacesNative = NativeStructureSuppression.REPLACE_SOURCE == placement.getNativeSuppression();
|
||||
if (replacesNative && !allowNativeSuppression) {
|
||||
throw new IllegalStateException("REPLACE_SOURCE is only valid on dimension-level structure placements");
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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.builtin.structure.StructureAdjustment;
|
||||
import art.arcane.iris.builtin.structure.StructureSetFrequency;
|
||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.vanilla.VanillaStructureAdjustment;
|
||||
import com.volmit.vanilla.VanillaStructureFit;
|
||||
import com.volmit.vanilla.VanillaStructureSetup;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What a dimension's {@link StructureSettings} say about the platform's own structures: which ones it disables, how
|
||||
* the starts of the others are adjusted, and how the platform sets them up. Keys match ignoring case and surrounding
|
||||
* space; a family pattern also matches the keys it starts at a namespace, slash or underscore boundary
|
||||
* ({@link #matchesKey}).
|
||||
*/
|
||||
public final class ImportedStructures {
|
||||
private final StructureSettings settings;
|
||||
|
||||
public ImportedStructures(StructureSettings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/** The settings the dimension of {@code settings} declares, or the defaults when it declares none. */
|
||||
public static ImportedStructures of(PackSettings settings) {
|
||||
List<Entry<StructureSettings>> declared = settings.declared(StructureSettings.class);
|
||||
return new ImportedStructures(declared.isEmpty() ? new StructureSettings() : declared.getFirst().value());
|
||||
}
|
||||
|
||||
/** Whether the dimension disables the platform structure {@code key}, by family or by its exact key. */
|
||||
public boolean disables(String key) {
|
||||
String normalizedKey = normalize(key);
|
||||
if (normalizedKey.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return settings.disabled().stream().anyMatch(pattern -> matchesKey(pattern, key))
|
||||
|| settings.disabledExact().stream().map(ImportedStructures::normalize)
|
||||
.anyMatch(exact -> !exact.isEmpty() && exact.equals(normalizedKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* How the platform's own starts of {@code key} are adjusted: the underground shift for underground steps, then every
|
||||
* matching adjustment in the order the pack lists them.
|
||||
*/
|
||||
public VanillaStructureAdjustment adjustment(String key, boolean underground) {
|
||||
VanillaStructureAdjustment adjustment = VanillaStructureAdjustment.NONE.shifted(underground ? settings.undergroundYShift() : 0);
|
||||
for (StructureAdjustment entry : settings.adjustments()) {
|
||||
if (entry != null && matchesAny(entry.match(), key)) {
|
||||
adjustment = adjustment.then(asAdjustment(entry));
|
||||
}
|
||||
}
|
||||
return adjustment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The structure set frequencies the dimension changes and whether it keeps data packs off the platform's definitions.
|
||||
* An override naming no namespaced key can match no registered set and is left out.
|
||||
*/
|
||||
public VanillaStructureSetup setup() {
|
||||
VanillaStructureSetup setup = settings.datapackOverrides()
|
||||
? VanillaStructureSetup.UNCHANGED
|
||||
: VanillaStructureSetup.UNCHANGED.protectingVanillaDefinitions();
|
||||
for (StructureSetFrequency override : settings.frequencyOverrides()) {
|
||||
Optional<ResourceId> structureSet = override == null ? Optional.empty() : structureSetId(override.structureSet());
|
||||
if (structureSet.isPresent()) {
|
||||
setup = setup.withFrequency(structureSet.get(), override.multiplier());
|
||||
}
|
||||
}
|
||||
return setup;
|
||||
}
|
||||
|
||||
private static Optional<ResourceId> structureSetId(String key) {
|
||||
try {
|
||||
return Optional.of(ResourceId.parse(normalize(key)));
|
||||
} catch (IllegalArgumentException notAnId) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the family pattern {@code pattern} matches the structure {@code key}: equal keys, or a pattern the key
|
||||
* starts with that ends in, or is followed in the key by, {@code :}, {@code /} or {@code _}. So
|
||||
* {@code minecraft:village} matches {@code minecraft:village_plains} and {@code nova_structures:} a whole namespace.
|
||||
*/
|
||||
public static boolean matchesKey(String pattern, String key) {
|
||||
if (pattern == null || key == null) {
|
||||
return false;
|
||||
}
|
||||
String normalizedPattern = normalize(pattern);
|
||||
String normalizedKey = normalize(key);
|
||||
if (normalizedPattern.isEmpty() || !normalizedKey.startsWith(normalizedPattern)) {
|
||||
return false;
|
||||
}
|
||||
if (normalizedKey.length() == normalizedPattern.length()) {
|
||||
return true;
|
||||
}
|
||||
char patternEnd = normalizedPattern.charAt(normalizedPattern.length() - 1);
|
||||
if (patternEnd == ':' || patternEnd == '/' || patternEnd == '_') {
|
||||
return true;
|
||||
}
|
||||
char boundary = normalizedKey.charAt(normalizedPattern.length());
|
||||
return boundary == '/' || boundary == '_';
|
||||
}
|
||||
|
||||
private static boolean matchesAny(List<String> patterns, String key) {
|
||||
return patterns.stream().anyMatch(pattern -> matchesKey(pattern, key));
|
||||
}
|
||||
|
||||
private static VanillaStructureAdjustment asAdjustment(StructureAdjustment entry) {
|
||||
VanillaStructureFit fit = VanillaStructureFit.SOURCE;
|
||||
fit = entry.stilt().map(fit::withStilts).orElse(fit);
|
||||
fit = entry.terrain().map(fit::withTerrain).orElse(fit);
|
||||
VanillaStructureAdjustment adjustment = VanillaStructureAdjustment.NONE.shifted(entry.yShift()).withFit(fit);
|
||||
adjustment = entry.yBand().map(adjustment::withYBand).orElse(adjustment);
|
||||
return entry.preserveSourceY() ? adjustment.keepingSourceY() : adjustment;
|
||||
}
|
||||
|
||||
private static String normalize(String key) {
|
||||
return key == null ? "" : key.trim().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* 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.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementGrid;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Where the pack's {@code nativeStructures} placements start platform structures: for one chunk, every placement in
|
||||
* scope whose grid starts there picks a weighted source and a base height. When several placements start the same
|
||||
* structure in one chunk, the placement with the lowest {@link StructurePlacementGrid#placementIdentity} (unsigned)
|
||||
* wins. Seeded from the mantle seed with the selection domain the planner always used, so worlds keep their starts.
|
||||
*/
|
||||
public final class NativeStartPlanner {
|
||||
private static final long NATIVE_SELECTION_DOMAIN = 0x4E41544956454A53L;
|
||||
|
||||
private NativeStartPlanner() {
|
||||
}
|
||||
|
||||
/** One start a {@code nativeStructures} placement makes: the placement, its chosen source and world base Y. */
|
||||
public record Plan(IrisStructurePlacement placement, IrisNativeStructure source, int chunkX, int chunkZ, int baseY) {
|
||||
}
|
||||
|
||||
public static List<Plan> plansAt(Engine engine, int chunkX, int chunkZ) {
|
||||
Map<String, Plan> plansByStructure = new LinkedHashMap<>();
|
||||
for (IrisStructurePlacement placement : StructurePlacementScope.placementsAt(engine, chunkX, chunkZ)) {
|
||||
Plan plan = planAt(engine, placement, chunkX, chunkZ);
|
||||
if (plan == null) {
|
||||
continue;
|
||||
}
|
||||
String structureKey = normalize(plan.source().getStructure());
|
||||
Plan current = plansByStructure.get(structureKey);
|
||||
if (current == null || comparePlacementPriority(plan.placement(), current.placement()) < 0) {
|
||||
plansByStructure.put(structureKey, plan);
|
||||
}
|
||||
}
|
||||
return List.copyOf(plansByStructure.values());
|
||||
}
|
||||
|
||||
public static Plan planAt(Engine engine, IrisStructurePlacement placement, int chunkX, int chunkZ) {
|
||||
validateBackend(placement);
|
||||
if (!placement.hasNativeStructures()) {
|
||||
return null;
|
||||
}
|
||||
Engine activeEngine = Objects.requireNonNull(engine, "Native structure planner requires an engine");
|
||||
if (activeEngine.getSeedManager() == null) {
|
||||
throw new IllegalStateException("Native structure planner requires a bound seed manager");
|
||||
}
|
||||
long mantleSeed = activeEngine.getSeedManager().getMantle();
|
||||
if (!StructurePlacementGrid.startsInChunk(placement, chunkX, chunkZ, mantleSeed)) {
|
||||
return null;
|
||||
}
|
||||
RNG placementRng = StructurePlacementGrid.placementRng(
|
||||
placement, chunkX, chunkZ, mantleSeed).nextParallelRNG(NATIVE_SELECTION_DOMAIN);
|
||||
IrisNativeStructure source = selectSource(placement.getNativeStructures(), placementRng);
|
||||
Integer baseY = resolveBaseY(activeEngine, placement, chunkX, chunkZ, placementRng);
|
||||
if (baseY == null) {
|
||||
return null;
|
||||
}
|
||||
return new Plan(placement, source, chunkX, chunkZ, baseY);
|
||||
}
|
||||
|
||||
public static void validateBackend(IrisStructurePlacement placement) {
|
||||
if (placement == null) {
|
||||
throw new IllegalStateException("Structure placement must not be null");
|
||||
}
|
||||
boolean iris = placement.hasIrisStructures();
|
||||
boolean nativeStructure = placement.hasNativeStructures();
|
||||
if (iris == nativeStructure) {
|
||||
throw new IllegalStateException("Structure placement must declare exactly one backend: "
|
||||
+ "structures or nativeStructures");
|
||||
}
|
||||
if (nativeStructure && placement.getAnchor() != null
|
||||
&& placement.getAnchor() != IrisStructureAnchorMode.LEGACY) {
|
||||
throw new IllegalStateException("Native structure placements do not support the Iris anchor field");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSubmerged(Engine engine, int blockX, int blockZ) {
|
||||
return engine.getHeight(blockX, blockZ, true) < engine.getDimension().getFluidHeight();
|
||||
}
|
||||
|
||||
static IrisNativeStructure selectSource(KList<IrisNativeStructure> sources, RNG rng) {
|
||||
Objects.requireNonNull(sources, "Native structure sources must not be null");
|
||||
Objects.requireNonNull(rng, "Native structure selection requires an RNG");
|
||||
long totalWeight = 0L;
|
||||
for (IrisNativeStructure source : sources) {
|
||||
if (source == null || source.getStructure() == null || source.getStructure().isBlank()) {
|
||||
throw new IllegalStateException("Native structure placement contains a blank source");
|
||||
}
|
||||
if (source.getWeight() < 1) {
|
||||
throw new IllegalStateException("Native structure source '" + source.getStructure()
|
||||
+ "' has invalid weight " + source.getWeight());
|
||||
}
|
||||
totalWeight = Math.addExact(totalWeight, source.getWeight());
|
||||
}
|
||||
if (totalWeight > Integer.MAX_VALUE) {
|
||||
throw new IllegalStateException("Native structure source weights exceed " + Integer.MAX_VALUE);
|
||||
}
|
||||
int roll = rng.nextInt((int) totalWeight);
|
||||
for (IrisNativeStructure source : sources) {
|
||||
roll -= source.getWeight();
|
||||
if (roll < 0) {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Native structure source selection produced no result");
|
||||
}
|
||||
|
||||
private static Integer resolveBaseY(Engine engine, IrisStructurePlacement placement,
|
||||
int chunkX, int chunkZ, RNG rng) {
|
||||
int worldMin = engine.getMinHeight() + 1;
|
||||
int worldMax = engine.getMinHeight() + engine.getHeight() - 1;
|
||||
if (worldMin > worldMax) {
|
||||
throw new IllegalStateException("Native structure placement has invalid world height bounds");
|
||||
}
|
||||
int blockX = (chunkX << 4) + 8;
|
||||
int blockZ = (chunkZ << 4) + 8;
|
||||
if (!placement.isUnderwater() && isSubmerged(engine, blockX, blockZ)) {
|
||||
return null;
|
||||
}
|
||||
if (!placement.isUnderground()) {
|
||||
int surfaceY = engine.getHeight(blockX, blockZ, true) + engine.getMinHeight();
|
||||
if (surfaceY < placement.getMinHeight() || surfaceY > placement.getMaxHeight()) {
|
||||
return null;
|
||||
}
|
||||
return surfaceY;
|
||||
}
|
||||
int bandMin = Math.max(worldMin, Math.min(placement.getMinHeight(), placement.getMaxHeight()));
|
||||
int bandMax = Math.min(worldMax, Math.max(placement.getMinHeight(), placement.getMaxHeight()));
|
||||
if (bandMin > bandMax) {
|
||||
return null;
|
||||
}
|
||||
return bandMin == bandMax ? bandMin : bandMin + rng.nextInt((bandMax - bandMin) + 1);
|
||||
}
|
||||
|
||||
private static int comparePlacementPriority(IrisStructurePlacement left, IrisStructurePlacement right) {
|
||||
long leftIdentity = StructurePlacementGrid.placementIdentity(left);
|
||||
long rightIdentity = StructurePlacementGrid.placementIdentity(right);
|
||||
return Long.compareUnsigned(leftIdentity, rightIdentity);
|
||||
}
|
||||
|
||||
private static String normalize(String structureKey) {
|
||||
return structureKey == null ? "" : structureKey.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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.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.StructurePlacementGrid;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.vanilla.JigsawOverrides;
|
||||
import com.volmit.vanilla.StructureStilts;
|
||||
import com.volmit.vanilla.StructureTerrain;
|
||||
import com.volmit.vanilla.VanillaStructureAdjustment;
|
||||
import com.volmit.vanilla.VanillaStructureContext;
|
||||
import com.volmit.vanilla.VanillaStructureFit;
|
||||
import com.volmit.vanilla.VanillaStructureHook;
|
||||
import com.volmit.vanilla.VanillaStructureRule;
|
||||
import com.volmit.vanilla.VanillaStructureSetup;
|
||||
import com.volmit.vanilla.VanillaStructureStart;
|
||||
import com.volmit.vanilla.VanillaStructureStartContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* What {@code iris:structure} says about the platform's own structures. The dimension's {@code iris:structure}
|
||||
* settings ({@link ImportedStructures}) disable, adjust and set them up; the pack's structure placements replace
|
||||
* them ({@code vanillaSource} with native suppression), place them alongside ({@link IrisStructureLocator#isPlaced})
|
||||
* and start them where their {@code nativeStructures} grids say ({@link NativeStartPlanner}).
|
||||
*/
|
||||
public final class StructureVanillaHook implements VanillaStructureHook {
|
||||
private static final Gson SAME_JSON = new Gson();
|
||||
|
||||
/**
|
||||
* {@link VanillaStructureRule#REPLACE} for a structure an Iris structure replaces or the dimension disables while a
|
||||
* placement places it, {@link VanillaStructureRule#BLOCK} for one the dimension disables, and
|
||||
* {@link VanillaStructureRule#ALSO_PLACE} for one a placement places alongside the platform.
|
||||
*/
|
||||
@Override
|
||||
public VanillaStructureRule rule(ResourceId structure, VanillaStructureContext context) {
|
||||
Engine engine = IrisPackSettings.of(context.settings()).engine();
|
||||
String key = structure.toString();
|
||||
boolean replaced = IrisStructureLocator.suppressesVanilla(engine, key);
|
||||
boolean blocked = replaced || ImportedStructures.of(context.settings()).disables(key);
|
||||
boolean placed = replaced || IrisStructureLocator.isPlaced(engine, key);
|
||||
VanillaStructureRule rule = blocked ? VanillaStructureRule.BLOCK : VanillaStructureRule.GENERATE;
|
||||
return placed ? rule.and(VanillaStructureRule.ALSO_PLACE) : rule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VanillaStructureAdjustment adjustment(ResourceId structure, boolean underground, VanillaStructureContext context) {
|
||||
return ImportedStructures.of(context.settings()).adjustment(structure.toString(), underground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VanillaStructureStart> starts(int chunkX, int chunkZ, VanillaStructureStartContext context) {
|
||||
Engine engine = IrisPackWorld.of(context.world()).engine();
|
||||
return NativeStartPlanner.plansAt(engine, chunkX, chunkZ).stream()
|
||||
.map(plan -> start(plan, engine.getMinHeight()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VanillaStructureSetup setup(VanillaStructureContext context) {
|
||||
return ImportedStructures.of(context.settings()).setup();
|
||||
}
|
||||
|
||||
/** {@code plan} as the start the platform generates: heights above the bottom, the placement's fit and identity. */
|
||||
static VanillaStructureStart start(NativeStartPlanner.Plan plan, int minHeight) {
|
||||
IrisStructurePlacement placement = plan.placement();
|
||||
VanillaStructureStart start = VanillaStructureStart.at(ResourceId.parse(plan.source().getStructure()),
|
||||
plan.chunkX(), plan.chunkZ(), plan.baseY() - minHeight)
|
||||
.withIdentity(StructurePlacementGrid.placementIdentity(placement))
|
||||
.withFit(fit(placement));
|
||||
if (placement.isUnderground()) {
|
||||
start = start.underground();
|
||||
}
|
||||
if (placement.getNativeSuppression() == NativeStructureSuppression.REPLACE_SOURCE) {
|
||||
start = start.replacingPlatformStart();
|
||||
}
|
||||
if (plan.source().getJigsaw() != null) {
|
||||
start = start.withJigsaw(sameJson(plan.source().getJigsaw(), JigsawOverrides.class));
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
private static VanillaStructureFit fit(IrisStructurePlacement placement) {
|
||||
VanillaStructureFit fit = VanillaStructureFit.SOURCE.withTerrain(sameJson(placement.resolvedTerrain(), StructureTerrain.class));
|
||||
return placement.getStilt() == null ? fit : fit.withStilts(sameJson(placement.getStilt(), StructureStilts.class));
|
||||
}
|
||||
|
||||
/** The placement classes are Iris's; the API values read the same JSON. */
|
||||
private static <T> T sameJson(Object irisValue, Class<T> apiType) {
|
||||
return SAME_JSON.fromJson(SAME_JSON.toJsonTree(irisValue), apiType);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
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.core.modules.IrisPackWorld;
|
||||
@@ -27,17 +28,15 @@ 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 art.arcane.iris.engine.framework.structure.StructureVanillaHook;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.vanilla.VanillaStructureContext;
|
||||
import com.volmit.vanilla.VanillaStructureRule;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
@@ -51,8 +50,9 @@ import com.volmit.world.PackWorld;
|
||||
* {@link StructureLocating}, and forgets a world's structure index when the world stops, which includes every reload of
|
||||
* the pack's structure files.
|
||||
* <p>
|
||||
* It decides over the platform's own structures through its vanilla structure hook ({@link #vanillaRule}): a structure
|
||||
* an Iris structure replaces is blocked, and one a structure placement of the pack places is reported as placed here.
|
||||
* It decides over the platform's own structures through its vanilla structure hook ({@link StructureVanillaHook}): the
|
||||
* dimension's {@code iris:structure} settings disable, adjust and set them up, and the pack's structure placements
|
||||
* replace them, place them alongside, and start them where their {@code nativeStructures} grids say.
|
||||
*/
|
||||
public final class StructureModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
@@ -70,11 +70,12 @@ public final class StructureModule implements IrisModule, ModuleLifecycle {
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(StructureSettings.class);
|
||||
StructureResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerValidator(new StructureValidator());
|
||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||
registry.registerLifecycle(this);
|
||||
registry.registerVanillaStructureHook(StructureModule::vanillaRule);
|
||||
registry.registerVanillaStructureHook(new StructureVanillaHook());
|
||||
}
|
||||
|
||||
/** The structure index is still kept per engine rather than in the world's state, so a stopping world drops it. */
|
||||
@@ -83,20 +84,6 @@ public final class StructureModule implements IrisModule, ModuleLifecycle {
|
||||
IrisStructureLocator.invalidate(IrisPackWorld.of(world).engine());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link VanillaStructureRule#REPLACE} for a platform structure that an Iris structure of the world's placements
|
||||
* replaces (its {@code vanillaSource} with native suppression), {@link VanillaStructureRule#ALSO_PLACE} for one
|
||||
* a placement of the world places itself, {@link VanillaStructureRule#GENERATE} otherwise.
|
||||
*/
|
||||
static VanillaStructureRule vanillaRule(ResourceId structure, VanillaStructureContext context) {
|
||||
Engine engine = IrisPackSettings.of(context.settings()).engine();
|
||||
String key = structure.toString();
|
||||
if (IrisStructureLocator.suppressesVanilla(engine, key)) {
|
||||
return VanillaStructureRule.REPLACE;
|
||||
}
|
||||
return IrisStructureLocator.isPlaced(engine, key) ? VanillaStructureRule.ALSO_PLACE : VanillaStructureRule.GENERATE;
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||
placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||
|
||||
-9
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.annotations;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisImportedStructureControl;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@@ -30,12 +29,4 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListVanillaStructure {
|
||||
/**
|
||||
* When true the field accepts family/namespace prefixes in addition to exact registered keys
|
||||
* (the {@code IrisImportedStructureControl.matchesKey} contract: "minecraft:village" matches
|
||||
* every village variant, "nova_structures:" matches a whole namespace). The generated editor
|
||||
* schema then validates entries against the registry enum OR a key/prefix pattern instead of
|
||||
* rejecting anything that is not an exact registered key.
|
||||
*/
|
||||
boolean prefixes() default false;
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListVanillaStructureSet {
|
||||
|
||||
}
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.decoration;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisImportedStructureControl;
|
||||
import art.arcane.iris.engine.framework.structure.ImportedStructures;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
@@ -98,7 +98,7 @@ public class IrisImportedFeatureControl {
|
||||
KList<String> deniedKeys = Objects.requireNonNull(
|
||||
disabled, "importedFeatures.disabled must not be null");
|
||||
for (String entry : deniedKeys) {
|
||||
if (IrisImportedStructureControl.matchesKey(entry, placedFeatureKey)) {
|
||||
if (ImportedStructures.matchesKey(entry, placedFeatureKey)) {
|
||||
return NativeFeatureGenerationStatus.DISABLED_BY_PACK;
|
||||
}
|
||||
}
|
||||
|
||||
-184
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.structure.vanilla;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureStiltSettings;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructureYBand;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Controls native vanilla, mod, and ingested datapack structure generation for this dimension (set as the dimension's 'importedStructures' field). Every registered structure generates through its native placement unless its key matches 'disabled', equals a key in 'disabledExact', or a viable dimension-level Iris placement explicitly replaces its source. Family matching uses namespace, slash, or underscore boundaries, while exact matching compares normalized complete keys only. Run '/iris structure list <dimension>' to dump every valid key. Only affects newly generated chunks and is separate from Iris structure placements.")
|
||||
@Data
|
||||
public class IrisImportedStructureControl {
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
@RegistryListVanillaStructure(prefixes = true)
|
||||
@Desc("Structure keys to deny explicitly, e.g. 'minecraft:stronghold'. A namespace:path prefix also matches, so 'minecraft:village' disables every village variant and 'minecraft:ruined_portal' disables every ruined portal. Every key not matched here remains enabled.")
|
||||
private KList<String> disabled = new KList<>();
|
||||
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
@RegistryListVanillaStructure(prefixes = false)
|
||||
@Desc("Exact structure keys to deny after trimming and case normalization. Unlike 'disabled', entries never match key families, so 'minecraft:ruined_portal' does not disable 'minecraft:ruined_portal_nether'.")
|
||||
private KList<String> disabledExact = new KList<>();
|
||||
|
||||
@MinNumber(-512)
|
||||
@MaxNumber(512)
|
||||
@Desc("Vertical block offset applied only to UNDERGROUND vanilla structures (the UNDERGROUND_STRUCTURES, UNDERGROUND_DECORATION, and STRONGHOLDS generation steps: strongholds, trial chambers, mineshafts, ancient cities, etc.). Surface structures (villages, outposts, etc.) are never shifted. Use a negative value to push deep structures lower when your dimension's sea/terrain level differs from vanilla's (e.g. -64 if you lowered the fluid height to 0). 0 = no shift.")
|
||||
private int undergroundYShift = 0;
|
||||
|
||||
@Desc("Controls whether ingested datapacks may replace minecraft-namespaced structure definitions, sets, pools, and templates. When false, those overrides are stripped from installed datapack copies so vanilla definitions stay intact. Non-minecraft structures from datapacks and mods remain governed by disabled because namespace alone cannot identify their origin. Resolved globally across loaded packs: if any dimension sets this false, minecraft-namespaced overrides are stripped from every installed datapack copy.")
|
||||
private boolean datapackOverrides = true;
|
||||
|
||||
@ArrayType(type = IrisStructureSetFrequencyOverride.class, min = 1)
|
||||
@Desc("Exact registered structure-set frequency overrides for native generation. The last entry for a normalized structure-set key wins. These do not convert native structures into Iris placements and affect only newly generated chunks.")
|
||||
private KList<IrisStructureSetFrequencyOverride> frequencyOverrides = new KList<>();
|
||||
|
||||
@ArrayType(type = IrisVanillaStructureAdjustment.class, min = 1)
|
||||
@Desc("Per-structure adjustments applied to vanilla, mod, and datapack structures that still generate natively. Vertical shifts from every matching entry stack. A matching preserveSourceY option disables Iris burial repositioning for that structure. The last matching entry with stilt settings controls foundation columns, and likewise for terrain and yBand settings. A structure suppressed by an Iris placement is unaffected.")
|
||||
private KList<IrisVanillaStructureAdjustment> adjustments = new KList<>();
|
||||
|
||||
public boolean shouldGenerate(String key) {
|
||||
return key != null && !key.isBlank()
|
||||
&& !matches(disabled, key)
|
||||
&& !matchesExact(disabledExact, key);
|
||||
}
|
||||
|
||||
public IrisNativeStructureDecision resolve(String key, boolean undergroundStep) {
|
||||
KList<IrisVanillaStructureAdjustment> activeAdjustments = Objects.requireNonNull(
|
||||
adjustments, "importedStructures.adjustments must not be null");
|
||||
int y = undergroundStep ? undergroundYShift : 0;
|
||||
boolean preserveSourceY = false;
|
||||
IrisStructureStiltSettings stilt = null;
|
||||
IrisStructureTerrain terrain = null;
|
||||
IrisStructureYBand yBand = null;
|
||||
for (IrisVanillaStructureAdjustment adjustment : activeAdjustments) {
|
||||
if (adjustment != null && adjustment.matches(key)) {
|
||||
y += adjustment.getYShift();
|
||||
preserveSourceY |= adjustment.isPreserveSourceY();
|
||||
if (adjustment.getStilt() != null) {
|
||||
stilt = adjustment.getStilt();
|
||||
}
|
||||
if (adjustment.getTerrain() != null) {
|
||||
terrain = adjustment.getTerrain();
|
||||
}
|
||||
if (adjustment.getYBand() != null) {
|
||||
yBand = adjustment.getYBand();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new IrisNativeStructureDecision(
|
||||
generationStatus(key), y, yBand, preserveSourceY, stilt, terrain);
|
||||
}
|
||||
|
||||
public double frequencyMultiplier(String structureSetKey) {
|
||||
KList<IrisStructureSetFrequencyOverride> activeOverrides = Objects.requireNonNull(
|
||||
frequencyOverrides, "importedStructures.frequencyOverrides must not be null");
|
||||
String normalizedKey = normalizeKey(structureSetKey);
|
||||
if (normalizedKey.isEmpty()) {
|
||||
return 1D;
|
||||
}
|
||||
double multiplier = 1D;
|
||||
for (IrisStructureSetFrequencyOverride override : activeOverrides) {
|
||||
if (override != null && normalizeKey(override.getStructureSet()).equals(normalizedKey)) {
|
||||
multiplier = override.getMultiplier();
|
||||
}
|
||||
}
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
public boolean hasFrequencyOverrides() {
|
||||
return !Objects.requireNonNull(
|
||||
frequencyOverrides, "importedStructures.frequencyOverrides must not be null").isEmpty();
|
||||
}
|
||||
|
||||
private NativeStructureGenerationStatus generationStatus(String key) {
|
||||
if (key == null || key.isBlank()) {
|
||||
return NativeStructureGenerationStatus.INVALID_REGISTRY_KEY;
|
||||
}
|
||||
if (matches(disabled, key) || matchesExact(disabledExact, key)) {
|
||||
return NativeStructureGenerationStatus.DISABLED_BY_PACK;
|
||||
}
|
||||
return NativeStructureGenerationStatus.GENERATE_NATIVE;
|
||||
}
|
||||
|
||||
private boolean matches(KList<String> list, String key) {
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
KList<String> activeList = Objects.requireNonNull(
|
||||
list, "importedStructures.disabled must not be null");
|
||||
for (String entry : activeList) {
|
||||
if (matchesKey(entry, key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesExact(KList<String> list, String key) {
|
||||
KList<String> activeList = Objects.requireNonNull(
|
||||
list, "importedStructures.disabledExact must not be null");
|
||||
String normalizedKey = normalizeKey(key);
|
||||
for (String entry : activeList) {
|
||||
String normalizedEntry = normalizeKey(entry);
|
||||
if (!normalizedEntry.isEmpty() && normalizedEntry.equals(normalizedKey)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matchesKey(String pattern, String key) {
|
||||
if (pattern == null || key == null) {
|
||||
return false;
|
||||
}
|
||||
String normalizedPattern = pattern.trim().toLowerCase(Locale.ROOT);
|
||||
String normalizedKey = key.trim().toLowerCase(Locale.ROOT);
|
||||
if (normalizedPattern.isEmpty() || !normalizedKey.startsWith(normalizedPattern)) {
|
||||
return false;
|
||||
}
|
||||
if (normalizedKey.length() == normalizedPattern.length()) {
|
||||
return true;
|
||||
}
|
||||
char patternEnd = normalizedPattern.charAt(normalizedPattern.length() - 1);
|
||||
if (patternEnd == ':' || patternEnd == '/' || patternEnd == '_') {
|
||||
return true;
|
||||
}
|
||||
char boundary = normalizedKey.charAt(normalizedPattern.length());
|
||||
return boundary == '/' || boundary == '_';
|
||||
}
|
||||
|
||||
private static String normalizeKey(String key) {
|
||||
return key == null ? "" : key.trim().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSettings;
|
||||
import art.arcane.iris.engine.object.runtime.StudioMode;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.structure.vanilla.IrisImportedStructureControl;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant;
|
||||
@@ -292,8 +291,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("Dimension-wide Iris structure placements, independent of biome/region placements")
|
||||
@ArrayType(type = IrisStructurePlacement.class, min = 1)
|
||||
private KList<IrisStructurePlacement> structures = new KList<>();
|
||||
@Desc("Controls native vanilla, mod, and ingested datapack structure generation for this dimension. Every registered structure is enabled by default; 'disabled' is the sole generation deny list and autocompletes live structure keys.")
|
||||
private IrisImportedStructureControl importedStructures = new IrisImportedStructureControl();
|
||||
@Desc("Controls native vanilla, mod, and ingested datapack PLACED FEATURE generation (ores, trees, plants, springs, geodes) for this dimension. Disabled by default: leaving this out generates exactly the terrain Iris always has. Set 'enabled' true to run the vanilla decoration feature pass over Iris terrain. Carvers are never imported.")
|
||||
private IrisImportedFeatureControl importedFeatures = new IrisImportedFeatureControl();
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
|
||||
Reference in new issue
Block a user