mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 08:14:45 +00:00
Make native structure imports opt-in and mark them experimental
A dimension without importedStructures no longer gets vanilla, mod or datapack structures in new chunks. Declaring the setting imports them, and disabled/disabledExact still narrow it down. Iris placements that place a vanilla structure themselves work without it. The feature is named "Structures (experimental)" and its description says so. The locate message for a blocked structure now says it is not imported by importedStructures or is disabled by a pack module.
This commit is contained in:
1 parent
5915a968ff
commit
e9b80420de
6 files changed
+55
-14
No files matched your search
+2
-2
@@ -117,7 +117,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
@Test
|
||||
public void unregisteredDiagnosticExplainsEveryRejectedRoute() {
|
||||
assertEquals(
|
||||
"Native structure minecraft:village is disabled by this dimension's importedStructures settings or a module of the pack.",
|
||||
"Native structure minecraft:village is not imported by this dimension's importedStructures settings or is disabled by a module of the pack.",
|
||||
CommandFind.describeStructureExclusion(
|
||||
CommandFind.StructureLookupRoute.POLICY_DISABLED, "minecraft:village",
|
||||
NativeStructureGenerationStatus.DISABLED_BY_PACK,
|
||||
@@ -213,7 +213,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
@Test
|
||||
public void findNativePolicyMessagesMatchModdedDiagnostics() {
|
||||
assertEquals(
|
||||
"Native structure minecraft:village_plains is disabled by this dimension's importedStructures settings or a module of the pack.",
|
||||
"Native structure minecraft:village_plains is not imported by this dimension's importedStructures settings or is disabled by a module of the pack.",
|
||||
NativeStructureGenerationPolicy.generationStatusMessage(
|
||||
"minecraft:village_plains", NativeStructureGenerationStatus.DISABLED_BY_PACK));
|
||||
assertEquals(
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public final class NativeStructureGenerationPolicy {
|
||||
return switch (Objects.requireNonNull(status, "Native structure status must not be null")) {
|
||||
case GENERATE_NATIVE -> "Native structure " + key + " generates natively.";
|
||||
case DISABLED_BY_PACK -> "Native structure " + key
|
||||
+ " is disabled by this dimension's importedStructures settings or a module of the pack.";
|
||||
+ " is not imported by this dimension's importedStructures settings or is disabled by a module of the pack.";
|
||||
case REPLACED_BY_IRIS -> "Native structure " + key
|
||||
+ " is replaced by an Iris placement in this pack and locates through that explicit replacement.";
|
||||
case INVALID_REGISTRY_KEY -> "Native structure registry key is invalid: " + key;
|
||||
|
||||
+27
-2
@@ -5,6 +5,7 @@ import art.arcane.iris.builtin.structure.StructureAdjustment;
|
||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.core.modules.ModuleSettings;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
@@ -61,7 +62,7 @@ public class NativeStructureGenerationPolicyTest {
|
||||
@Test
|
||||
public void generationStatusMessagesAreSharedAcrossPlatforms() {
|
||||
assertEquals(
|
||||
"Native structure minecraft:village_plains is disabled by this dimension's importedStructures settings or a module of the pack.",
|
||||
"Native structure minecraft:village_plains is not imported by this dimension's importedStructures settings or is disabled by a module of the pack.",
|
||||
NativeStructureGenerationPolicy.generationStatusMessage(
|
||||
"minecraft:village_plains", NativeStructureGenerationStatus.DISABLED_BY_PACK));
|
||||
assertEquals(
|
||||
@@ -93,6 +94,25 @@ public class NativeStructureGenerationPolicyTest {
|
||||
assertFalse(NativeStructureGenerationPolicy.generates(engine, "nova_structures:witch_villa"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aDimensionWithoutImportedStructuresGeneratesNoNativeStructure() throws IOException {
|
||||
Engine engine = engine(ModuleSettings.NONE, new KList<>(), List.of());
|
||||
|
||||
assertEquals(NativeStructureGenerationStatus.DISABLED_BY_PACK,
|
||||
NativeStructureGenerationPolicy.resolve(engine, "minecraft:village_plains"));
|
||||
assertFalse(NativeStructureGenerationPolicy.generates(engine, "minecraft:stronghold"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aPlacementOfANativeStructureWorksWithoutImportedStructures() throws IOException {
|
||||
Engine engine = engine(ModuleSettings.NONE, regionPlacement("minecraft:village_plains"), List.of());
|
||||
|
||||
assertEquals(NativeStructureGenerationStatus.REPLACED_BY_IRIS,
|
||||
NativeStructureGenerationPolicy.resolve(engine, "minecraft:village_plains"));
|
||||
assertEquals(NativeStructureGenerationStatus.DISABLED_BY_PACK,
|
||||
NativeStructureGenerationPolicy.resolve(engine, "minecraft:village_desert"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exactDisabledKeyDoesNotDisableSiblingVariant() throws IOException {
|
||||
StructureSettings settings = new StructureSettings(List.of(), List.of("minecraft:ruined_portal"), 0, true,
|
||||
@@ -236,6 +256,11 @@ public class NativeStructureGenerationPolicyTest {
|
||||
/** An engine whose pack serves Iris's built-in modules and {@code packModules}, with the given structure placements. */
|
||||
private Engine engine(StructureSettings settings, KList<StructurePlacement> regionPlacements,
|
||||
KList<StructurePlacement> dimensionPlacements, List<IrisModule> packModules) throws IOException {
|
||||
return engine(BuiltInPack.settings(settings, placementSettings(dimensionPlacements)), regionPlacements, packModules);
|
||||
}
|
||||
|
||||
private Engine engine(ModuleSettings dimensionSettings, KList<StructurePlacement> regionPlacements,
|
||||
List<IrisModule> packModules) throws IOException {
|
||||
IrisData data = mock(IrisData.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||
@@ -248,7 +273,7 @@ public class NativeStructureGenerationPolicyTest {
|
||||
packs.add(BuiltInPack.serveWithResources(data, folder, packModules));
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(settings, placementSettings(dimensionPlacements)));
|
||||
when(dimension.getModuleSettings()).thenReturn(dimensionSettings);
|
||||
when(dimension.getAllRegions(engine)).thenReturn(regions);
|
||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||
return engine;
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class ImportedStructuresTest {
|
||||
private static final Gson JSON = new Gson();
|
||||
|
||||
@Test
|
||||
public void defaultSettingsGenerateEveryStructureAndChangeNothing() {
|
||||
public void declaredDefaultSettingsImportEveryStructureAndChangeNothing() {
|
||||
ImportedStructures defaults = imported(new StructureSettings());
|
||||
|
||||
assertFalse(defaults.disables("minecraft:village_plains"));
|
||||
|
||||
@@ -36,8 +36,8 @@ import java.util.List;
|
||||
* generate are moved and fitted, how often structure sets start, and whether installed data packs may replace the
|
||||
* platform's own definitions. 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 module structure list' to dump every valid key. Only affects newly generated chunks and is separate from Iris structure placements.")
|
||||
@Feature(id = "iris:structure", name = "Structures", key = "importedStructures", targets = Level.DIMENSION)
|
||||
@Desc("Experimental. Opt-in import of native vanilla, mod, and ingested datapack structures into this dimension. Without this setting no native structure generates. With it, 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 module structure list' to dump every valid key. Only affects newly generated chunks. Iris structure placements, including ones that place a vanilla structure, work without it.")
|
||||
@Feature(id = "iris:structure", name = "Structures (experimental)", key = "importedStructures", targets = Level.DIMENSION)
|
||||
public final class StructureSettings implements IrisFeature {
|
||||
@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.")
|
||||
|
||||
+22
-6
@@ -32,24 +32,40 @@ 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 RegistryKeyFamily}).
|
||||
* the starts of the others are adjusted, and how the platform sets them up. Importing is opt-in: a dimension that
|
||||
* declares no settings disables every platform structure. Keys match ignoring case and surrounding space; a family
|
||||
* pattern also matches the keys it starts at a namespace, slash or underscore boundary ({@link RegistryKeyFamily}).
|
||||
*/
|
||||
public final class ImportedStructures {
|
||||
private static final ImportedStructures NOTHING_IMPORTED = new ImportedStructures(new StructureSettings(), false);
|
||||
|
||||
private final StructureSettings settings;
|
||||
private final boolean importsStructures;
|
||||
|
||||
public ImportedStructures(StructureSettings settings) {
|
||||
this(settings, true);
|
||||
}
|
||||
|
||||
private ImportedStructures(StructureSettings settings, boolean importsStructures) {
|
||||
this.settings = settings;
|
||||
this.importsStructures = importsStructures;
|
||||
}
|
||||
|
||||
/** The settings the dimension of {@code settings} declares, or the defaults when it declares none. */
|
||||
/** The settings the dimension of {@code settings} declares; nothing imported when it declares none. */
|
||||
public static ImportedStructures of(PackSettings settings) {
|
||||
return new ImportedStructures(settings.declared(StructureSettings.class).dimension().orElseGet(StructureSettings::new));
|
||||
return settings.declared(StructureSettings.class).dimension()
|
||||
.map(ImportedStructures::new)
|
||||
.orElse(NOTHING_IMPORTED);
|
||||
}
|
||||
|
||||
/** Whether the dimension disables the platform structure {@code key}, by family or by its exact key. */
|
||||
/**
|
||||
* Whether the dimension disables the platform structure {@code key}: every key when it imports no structures,
|
||||
* otherwise by family or by its exact key.
|
||||
*/
|
||||
public boolean disables(String key) {
|
||||
if (!importsStructures) {
|
||||
return true;
|
||||
}
|
||||
String normalizedKey = normalize(key);
|
||||
if (normalizedKey.isEmpty()) {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user