Jump to content

Recommended Posts

Posted (edited)

in [1.14.4][SOLVED] remove vanilla ore generation in I figured out how to remove ALL ores with:

 

        for (Biome biome : ForgeRegistries.BIOMES) 
	{
            biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).clear();
        }

 

The problem with that is that it includes things I don't want to remove. I'm trying to create a find and replace method to just find all the iron_ore features in all the biomes but I don't know how to identify what each feature actually is. I get things like: "net.minecraft.world.gen.feature.ConfiguredFeature@41aa9e27" when I try to get the feature information using: "biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).get(0).toString()". how might I identify a given feature?

 

[SOLUTION](sort of...)

 

Create this class:

package com.YourName.YourMod.world;

import com.google.common.collect.Lists;
import net.minecraft.block.Blocks;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.GenerationStage.Decoration;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.placement.*;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


public class OreGeneration {

    public static void setupOreGeneration() {

        for (Biome biome: ForgeRegistries.BIOMES) {

            if (biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).size() == 15) {

                biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).clear();
                
                addStoneVariants(biome);
                addOres(biome);
                addSedimentDisks(biome);
                addExtraEmeraldOre(biome);
                addInfestedStone(biome);


            } else if (biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).size() == 14) {

                biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).clear();

                addStoneVariants(biome);
                addOres(biome);
                addSedimentDisks(biome);

            } else if (biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).size() == 12) {

                biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).clear();

                addStoneVariants(biome);
                addOres(biome);
                addSwampClayDisks(biome);
            }
        }
    }

    public static void addStoneVariants(Biome biomeIn) {
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.DIRT.getDefaultState(), 33), Placement.COUNT_RANGE, new CountRangeConfig(10, 0, 0, 256)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.GRAVEL.getDefaultState(), 33), Placement.COUNT_RANGE, new CountRangeConfig(8, 0, 0, 256)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.GRANITE.getDefaultState(), 33), Placement.COUNT_RANGE, new CountRangeConfig(10, 0, 0, 80)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.DIORITE.getDefaultState(), 33), Placement.COUNT_RANGE, new CountRangeConfig(10, 0, 0, 80)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.ANDESITE.getDefaultState(), 33), Placement.COUNT_RANGE, new CountRangeConfig(10, 0, 0, 80)));
    }

    public static void addOres(Biome biomeIn) {
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.COAL_ORE.getDefaultState(), 17), Placement.COUNT_RANGE, new CountRangeConfig(20, 0, 0, 128)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.IRON_ORE.getDefaultState(), 9), Placement.COUNT_RANGE, new CountRangeConfig(20, 0, 0, 64)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.GOLD_ORE.getDefaultState(), 9), Placement.COUNT_RANGE, new CountRangeConfig(2, 0, 0, 32)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.REDSTONE_ORE.getDefaultState(), 8), Placement.COUNT_RANGE, new CountRangeConfig(8, 0, 0, 16)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.DIAMOND_ORE.getDefaultState(), 8), Placement.COUNT_RANGE, new CountRangeConfig(1, 0, 0, 16)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.LAPIS_ORE.getDefaultState(), 7), Placement.COUNT_DEPTH_AVERAGE, new DepthAverageConfig(1, 16, 16)));
    }

    public static void addExtraEmeraldOre(Biome biomeIn) {
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.EMERALD_ORE, new ReplaceBlockConfig(Blocks.STONE.getDefaultState(), Blocks.EMERALD_ORE.getDefaultState()), Placement.EMERALD_ORE, IPlacementConfig.NO_PLACEMENT_CONFIG));
    }

    public static void addInfestedStone(Biome biomeIn) {
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, Blocks.INFESTED_STONE.getDefaultState(), 9), Placement.COUNT_RANGE, new CountRangeConfig(7, 0, 0, 64)));
    }

    public static void addSedimentDisks(Biome biomeIn) {
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.DISK, new SphereReplaceConfig(Blocks.SAND.getDefaultState(), 7, 2, Lists.newArrayList(Blocks.DIRT.getDefaultState(), Blocks.GRASS_BLOCK.getDefaultState())), Placement.COUNT_TOP_SOLID, new FrequencyConfig(3)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.DISK, new SphereReplaceConfig(Blocks.CLAY.getDefaultState(), 4, 1, Lists.newArrayList(Blocks.DIRT.getDefaultState(), Blocks.CLAY.getDefaultState())), Placement.COUNT_TOP_SOLID, new FrequencyConfig(1)));
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.DISK, new SphereReplaceConfig(Blocks.GRAVEL.getDefaultState(), 6, 2, Lists.newArrayList(Blocks.DIRT.getDefaultState(), Blocks.GRASS_BLOCK.getDefaultState())), Placement.COUNT_TOP_SOLID, new FrequencyConfig(1)));
    }

    public static void addSwampClayDisks(Biome biomeIn) {
        biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.DISK, new SphereReplaceConfig(Blocks.CLAY.getDefaultState(), 4, 1, Lists.newArrayList(Blocks.DIRT.getDefaultState(), Blocks.CLAY.getDefaultState())), Placement.COUNT_TOP_SOLID, new FrequencyConfig(1)));
    }
}

 

look for the ore you want to replace in one of the "add*" methods and put yours in its place

 

add the class to your main mod class setup event:

    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
        setup.init();
        LOGGER.info("HELLO FROM PREINIT");
        LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
	OreGeneration.setupOreGeneration();
    }

 

Edited by andGarrett
Posted (edited)

toString() clearly doesn't work.

 

I think there is no way to get any id from biome features. (might be wrong, but I looked for it)

 

The way I did it was to remove it all, looked for the vanilla code and replicated what I wanted to keep.

Search on your IDE for the DefaultBiomeFeatures class

 

Note that stone variants are in the same category as UNDERGROUND_ORES so you need to add them as well. 

 

This is perhaps not the best way to do it tho since comparability goes a bit out the window

Edited by Afroman
Posted
10 hours ago, andGarrett said:

how might I identify a given feature?

Use the config they have to obtain the information like so for IRON_ORE.
 

    		for (ConfiguredFeature<?> f : biome.getFeatures(Decoration.UNDERGROUND_ORES)) {
    			if (f.config instanceof OreFeatureConfig) {
    				if (((OreFeatureConfig)f.config).state.getBlock() == Blocks.IRON_ORE) {
    					
    				}
    			}
    		}

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
13 hours ago, Afroman said:

The way I did it was to remove it all, looked for the vanilla code and replicated what I wanted to keep.

Search on your IDE for the DefaultBiomeFeatures class

Yeah, that's what I was planning on doing if I couldn't do a find and replace method.

 

11 hours ago, Animefan8888 said:

Use the config they have to obtain the information like so for IRON_ORE.
 


    		for (ConfiguredFeature<?> f : biome.getFeatures(Decoration.UNDERGROUND_ORES)) {
    			if (f.config instanceof OreFeatureConfig) {
    				if (((OreFeatureConfig)f.config).state.getBlock() == Blocks.IRON_ORE) {
    					
    				}
    			}
    		}

 

I fiddled around with this for an hour or two, but I couldn't figure out how to make it work. the final if statement condition is never true.

Posted (edited)
21 hours ago, andGarrett said:

I fiddled around with this for an hour or two, but I couldn't figure out how to make it work. the final if statement condition is never true.

Neither is the first. It seems that "f.config" is always an instance of DecoratedFeatureConfig.

I actually remember reaching this and getting stuck. But I did some more digging and this works. This vanilla part is actually a mess. I am Happy to find an alternative.

 

	    List<ConfiguredFeature> features = new ArrayList<ConfiguredFeature>();

            for (ConfiguredFeature<?> f : biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES)) {
                if (((DecoratedFeatureConfig)f.config).feature.feature instanceof OreFeature) {
                    if (((OreFeatureConfig)((DecoratedFeatureConfig)f.config).feature.config).state.getBlock() == Blocks.IRON_ORE) {
                        features.add(f);
                    }
                }
            }

            biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).removeAll(features);

 

Edited by Afroman

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

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

Announcements



×
×
  • Create New...

Important Information

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