Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi, I was wondering if anyone would be willing to give me some code that generates ores, or could just point me in the right direction, please? I've tried looking, I really have, but I can't find much. Thanks!

Edited by Linky132

so as you see in this code i am making it spawn randomly across the map. just to tell u this is for 1.15 the code in 1.16 is something similar to this this code is just to demonstrate how you would write it. also make a separate java class in ModFolder.world.gen.OreGeneration.java and type in code something like this but dont copy, it wont work in 1.16 and replace RegistryHandler.NETHERITE_ORE with the path to the ore you want to generate thats in your registry handler also then in your main.java class where it has your mod id and stuff in the private void setup(final FMLCommonSetupEvent event) u will write OreGeneration.generate(); in the brackets

 

private static void setupOreGeneration() {
    for (Biome biome : ForgeRegistries.BIOMES) {
        biome.addFeature(Decoration.UNDERGROUND_ORES,
                Feature.ORE
                        .withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
                                RegistryHandler.NETHERITE_ORE.get().getDefaultState(), 10))
                        .withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(20, 5, 0, 128))));
    }
}


public static void generate() {
    setupOreGeneration();

}

Edited by Somonestolemyusername

3 hours ago, Somonestolemyusername said:

so as you see in this code i am making it spawn randomly across the map. just to tell u this is for 1.15 the code in 1.16 is something similar to this this code is just to demonstrate how you would write it. also make a separate java class in ModFolder.world.gen.OreGeneration.java and type in code something like this but dont copy, it wont work in 1.16 and replace RegistryHandler.NETHERITE_ORE with the path to the ore you want to generate thats in your registry handler also then in your main.java class where it has your mod id and stuff in the private void setup(final FMLCommonSetupEvent event) u will write OreGeneration.generate(); in the brackets

This is not applicable for 1.16.2+ as the system was changed.

 

First, you will need to register your Configured Feature within the associated WorldGenRegistries. I would suggest looking at how the Features class does the registering and borrow the method. Note that this should be deferred until FMLCommonSetupEvent. For reference, the register event is not thread-safe, so it should be wrapped using the synchronous work queue provided in the event (e.g. enqueueWork). From there, you can attach the feature to the biome(s) of your choice using BiomeLoadingEvent. You can grab the generation settings builder there and add a feature during a specific point in the generation process, in your case most likely UNDERGROUND_ORES.

  • 2 weeks 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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.