Kreezcraft

1.16.4 Oregen

After much searching i came across an example that explained exactly what had to be done to make oregen in 1.16.4 work.

The source: forums.minecraftforge.net/topic/94945-1164how-to-generate-ores/?do=findComment&comment=434130

How I used it to make Diamond Sand appear as ore again in DiamondGlass.

In the main constructor of the master class for my DiamondGlass mod I now have this. The line where I register ModFeatures is important.

    public DiamondGlass() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
        ConfigHelper.loadConfig(ConfigHelper.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("diamondglass.toml"));
        MinecraftForge.EVENT_BUS.register(this);

        //the line that matters immediately follows
        MinecraftForge.EVENT_BUS.register(new ModFeatures());

        InitBlocks.register();
    }

We only need one file too? Not a bunch all over the place. The file you guessed it is called ModFeatures.java. In that file will be this code, adapted to your mod ofcourse.

@Mod.EventBusSubscriber(modid = DiamondGlass.ModId, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModFeatures {

    public static ConfiguredFeature<?, ?> DIAMOND_SAND_CONFIG;

    @SubscribeEvent
    public static void setup(FMLCommonSetupEvent event) {
        DIAMOND_SAND_CONFIG = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, "diamond_sand",
                Feature.ORE.withConfiguration(
                        new OreFeatureConfig(
                                OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD,
                                InitBlocks.diamondSand.getDefaultState(), 9)
                ).range(64).square().func_242731_b(20)
        );
    }

    @SubscribeEvent
    public void onBiomeLoading(final BiomeLoadingEvent biome) {
        if(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND) return;

        biome.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES)
                .add(() -> ModFeatures.DIAMOND_SAND_CONFIG);
    }
}

That’s it. You should have no problems converting this to your needs if you do either reach out to me on my Discord or to the place where I got referenced at the top of this article.