Jump to content

Changes to Registering Configured Features from 1.19.2 to 1.19.3+


itzer

Recommended Posts

I'm updating my mod from 1.19.2 to 1.20.X, going to 1.19.3 as an intermediate step so that I can ensure my data generators work correctly before updating the rest.

I have many lines to create configured features that look like this:

ALPINE_ROCK = new ConfiguredFeature<>(ModGeneration.OUTCROP.get(), new BlockStateConfiguration(Blocks.STONE.defaultBlockState()));
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(Main.MOD_ID, "alpine_rock"), ALPINE_ROCK);

Now I am on 1.19.3, BuiltinRegistries.CONFIGURED_FEATURE no longer exists. What is the proper way to register configured features in this version? Can this even still be done in code, or is this one of the "dynamic registries" affected by the registry overhaul? If it can no longer be done in code, what is necessary to do it using JSON?

Link to comment
Share on other sites

It is now done with datagen, you will need to add a `DatapackBuiltinEntriesProvider` to your data generator. The `RegistrySetBuilder` argument should look something like this:

private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
  .add(Registries.CONFIGURED_FEATURE, ModConfiguredFeatures::bootstrap)
  .add(Registries.PLACED_FEATURE, ModPlacedFeatures::bootstrap);

with your `ModConfiguredFeatures` class based on this rough template:

public static final ResourceKey<ConfiguredFeature<?, ?>> EXAMPLE = createKey("example");
// Add more keys here

public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
  HolderGetter<ConfiguredFeature<?, ?>> configured = context.lookup(Registries.CONFIGURED_FEATURE);
  HolderGetter<PlacedFeature> placed = context.lookup(Registries.PLACED_FEATURE);

  register(context, EXAMPLE, Feature.EXAMPLE_FEATURE, new ExampleConfiguration(args));
  // Register more features here
}

private static ResourceKey<ConfiguredFeature<?, ?>> createKey(String name) {
  return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation("modid", name));
}

private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC config) {
  context.register(key, new ConfiguredFeature<>(feature, config));
}

Hope this helps get you started :)

  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.