Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.3] Working ORE GENERATION class
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
ianm1647

[1.14.3] Working ORE GENERATION class

By ianm1647, July 14 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

ianm1647    1

ianm1647

ianm1647    1

  • Tree Puncher
  • ianm1647
  • Members
  • 1
  • 3 posts
Posted July 14 (edited)

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 July 14 by ianm1647
fixed
  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

Sinhika    7

Sinhika

Sinhika    7

  • Stone Miner
  • Sinhika
  • Members
  • 7
  • 60 posts
Posted July 20 (edited)

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 July 20 by Sinhika
  • Quote

Share this post


Link to post
Share on other sites

LeLoomi    0

LeLoomi

LeLoomi    0

  • Tree Puncher
  • LeLoomi
  • Members
  • 0
  • 3 posts
Posted August 19

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 ❤️

  • Quote

Share this post


Link to post
Share on other sites

fanor    1

fanor

fanor    1

  • Tree Puncher
  • fanor
  • Members
  • 1
  • 17 posts
Posted August 24

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

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1620

Choonster

Choonster    1620

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1620
  • 5047 posts
Posted August 24
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.

  • Quote

Share this post


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.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • yegor
      [1.12.2] Transparent armor not rendering properly.

      By yegor · Posted 35 minutes ago

      In my mod I have transparent armor which I created with an "ArmorSlime" class, which extends ItemArmor. The item texture for my armor is slightly transparent and it renders correctly, even in item frames.   The armor model uses a slightly transparent texture, which works on the player model, but when I place the armor on an armor stand, it is rendered fully opaque.   Is this a mod issue, or an issue with minecraft itself? Is there a solution?  
    • yegor
      moving topic to just modding support

      By yegor · Posted 40 minutes ago

      Moved
    • J0WAY
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By J0WAY · Posted 46 minutes ago

      Okay, But my main problem is why won't my sword spawn on my mob because i did just change it to the vanilla code and it still doesn't work.  
    • thedarkcolour
      [1.14] Patching method with coremod in TreeFeature causes IncompatibleClassChangeError

      By thedarkcolour · Posted 2 hours ago

      https://github.com/thedarkcolour/Future-MC/tree/1.14
    • Draco18s
      [1.14] layout of a modpack

      By Draco18s · Posted 3 hours ago

      I'm pretty sure I've left some comments on his videos about the mistakes he's perpetuating, but its not like anyone reads those.
  • Topics

    • yegor
      0
      [1.12.2] Transparent armor not rendering properly.

      By yegor
      Started 34 minutes ago

    • yegor
      0
      moving topic to just modding support

      By yegor
      Started 40 minutes ago

    • J0WAY
      2
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By J0WAY
      Started 5 hours ago

    • thedarkcolour
      15
      [1.14] Patching method with coremod in TreeFeature causes IncompatibleClassChangeError

      By thedarkcolour
      Started 20 hours ago

    • JetCobblestone
      4
      [1.14] layout of a modpack

      By JetCobblestone
      Started 8 hours ago

  • Who's Online (See full list)

    • plugsmustard
    • J0WAY
    • imacatlolol
    • Itz_Yuseix
    • thedarkcolour
    • StarCraftNetwork
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.3] Working ORE GENERATION class
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community