Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.2] How to add Custom Ore to World Generation


Recommended Posts

I've an Custom Ore that i want to add to World Gen to the whole Overworld, in previous versions of Minecraft I was able to use ForgeRegistries.BIOMES but that field doesn't exist on ForgeRegistries anymore o.O
I've done an googling but sadly i couldn't find an solution for this.

Link to post
Share on other sites
8 minutes ago, samjviana said:

So at this point it isn't possible? At least not by the usual way?

I would recommend trying and seeing if it works anyways just for the heck of it.

Forge is in beta right now for 1.16, so some issues are to be expected.

They're working quite hard to get things figured out, but it may take a little while.

  • Like 1

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to post
Share on other sites
21 hours ago, imacatlolol said:

I would recommend trying and seeing if it works anyways just for the heck of it.

Forge is in beta right now for 1.16, so some issues are to be expected.

They're working quite hard to get things figured out, but it may take a little while.

i'll look into it, thanks.
Any news i'll post here.

  • Like 1
Link to post
Share on other sites

So, after a lot of digging around the forge/minecraft classes i managed to figure it out how the Ore Gen is working.
The feature registering remains similar:

public static void initGen() {
    Registry.register(
        WorldGenRegistries.field_243653_e /* Feature Registering */,
        ModBlocks.ADAMANTINE_ORE.getId() /* Resource Location */,
        Feature.field_236289_V_ /* no_surface_ore */.withConfiguration(
            new OreFeatureConfig(
                OreFeatureConfig.FillerBlockType.field_241882_a /* base_stone_overworld */,
                ModBlocks.ADAMANTINE_ORE.get().getDefaultState() */,
                64 
            )
        ).withPlacement(Placement.field_242910_o /* depth */ .configure(
            new DepthAverageConfig(12, 12)
        )).func_242728_a() /* spreadHorizontally */ .func_242731_b(1) /* repeat */
    );
}

The most trick part was adding that feature in the already configured features of an biome:

public static void setupGen() {
    for (Map.Entry<RegistryKey<Biome>, Biome> biome : WorldGenRegistries.field_243657_i.func_239659_c_() /* Collection of Biome Entries */) {
        if (!biome.getValue().getCategory().equals(Biome.Category.NETHER) && !biome.getValue().getCategory().equals(Biome.Category.THEEND)) {
            addFeatureToBiome(
                biome.getValue(),
                GenerationStage.Decoration.UNDERGROUND_ORES,
                WorldGenRegistries.field_243653_e.getOrDefault(ModBlocks.ADAMANTINE_ORE.getId())
            );
        }
    }
}

public static void addFeatureToBiome(Biome biome, GenerationStage.Decoration decoration, ConfiguredFeature<?, ?> configuredFeature) {
    List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = new ArrayList<>(
        biome.func_242440_e().func_242498_c() /* List of Configured Features */
    );

    while (biomeFeatures.size() <= decoration.ordinal()) {
        biomeFeatures.add(Lists.newArrayList());
    }
    
    List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(biomeFeatures.get(decoration.ordinal()));
    features.add(() -> configuredFeature);
    biomeFeatures.set(decoration.ordinal(), features);

    /* Change field_242484_f that contains the Configured Features of the Biome*/
    ObfuscationReflectionHelper.setPrivateValue(BiomeGenerationSettings.class, biome.func_242440_e(), biomeFeatures, "field_242484_f");
}}

Actually it seems that there's no proper way of doing this by now, since i needed to use the "setPrivateValue".
It's not ideal ... but it works.
Thanks a lot for the guidance.

Edited by samjviana
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.