mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Import native structures only when importedStructures sets enabled
Declaring importedStructures used to opt in by itself, so a block that only set datapackOverrides to false turned vanilla structures on. The new enabled option, false by default, is now the only switch; the other options shape the import once it is on.
This commit is contained in:
1 parent
f4821f7b0d
commit
547edabfdf
7 files changed
+58
-33
No files matched your search
@@ -36,9 +36,12 @@ 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("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.")
|
||||
@Desc("Experimental. Opt-in import of native vanilla, mod, and ingested datapack structures into this dimension. No native structure generates unless 'enabled' is true. Then 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 {
|
||||
@Desc("Experimental. Set to true to import native vanilla, mod, and datapack structures into this dimension. Off by default.")
|
||||
private boolean enabled = false;
|
||||
|
||||
@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();
|
||||
@@ -64,8 +67,10 @@ public final class StructureSettings implements IrisFeature {
|
||||
public StructureSettings() {
|
||||
}
|
||||
|
||||
public StructureSettings(List<String> disabled, List<String> disabledExact, int undergroundYShift, boolean datapackOverrides,
|
||||
List<StructureSetFrequency> frequencyOverrides, List<StructureAdjustment> adjustments) {
|
||||
public StructureSettings(boolean enabled, List<String> disabled, List<String> disabledExact, int undergroundYShift,
|
||||
boolean datapackOverrides, List<StructureSetFrequency> frequencyOverrides,
|
||||
List<StructureAdjustment> adjustments) {
|
||||
this.enabled = enabled;
|
||||
this.disabled = List.copyOf(disabled);
|
||||
this.disabledExact = List.copyOf(disabledExact);
|
||||
this.undergroundYShift = undergroundYShift;
|
||||
@@ -74,6 +79,11 @@ public final class StructureSettings implements IrisFeature {
|
||||
this.adjustments = List.copyOf(adjustments);
|
||||
}
|
||||
|
||||
/** Whether the dimension imports the platform's own structures at all. */
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/** Family patterns of the structures the dimension disables. */
|
||||
public List<String> disabled() {
|
||||
return listOrEmpty(disabled);
|
||||
|
||||
+8
-17
@@ -32,38 +32,29 @@ 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. 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}).
|
||||
* the starts of the others are adjusted, and how the platform sets them up. Importing is opt-in: unless the settings
|
||||
* are {@link StructureSettings#enabled}, every platform structure is disabled. 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; nothing imported when it declares none. */
|
||||
/** The settings the dimension of {@code settings} declares, or the defaults when it declares none. */
|
||||
public static ImportedStructures of(PackSettings settings) {
|
||||
return settings.declared(StructureSettings.class).dimension()
|
||||
.map(ImportedStructures::new)
|
||||
.orElse(NOTHING_IMPORTED);
|
||||
return new ImportedStructures(settings.declared(StructureSettings.class).dimension().orElseGet(StructureSettings::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the dimension disables the platform structure {@code key}: every key when it imports no structures,
|
||||
* Whether the dimension disables the platform structure {@code key}: every key unless it imports structures,
|
||||
* otherwise by family or by its exact key.
|
||||
*/
|
||||
public boolean disables(String key) {
|
||||
if (!importsStructures) {
|
||||
if (!settings.enabled()) {
|
||||
return true;
|
||||
}
|
||||
String normalizedKey = normalize(key);
|
||||
|
||||
Reference in new issue
Block a user