Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom registries in DataGeneratorEntrypoint#buildRegistry not functioning #4149

Open
marlester-dev opened this issue Oct 8, 2024 · 2 comments

Comments

@marlester-dev
Copy link

marlester-dev commented Oct 8, 2024

using registry builder, custom registries are not working:

    @Override
    public void buildRegistry(RegistrySetBuilder registryBuilder) {
        registryBuilder
                .add(Registries.CONFIGURED_FEATURE, TFConfiguredFeatures::bootstrap)
                .add(Registries.PLACED_FEATURE, TFPlacedFeatures::bootstrap)
                .add(Registries.STRUCTURE, TFStructures::bootstrap)
                .add(Registries.STRUCTURE_SET, TFStructureSets::bootstrap)
                .add(Registries.CONFIGURED_CARVER, TFCaveCarvers::bootstrap)
                .add(Registries.NOISE_SETTINGS, TFDimensionSettings::bootstrapNoise)
                .add(BiomeLayerStack.BIOME_STACK_KEY, BiomeLayerStack::bootstrap)
                .add(Registries.DIMENSION_TYPE, TFDimensionSettings::bootstrapType)
                .add(Registries.LEVEL_STEM, TFDimensionSettings::bootstrapStem)
                .add(Registries.BIOME, TFBiomes::bootstrap)
                .add(WoodPalettes.WOOD_PALETTE_TYPE_KEY, WoodPalettes::bootstrap)
                .add(Registries.DAMAGE_TYPE, TFDamageTypes::bootstrap)
                .add(Registries.TRIM_MATERIAL, TFTrimMaterials::bootstrap)
                .add(Restrictions.RESTRICTION_KEY, Restrictions::bootstrap)
                .add(MagicPaintingVariants.REGISTRY_KEY, MagicPaintingVariants::bootstrap);
    }

Error:

java.lang.IllegalArgumentException: Multiple entries with same key: twilight:biome_layer_stack=net.minecraft.core.RegistrySetBuilder$UniversalLookup@40f911e4 and twilight:biome_layer_stack=net.minecraft.core.RegistrySetBuilder$1@3f3ea394

I'm creating registry keys with ResourceKey.createRegistryKey(ResourceLocation)

@marlester-dev
Copy link
Author

marlester-dev commented Oct 8, 2024

Seems like the error is coming from immutable builder map here in RegistrySetBuilder$BuildState:

        public static BuildState create(RegistryAccess registryAccess, Stream<ResourceKey<? extends Registry<?>>> registries) {
            CompositeOwner compositeOwner = new CompositeOwner();
            List<RuntimeException> list = new ArrayList();
            UniversalLookup universalLookup = new UniversalLookup(compositeOwner);
            ImmutableMap.Builder<ResourceLocation, HolderGetter<?>>/*the map ->*/ builder = ImmutableMap.builder();
            registryAccess.registries().forEach((registryEntry) -> {
                builder.put(registryEntry.key().location(), RegistrySetBuilder.wrapContextLookup(registryEntry.value().asLookup()));
            });
            registries.forEach((registryKey) -> {
                builder.put(registryKey.location(), universalLookup);
            });
            return new BuildState(compositeOwner, universalLookup, builder.build(), new HashMap(), list);
        }

@marlester-dev
Copy link
Author

tested on mc 1.20.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant