Added exact imported feature denial

- importedFeatures gains disabledExact, which denies normalized complete placed feature keys without matching key families
- Mod ingest puts converted feature keys in disabledExact, so converting mod:ore_tin no longer suppresses mod:ore_tin_large
- Mod ingest keeps vanilla and unselected mod features generating when the source pack already ran importedFeatures, and otherwise disables vanilla plus every unselected mod namespace that has placed features
- Studio schema digest updated for the new field
This commit is contained in:
Brian Neumann-Fopiano committed 2026-10-14 21:05:27 -04:00
1 parent 191d9e88e6
commit a3f607e264
8 files changed
+159 -13

No files matched your search

@@ -0,0 +1,78 @@
/*
* 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.pack.ingest;
import art.arcane.iris.structure.nativegen.IrisImportedFeatureControl;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.junit.Test;
import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class ImportedFeatureWriterTest {
@Test
public void sourceThatAlreadyRanImportedFeaturesKeepsVanillaAndOtherModsGenerating() {
JsonObject dimension = dimension("{\"importedFeatures\": {\"enabled\": true, \"disabled\": [\"minecraft:ore_diamond\"]}}");
IrisImportedFeatureControl control = ImportedFeatureWriter.write(dimension, Set.of("examplemod:ore_tin"), Set.of("othermod"));
JsonObject imported = dimension.getAsJsonObject("importedFeatures");
assertEquals(List.of("minecraft:ore_diamond"), ModIngestFixture.strings(imported.get("disabled")));
assertEquals(List.of("examplemod:ore_tin"), ModIngestFixture.strings(imported.get("disabledExact")));
assertTrue(control.shouldGenerate("minecraft:ore_iron"));
assertTrue(control.shouldGenerate("othermod:daisies"));
assertFalse(control.shouldGenerate("minecraft:ore_diamond"));
assertFalse(control.shouldGenerate("examplemod:ore_tin"));
}
@Test
public void sourceWithoutImportedFeaturesOnlyRunsTheSelectedModsPassthrough() {
JsonObject dimension = dimension("{}");
IrisImportedFeatureControl control = ImportedFeatureWriter.write(dimension, Set.of("examplemod:ore_tin"), Set.of("othermod"));
JsonObject imported = dimension.getAsJsonObject("importedFeatures");
assertTrue(imported.get("enabled").getAsBoolean());
assertEquals(List.of("minecraft:", "othermod:"), ModIngestFixture.strings(imported.get("disabled")));
assertFalse(control.shouldGenerate("minecraft:ore_iron"));
assertFalse(control.shouldGenerate("othermod:daisies"));
assertFalse(control.shouldGenerate("examplemod:ore_tin"));
assertTrue(control.shouldGenerate("examplemod:ore_tin_large"));
assertTrue(control.shouldGenerate("examplemod:maple_trees"));
}
@Test
public void existingExactEntriesAreKept() {
JsonObject dimension = dimension("{\"importedFeatures\": {\"enabled\": false, \"disabledExact\": [\"examplemod:old\"]}}");
ImportedFeatureWriter.write(dimension, Set.of("examplemod:ore_tin"), Set.of());
assertEquals(List.of("examplemod:old", "examplemod:ore_tin"),
ModIngestFixture.strings(dimension.getAsJsonObject("importedFeatures").get("disabledExact")));
}
private static JsonObject dimension(String json) {
return JsonParser.parseString(json).getAsJsonObject();
}
}
@@ -155,20 +155,21 @@ public class ModIngesterFeatureTest {
assertEquals(ModIngestTier.PASSTHROUGH, weird.tier());
assertTrue(weird.reason(), weird.reason().contains("examplemod:custom_stone"));
assertTrue(imported.get("enabled").getAsBoolean());
assertEquals(List.of("minecraft:ore_diamond", "minecraft:", "examplemod:bluebell_patch", "examplemod:glow_flowers",
"examplemod:ore_ruby", "examplemod:ore_sapphire", "examplemod:ore_tin"),
assertEquals(List.of("minecraft:ore_diamond", "minecraft:", "othermod:"),
ModIngestFixture.strings(imported.get("disabled")));
assertEquals(List.of("examplemod:bluebell_patch", "examplemod:glow_flowers",
"examplemod:ore_ruby", "examplemod:ore_sapphire", "examplemod:ore_tin"),
ModIngestFixture.strings(imported.get("disabledExact")));
assertEquals(List.of("LAKES"), ModIngestFixture.strings(imported.get("disabledSteps")));
}
@Test
public void featuresWithoutHostsOrShadowedByDisabledPrefixesAreSkipped() {
public void featuresWithoutHostsAreSkippedAndConvertedKeysNeverShadowTheirFamily() {
ModIngestItem nether = ModIngestFixture.item(report, "examplemod:nether_ore");
ModIngestItem buried = ModIngestFixture.item(report, "examplemod:ore_tin_buried");
assertEquals(ModIngestTier.SKIPPED, nether.tier());
assertEquals(ModIngestTier.SKIPPED, buried.tier());
assertTrue(buried.reason(), buried.reason().contains("examplemod:ore_tin"));
assertEquals(ModIngestTier.PASSTHROUGH, buried.tier());
}
@Test
@@ -85,7 +85,7 @@ public class ModIngesterPackTest {
assertFalse(modified.contains("biomes/unused/orphan.json"));
assertEquals(report.items().size(), manifest.getAsJsonArray("items").size());
assertTrue(report.summaryLines().toString(),
report.summaryLines().contains("examplemod: 5 native, 6 adopted, 2 passthrough, 7 skipped"));
report.summaryLines().contains("examplemod: 5 native, 6 adopted, 3 passthrough, 6 skipped"));
}
@Test
@@ -83,7 +83,7 @@ public class SchemaBuilderIdentityTest {
@ClassRule
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
private static final String EXPECTED_SCHEMA_DIGEST = "2db2ba19e3466b7c686adca580943c1cc832bf0b44a0568e8db86a920116cfc0";
private static final String EXPECTED_SCHEMA_DIGEST = "5841ff4a1ad2813e4ad45f941fd40e5083a6b1b29a61c522df9efa12eb04f8c0";
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
IrisDimension.class,
@@ -86,6 +86,31 @@ public class IrisImportedFeatureControlTest {
control.resolve("minecraft:ore_diamond", IrisDecorationStep.UNDERGROUND_ORES));
}
@Test
public void disabledExactDeniesOnlyTheCompleteKey() {
IrisImportedFeatureControl control = new IrisImportedFeatureControl()
.setEnabled(true)
.setDisabledExact(keys(" ExampleMod:Ore_Tin "));
assertFalse(control.shouldGenerate("examplemod:ore_tin"));
assertTrue(control.shouldGenerate("examplemod:ore_tin_large"));
assertTrue(control.shouldGenerate("examplemod:ore_tin/deep"));
assertTrue(control.hasFeatureFilter());
assertEquals(NativeFeatureGenerationStatus.DISABLED_BY_PACK,
control.resolve("examplemod:ore_tin", IrisDecorationStep.UNDERGROUND_ORES));
assertEquals(NativeFeatureGenerationStatus.GENERATE_NATIVE,
control.resolve("examplemod:ore_tin_large", IrisDecorationStep.UNDERGROUND_ORES));
}
@Test
public void nullDisabledExactIsRejected() {
IrisImportedFeatureControl control = new IrisImportedFeatureControl()
.setEnabled(true)
.setDisabledExact(null);
assertThrows(NullPointerException.class, () -> control.shouldGenerate("examplemod:ore_tin"));
}
@Test
public void stepAllowListNarrowsGenerationToListedStepsOnly() {
IrisImportedFeatureControl control = new IrisImportedFeatureControl()