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

For anyone who is stuck on ore generation, this is what I've come up with. It works, of course everything is already filled in, the variable effecting the ore spawning is at the top. 

 

Feel free to use code, just make sure you use your blocks instead of mine.

package com.ianite.main.world;

import com.ianite.main.block.IaniteBlocks;

import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.common.BiomeManager;

public class IaniteOreGeneration {
    private static final CountRangeConfig IANITE = new CountRangeConfig(15, 10, 0, 25);
    private static final int IANITE_VEINSIZE = 5;
    private static final CountRangeConfig TRITANIUM = new CountRangeConfig(25, 10, 0, 128);
    private static final int TRITANIUM_VEINSIZE = 8;

    public static void setupOreGeneration() {
        for (BiomeManager.BiomeType btype : BiomeManager.BiomeType.values()) {
                for (BiomeManager.BiomeEntry biomeEntry : BiomeManager.getBiomes(btype)) {
                    if (IaniteOreConfig.enableIaniteOre) {
                        biomeEntry.biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, 
                        		IaniteBlocks.ianite_ore.getDefaultState(), IANITE_VEINSIZE), Placement.COUNT_RANGE, IANITE));
                    }
                }
        }
    }

    public static void setupNetherOreGeneration() {
        if (IaniteOreConfig.enableTritaniumOre) {
            Biomes.NETHER.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NETHERRACK, 
            		IaniteBlocks.tritanium_ore.getDefaultState(), TRITANIUM_VEINSIZE), Placement.COUNT_RANGE, TRITANIUM));
        }
    }
}

 

Edited by ianm1647
fixed

The wonder of open source code is that you can freely copy and modify it, though I will note that most licenses, like my LGPL-3.0 licensed code, do require attribution. The problem of open source code is that you can freely copy and implement other people's mistakes.

 

The above code is incorrect, and will only generate ore in vanilla biomes, as I finally figured out after bug reports from users. Iterate over the Forge biome register, NOT the vanilla BiomeManager.

 

For example, if you have an ore that should generate in all overworld-type biomes, code like this works:

 

public class OreGeneration
{
    // Vein/Chunk Count, MinHeight, MaxHeightBase, MaxHeight
    private static final CountRangeConfig copper_cfg = new CountRangeConfig(15, 40, 0, 128);
    private static final int copper_veinsize = 7;

	public static void setupOreGen()
    {
    	for (Biome biome: ForgeRegistries.BIOMES.getValues())
        {
            // we have no End or Nether ores, so skip those.
            if (  biome.getCategory() == Biome.Category.THEEND || biome.getCategory() == Biome.Category.NETHER)
            {
                continue;
            }
            
            // Overworld-type Ore generation
            if (SimpleOresConfig.enableCopperOre)
            {
                biome.addFeature(
                        GenerationStage.Decoration.UNDERGROUND_ORES,
                        Biome.createDecoratedFeature(Feature.ORE,
                                                     new OreFeatureConfig(
                                                             OreFeatureConfig.FillerBlockType.NATURAL_STONE,
                                                             ModBlocks.copper_ore.getDefaultState(),
                                                             copper_veinsize),
                                                     Placement.COUNT_RANGE,
                                                     copper_cfg));
        	} // end if copper_ore
		} // end for biomes
	} // end setupOreGen()
} // end class

 

This is, of course, a very stripped-down example. The full mod is here, for those that want to study the code: https://github.com/Sinhika/SimpleOres2

Edited by Sinhika

  • 5 weeks later...

You Sir and Sir, are a geniuses. I've been trying to get this to work for hours now, and it does indeed work now ❤️

Guys, have you an idea of remplace Natural_stone by other block ? like custom block ?

1 hour ago, fanor said:

Guys, have you an idea of remplace Natural_stone by other block ? like custom block ?

Currently, you need to create your own Feature implementation that does the same thing as OreFeature but can be configured to replace your desired block.

 

If/when this pull request is merged, all you'll need to do is create a new FillerBlockType that matches the block you want to replace.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.