diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java index f64f1ea837..667f114e18 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java @@ -82,6 +82,8 @@ public static final class Entries { Entries(RegistryWrapper.WrapperLookup registries, String modId) { this.registries = registries; this.queuedEntries = DynamicRegistries.getDynamicRegistries().stream() + // Some modded dynamic registries might not be in the wrapper lookup, filter them out + .filter(e -> registries.getOptionalWrapper(e.key()).isPresent()) .collect(Collectors.toMap( e -> e.key().getValue(), e -> RegistryEntries.create(registries, e) diff --git a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java index f48369883b..b367cc0578 100644 --- a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java +++ b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java @@ -56,6 +56,9 @@ public class DataGeneratorTestContent implements ModInitializer { TEST_DATAGEN_DYNAMIC_REGISTRY_KEY, new Identifier(MOD_ID, "tiny_potato") ); + // Empty registry + public static final RegistryKey> TEST_DATAGEN_DYNAMIC_EMPTY_REGISTRY_KEY = + RegistryKey.ofRegistry(new Identifier("fabric", "test_datagen_dynamic_empty")); @Override public void onInitialize() { @@ -73,6 +76,7 @@ public void onInitialize() { .build()); DynamicRegistries.register(TEST_DATAGEN_DYNAMIC_REGISTRY_KEY, TestDatagenObject.CODEC); + DynamicRegistries.register(TEST_DATAGEN_DYNAMIC_EMPTY_REGISTRY_KEY, TestDatagenObject.CODEC); } private static Block createBlock(String name, boolean hasItem, AbstractBlock.Settings settings) { diff --git a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java index 43b4361ec1..0b09e9c89b 100644 --- a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java +++ b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java @@ -132,6 +132,7 @@ public void buildRegistry(RegistryBuilder registryBuilder) { TEST_DATAGEN_DYNAMIC_REGISTRY_KEY, this::bootstrapTestDatagenRegistry ); + // do NOT add TEST_DATAGEN_DYNAMIC_EMPTY_REGISTRY_KEY, should still work without it } private void bootstrapTestDatagenRegistry(Registerable registerable) {