Ordered converted ore hosts

- The worldgen catalog (format 2) records the members of every block tag referenced by a captured placed feature, so ore targets using mod block tags convert instead of passing through
- Ore conversion supports noise_based_count and noise_threshold_count placement counts
- Converted ores that produce another converted ore's host block are written ahead of it, so an ore whose host comes from a sibling ore finds that host during the deposit stage
This commit is contained in:
Brian Neumann-Fopiano committed 2026-10-14 22:37:28 -04:00
1 parent d5796b275e
commit 965e19801d
20 files changed
+445 -45

No files matched your search

@@ -37,12 +37,17 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot.
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot.WorldgenSpawn;
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot.WorldgenStructure;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
public final class WorldgenCatalogAssembler {
private static final String MINECRAFT = "minecraft";
@@ -58,16 +63,57 @@ public final class WorldgenCatalogAssembler {
List<CatalogStructure> structures = structures(snapshot.structures());
List<CatalogDimensionType> dimensionTypes = dimensionTypes(snapshot.dimensionTypes());
List<CatalogLevelStem> levelStems = levelStems(snapshot.levelStems());
Map<String, List<String>> blockTags = referencedBlockTags(placedFeatures, snapshot.blockTags());
Map<String, List<String>> registryKeys = new LinkedHashMap<>();
registryKeys.put("biome", biomes.stream().map(CatalogBiome::key).toList());
registryKeys.put("placed_feature", placedFeatures.stream().map(CatalogPlacedFeature::key).toList());
registryKeys.put("structure", structures.stream().map(CatalogStructure::key).toList());
registryKeys.put("dimension_type", dimensionTypes.stream().map(CatalogDimensionType::key).toList());
registryKeys.put("level_stem", levelStems.stream().map(CatalogLevelStem::key).toList());
registryKeys.put("block_tag", List.copyOf(blockTags.keySet()));
List<CatalogNamespace> namespaces = namespaces(registryKeys, context);
return new WorldgenCatalog(WorldgenCatalog.FORMAT, context.minecraftVersion(), context.platform(),
context.capturedAtEpochMillis(), WorldgenCatalogFingerprint.of(namespaces, registryKeys), namespaces,
biomes, placedFeatures, structures, dimensionTypes, levelStems);
biomes, placedFeatures, structures, dimensionTypes, levelStems, blockTags);
}
private static Map<String, List<String>> referencedBlockTags(List<CatalogPlacedFeature> features,
Map<String, List<String>> available) {
Set<String> referenced = new TreeSet<>();
for (CatalogPlacedFeature feature : features) {
collectTagMatches(feature.config(), referenced);
}
Map<String, List<String>> tags = new TreeMap<>();
for (String tag : referenced) {
List<String> members = available.get(tag);
if (members != null) {
tags.put(tag, members);
}
}
return tags;
}
private static void collectTagMatches(JsonElement element, Set<String> tags) {
if (element == null || element.isJsonNull() || element.isJsonPrimitive()) {
return;
}
if (element.isJsonArray()) {
for (JsonElement entry : element.getAsJsonArray()) {
collectTagMatches(entry, tags);
}
return;
}
JsonObject object = element.getAsJsonObject();
JsonElement predicate = object.get("predicate_type");
JsonElement tag = object.get("tag");
if (predicate != null && predicate.isJsonPrimitive() && predicate.getAsString().endsWith("tag_match")
&& tag != null && tag.isJsonPrimitive()) {
String key = tag.getAsString();
tags.add(key.contains(":") ? key : MINECRAFT + ":" + key);
}
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
collectTagMatches(entry.getValue(), tags);
}
}
private static List<CatalogNamespace> namespaces(Map<String, List<String>> registryKeys, CatalogCaptureContext context) {
@@ -23,6 +23,7 @@ import art.arcane.iris.pack.ingest.catalog.CatalogLevelStem;
import art.arcane.iris.pack.ingest.catalog.CatalogNamespace;
import art.arcane.iris.pack.ingest.catalog.CatalogPlacedFeature;
import art.arcane.iris.pack.ingest.catalog.WorldgenCatalog;
import art.arcane.iris.pack.ingest.catalog.WorldgenCatalogIndex;
import art.arcane.iris.pack.ingest.catalog.WorldgenCatalogFingerprint;
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeModMetadata;
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot;
@@ -34,6 +35,7 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot.
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot.WorldgenSpawn;
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldgenSnapshot.WorldgenStructure;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import org.junit.Test;
@@ -104,15 +106,27 @@ public class WorldgenCatalogAssemblerTest {
"placed_feature", List.of("examplemod:ore_glimmer"),
"structure", List.of("examplemod:tower"),
"dimension_type", List.of("minecraft:overworld"),
"level_stem", List.of("minecraft:overworld")));
"level_stem", List.of("minecraft:overworld"),
"block_tag", List.of("examplemod:glimmer_hosts")));
assertEquals(expected, catalog.contentFingerprint());
}
@Test
public void onlyBlockTagsReferencedByPlacedFeaturesAreKept() {
WorldgenCatalog catalog = WorldgenCatalogAssembler.assemble(snapshot(), CONTEXT);
assertEquals(Map.of("examplemod:glimmer_hosts", List.of("minecraft:dirt", "minecraft:grass_block")), catalog.blockTags());
assertEquals(List.of("minecraft:dirt", "minecraft:grass_block"),
WorldgenCatalogIndex.of(catalog).blockTag("examplemod:glimmer_hosts").orElseThrow());
}
static NativeWorldgenSnapshot snapshot() {
JsonObject definition = new JsonObject();
definition.add("downfall", new JsonPrimitive(0.4F));
JsonObject config = new JsonObject();
config.add("type", new JsonPrimitive("minecraft:ore"));
JsonObject config = JsonParser.parseString("""
{"type": "minecraft:ore", "targets": [{"state": "examplemod:glimmer_ore",
"target": {"predicate_type": "minecraft:tag_match", "tag": "examplemod:glimmer_hosts"}}]}
""").getAsJsonObject();
return new NativeWorldgenSnapshot(
List.of(new WorldgenBiome("examplemod:glade", 0.7F, 0.4F, true, List.of("minecraft:is_overworld"),
List.of(List.of(), List.of("examplemod:ore_glimmer")),
@@ -124,6 +138,8 @@ public class WorldgenCatalogAssemblerTest {
List.of(new WorldgenDimensionType("minecraft:overworld", -64, 384, 384, null)),
List.of(new WorldgenLevelStem("minecraft:overworld", "minecraft:overworld", "minecraft:noise",
"minecraft:multi_noise", null)),
Map.of("examplemod:glimmer_hosts", List.of("minecraft:dirt", "minecraft:grass_block"),
"minecraft:unreferenced", List.of("minecraft:stone")),
new EncodeFailures(0, List.of(), null));
}
}
@@ -30,6 +30,7 @@ import art.arcane.iris.pack.ingest.catalog.WorldgenCatalog;
import org.junit.Test;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
@@ -74,7 +75,7 @@ public class WorldgenCatalogSummaryTest {
@Test
public void keyNamespacesWithoutModMetadataStillSummarize() {
WorldgenCatalog catalog = new WorldgenCatalog(WorldgenCatalog.FORMAT, "26.3", "fabric", 1L, "x",
List.of(), List.of(biome("datapack:dunes")), List.of(), List.of(), List.of(), List.of());
List.of(), List.of(biome("datapack:dunes")), List.of(), List.of(), List.of(), List.of(), Map.of());
NamespaceSummary summary = WorldgenCatalogSummary.namespace(catalog, "datapack").orElseThrow();
@@ -104,7 +105,7 @@ public class WorldgenCatalogSummaryTest {
List.of(new CatalogStructure("examplemod:tower", "minecraft:jigsaw", "surface_structures", "none", "",
List.of(), List.of())),
List.of(new CatalogDimensionType("examplemod:sky", 0, 256, 256, null)),
List.of(new CatalogLevelStem("examplemod:sky", "examplemod:sky", "minecraft:noise", "minecraft:fixed", null)));
List.of(new CatalogLevelStem("examplemod:sky", "examplemod:sky", "minecraft:noise", "minecraft:fixed", null)), Map.of());
}
private static CatalogBiome biome(String key) {