question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FAPI 0.68.0] `FabricDataGenHelper.createRegistryWrapper` changes bootstrap order.

See original GitHub issue

I am trying to use the DataGen to create all relevant files for my Biomes and Features by adding custom bootstrap methods to the buildRegistry entry point:

@Override
public void buildRegistry(RegistrySetBuilder registryBuilder) {
    registryBuilder.add(Registries.CONFIGURED_FEATURE, TestConfiguredFeatures::bootstrap);
    registryBuilder.add(Registries.PLACED_FEATURE, TestPlacedFeatures::bootstrap);
    registryBuilder.add(Registries.BIOME, TestBiomes::bootstrap);
    registryBuilder.add(Registries.NOISE_SETTINGS, NoiseDatagen::bootstrap);
}

The PLACED_FEATURE-Bootstrap relies on objects created in the CONFIGURED_FEATURE-bootstrap, and BIOMEs rely on the PLACED_FEATUREs.

If the bootstrap for those Biomes is called before the features are initialised, there may be odd behaviour.

Unfortunately, FabricDataGenHelper.createRegistryWrapper does not run toe bootstrap sequence in the same order as BuiltinRegistries.REGISTRY_BUILDER. This is due to the use of an unordered value-set of a HasMap that will populate the RegistryBuilder: https://github.com/FabricMC/fabric/blob/70063eb9397d2a82209d3c048881952ab3cae94d/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java#L180 https://github.com/FabricMC/fabric/blob/70063eb9397d2a82209d3c048881952ab3cae94d/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java#L192-L194

I think the new RegistryBuilder should retain the original order that is used in BuiltinRegistries.REGISTRY_BUILDER for all vanilla Registries.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
modmuss50commented, Nov 30, 2022

I believe this is working as intenteded using the RegistryEntry.Reference is the expected way of doing this. If you do have a use case where this doesnt work for please let me know.

0reactions
quiqueckcommented, Nov 30, 2022

Maybe I should also show how we use those Methods This is a simplified Version of what is actually going on in our Code:

public class MyConfiguredFeatures {
    public static RegistryEntry<ConfiguredFeature<?, ?>> FEATURE_A 
        = getReference(someID, createConfiguredFeatureA() );

    public static void bootstrap(Registerable <ConfiguredFeature<?, ?>> registerable) {
        FEATURE_A = register(
            registerable,
            FEATURE_A.unwrapKey().orElseThrow().location(),
            holder.value()
        );
    }
}

So when bootstrapping PlacedFeature, FEATURE_A would wither be an unbound Reference or a bound RegistryEntry. We can use both to create the PlacedFeatures.

Whenever the bootstrap process of ConfiguredFeatures runs, it will take the information that is already stored in the RegistryEntry (remeber our Version of the Reference holds both the key and the value) to register those with the Registry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating to v5 - Bootstrap
Track and review changes to the Bootstrap source files, documentation, and components to help you migrate from v4 to v5. On this page....
Read more >
Grid system - Bootstrap
Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, five default responsive...
Read more >
Migrating to v4 - Bootstrap
Bootstrap 4 is a major rewrite of the entire project. The most notable changes are summarized below, followed by more specific changes to...
Read more >
Columns · Bootstrap v5.0
Learn how to modify columns with a handful of options for alignment, ordering, and offsetting thanks to our flexbox grid system. Plus, see...
Read more >
Grid system · Bootstrap v5.0
Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, six default responsive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found