Jump to content

[1.7.2] Custom Biome Not Spawning


JimiIT92

Recommended Posts

Hi guys :D I'm making a new biome today but since there isn't anymore the method GameRegistry.registerBiome i can't figure it out how to add a new biome and make it spawn. Actually i've only coded it and registered in the way i see online but it doesn't spawn :/

Here is the code of my custom biome:

package mod.mineworld.world.mod_plants;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenLiquids;
import net.minecraft.world.gen.feature.WorldGenerator;

public class BiomeGenAppleForest extends BiomeGenBase
{

private WorldGenerator WorldGenTrees;
private WorldGenerator WorldGenLakes;
int color;
public BiomeGenAppleForest(int par1)
{
super(par1);
this.theBiomeDecorator.treesPerChunk = 50;
this.topBlock = Blocks.grass;
this.fillerBlock = Blocks.dirt;
this.WorldGenTrees = new WorldGenAppleTrees(false);
this.WorldGenLakes = new WorldGenLiquids(Blocks.water);
}

/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
{
return (WorldGenerator)(par1Random.nextInt(5) == 0 ? this.WorldGenLakes : (par1Random.nextInt(10) == 0 ? this.WorldGenTrees : this.WorldGenTrees));
}

public BiomeGenBase setColor(int par1)
{
    this.color = 16711680;
    return this;
}

}

 

And here is how i registered it in the main sub-mod file:

public static BiomeGenBase AppleForest

AppleForest = new BiomeGenAppleForest(154).setColor(353825).setBiomeName("Apple Forest");

BiomeDictionary.registerBiomeType(AppleForest, Type.FOREST);
BiomeManager.addSpawnBiome(AppleForest);

 

I think it should be registered this way but i don't know why it doesn't spawn :/

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

Ok this works but i have to create a new World Type (so when creating a new world specifing this new type)... but how to make  it works WITHOUT making this new World Type? How can i add my custom biome to the default world type GenLayer?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

I have a good idea on how to add new biomes without a new world type, but I haven't figured everything out yet.

 

To add your biome to world generation without making a new world type, use the InitBiomeGens event. First, if you haven't made an event handler class for you mod, do so (just a plain class file). Register it in you main class using

MinecraftForge.TERRAIN_GEN_BUS.register(new MyEventHandler());

replacing MyEventHandler with whatever you decided to name your event handler. You must register the handler with the terrain gen bus.

 

Then, in your event handler class, use this anotated method:

@SubscribeEvent
public void registrerBiomes(InitBiomeGens event){
	GenLayer layer1 = event.newBiomeGens[0];
	GenLayer layer2 = event.newBiomeGens[1];

/* Your genlayer-altering code goes here! */

	GenLayer event.newBiomeGens[0] = layer1;
	GenLayer event.newBiomeGens[1] = layer2;
}

You can rename the method to whatever you want, but the annotation and argument need to stay the same. You don't necessarily need the layer1 and layer2, but they're just convenient so you don't have to keep referring to the array. To alter the GenLayer, create your own GenLayerMod class (named whatever you want) that extends GenLayer and has a constructor similar to this:

public GenLayerMod(long par1, GenLayer par2) {
	super(par1);
	this.parent = par2;
	// TODO Auto-generated constructor stub
}

You have it alter the world using  the

public int[] getInts(int par1, int par2, int par3, int par4){}

method.

 

To have your new gen layer class take control of world generation, use

layer1 = new GenLayerMod(40L,layer1);
layer2 = new GenLayerMod(40L,layer2);

in the event method.

Change the 40L to whatever default randomization seed you feel necessary.

 

The getInts method will take over and that's where you'll get to play with the world generation.

 

This is where I'm stuck. I've looked at vanilla genlayers, and they seem to control the biomes one square block at a time (x and z coords). I recommend using the GenLayerDeepOcean to start out with learning how to identify blocks, but Minecraft's vanilla code has it lucky. All vanilla biomes generate before the world is magnified, so each biome really only needs to generate in the area of a few blocks, then it's all expanded. What's left for us modders is an already magnified world with only the ability to control biomes 1 block at a time. I haven't come up with a good way to go about generating full-scale biomes yet. I really hope Forge eventually adds an easier way to generate biomes.

 

So, overall, adding a new world type is probably the easiest way to generate new biomes.

Link to comment
Share on other sites

so, now i tell you what i did yet, without new custom WorldType:

 

I took the InitBiomeGens event like Azaka7 described before.

He gets lost while looking all that GenLayers and so do i .. haha .. maybe later when i have time to study that .. but Azaka7, you seem to understand these layers much better than i do, so far ..:)

 

But i did this:

I just copied the public static initializeAllBiomeGenerators() and squeezed my biome in, so i don't have to mess around all these layers!

(take a look at my comments ////// and search for "Tutorial".. all other stuff is just copied):

 

 

package com.chrissionair.tutorial.event;

 

import net.minecraft.world.WorldType;

import net.minecraft.world.gen.layer.GenLayer;

import net.minecraft.world.gen.layer.GenLayerAddIsland;

import net.minecraft.world.gen.layer.GenLayerAddMushroomIsland;

import net.minecraft.world.gen.layer.GenLayerAddSnow;

import net.minecraft.world.gen.layer.GenLayerBiomeEdge;

import net.minecraft.world.gen.layer.GenLayerDeepOcean;

import net.minecraft.world.gen.layer.GenLayerEdge;

import net.minecraft.world.gen.layer.GenLayerFuzzyZoom;

import net.minecraft.world.gen.layer.GenLayerHills;

import net.minecraft.world.gen.layer.GenLayerIsland;

import net.minecraft.world.gen.layer.GenLayerRareBiome;

import net.minecraft.world.gen.layer.GenLayerRemoveTooMuchOcean;

import net.minecraft.world.gen.layer.GenLayerRiver;

import net.minecraft.world.gen.layer.GenLayerRiverInit;

import net.minecraft.world.gen.layer.GenLayerRiverMix;

import net.minecraft.world.gen.layer.GenLayerShore;

import net.minecraft.world.gen.layer.GenLayerSmooth;

import net.minecraft.world.gen.layer.GenLayerVoronoiZoom;

import net.minecraft.world.gen.layer.GenLayerZoom;

import net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens;

 

import com.chrissionair.tutorial.world.GenLayerBiome_Tutorial;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

 

public class Tutorial_Biome_Event {

 

// Forge WorldTypeEvent used in WorldChunkManager.class

@SubscribeEvent

public void onBiomeInit(InitBiomeGens e) {

 

e.newBiomeGens = initializeAllBiomeGenerators_Tutorial(e.seed, e.worldType);

}

 

// copied from GenLayer.class initializeAllBiomeGenerators()

        // with only one changed input

public static GenLayer[] initializeAllBiomeGenerators_Tutorial(long par0, WorldType par2WorldType)

    {

        boolean flag = false;

        GenLayerIsland genlayerisland = new GenLayerIsland(1L);

        GenLayerFuzzyZoom genlayerfuzzyzoom = new GenLayerFuzzyZoom(2000L, genlayerisland);

        GenLayerAddIsland genlayeraddisland = new GenLayerAddIsland(1L, genlayerfuzzyzoom);

        GenLayerZoom genlayerzoom = new GenLayerZoom(2001L, genlayeraddisland);

        genlayeraddisland = new GenLayerAddIsland(2L, genlayerzoom);

        genlayeraddisland = new GenLayerAddIsland(50L, genlayeraddisland);

        genlayeraddisland = new GenLayerAddIsland(70L, genlayeraddisland);

        GenLayerRemoveTooMuchOcean genlayerremovetoomuchocean = new GenLayerRemoveTooMuchOcean(2L, genlayeraddisland);

        GenLayerAddSnow genlayeraddsnow = new GenLayerAddSnow(2L, genlayerremovetoomuchocean);

        genlayeraddisland = new GenLayerAddIsland(3L, genlayeraddsnow);

        GenLayerEdge genlayeredge = new GenLayerEdge(2L, genlayeraddisland, GenLayerEdge.Mode.COOL_WARM);

        genlayeredge = new GenLayerEdge(2L, genlayeredge, GenLayerEdge.Mode.HEAT_ICE);

        genlayeredge = new GenLayerEdge(3L, genlayeredge, GenLayerEdge.Mode.SPECIAL);

        genlayerzoom = new GenLayerZoom(2002L, genlayeredge);

        genlayerzoom = new GenLayerZoom(2003L, genlayerzoom);

        genlayeraddisland = new GenLayerAddIsland(4L, genlayerzoom);

        GenLayerAddMushroomIsland genlayeraddmushroomisland = new GenLayerAddMushroomIsland(5L, genlayeraddisland);

        GenLayerDeepOcean genlayerdeepocean = new GenLayerDeepOcean(4L, genlayeraddmushroomisland);

        GenLayer genlayer3 = GenLayerZoom.magnify(1000L, genlayerdeepocean, 0);

        byte b0 = 4;

 

        if (par2WorldType == WorldType.LARGE_BIOMES)

        {

            b0 = 6;

        }

 

        if (flag)

        {

            b0 = 4;

        }

        b0 = GenLayer.getModdedBiomeSize(par2WorldType, b0);

 

        GenLayer genlayer = GenLayerZoom.magnify(1000L, genlayer3, 0);

        GenLayerRiverInit genlayerriverinit = new GenLayerRiverInit(100L, genlayer);

       

        // BeginnOF my own code

        // started here to put in the code from getBiomeLayer()-method from WorldType.class

        // but instead of GenLayerBiome i put here my own GenLayerBiome_Tutorial()

        // so instead of: Object object = par2WorldType.getBiomeLayer(par0, genlayer3);

 

        GenLayer ret = new GenLayerBiome_Tutorial(200L, genlayer3, par2WorldType);

        ret = GenLayerZoom.magnify(1000L, ret, 2);

        Object object = new GenLayerBiomeEdge(1000L, ret);

       

        // EndOF

 

        GenLayer genlayer1 = GenLayerZoom.magnify(1000L, genlayerriverinit, 2);

        GenLayerHills genlayerhills = new GenLayerHills(1000L, (GenLayer)object, genlayer1);

        genlayer = GenLayerZoom.magnify(1000L, genlayerriverinit, 2);

        genlayer = GenLayerZoom.magnify(1000L, genlayer, b0);

        GenLayerRiver genlayerriver = new GenLayerRiver(1L, genlayer);

        GenLayerSmooth genlayersmooth = new GenLayerSmooth(1000L, genlayerriver);

        object = new GenLayerRareBiome(1001L, genlayerhills);

 

        for (int j = 0; j < b0; ++j)

        {

            object = new GenLayerZoom((long)(1000 + j), (GenLayer)object);

 

            if (j == 0)

            {

                object = new GenLayerAddIsland(3L, (GenLayer)object);

            }

 

            if (j == 1)

            {

                object = new GenLayerShore(1000L, (GenLayer)object);

            }

        }

 

        GenLayerSmooth genlayersmooth1 = new GenLayerSmooth(1000L, (GenLayer)object);

        GenLayerRiverMix genlayerrivermix = new GenLayerRiverMix(100L, genlayersmooth1, genlayersmooth);

        GenLayerVoronoiZoom genlayervoronoizoom = new GenLayerVoronoiZoom(10L, genlayerrivermix);

        genlayerrivermix.initWorldGenSeed(par0);

        genlayervoronoizoom.initWorldGenSeed(par0);

        return new GenLayer[] {genlayerrivermix, genlayervoronoizoom, genlayerrivermix};

    }

}

 

 

 

 

My own GenLayerBiome_Tutorial(..) looks like this:

 

 

package com.chrissionair.tutorial.world;

 

import net.minecraft.world.WorldType;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.gen.layer.GenLayer;

import net.minecraft.world.gen.layer.IntCache;

 

import com.chrissionair.tutorial.Tutorial;

 

public class GenLayerBiome_Tutorial extends GenLayer

{

    private BiomeGenBase[] field_151623_c;

    private BiomeGenBase[] field_151621_d;

    private BiomeGenBase[] field_151622_e;

    private BiomeGenBase[] field_151620_f;

    private static final String __OBFID = "CL_00000555";

 

    public GenLayerBiomeTutorial(long par1, GenLayer par3GenLayer, WorldType par4WorldType)

    {

        super(par1);

        this.field_151623_c = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.desert, BiomeGenBase.desert, BiomeGenBase.savanna, BiomeGenBase.savanna, BiomeGenBase.plains};

        this.field_151621_d = new BiomeGenBase[] {BiomeGenBase.forest, BiomeGenBase.roofedForest, BiomeGenBase.extremeHills, BiomeGenBase.plains, BiomeGenBase.birchForest, BiomeGenBase.swampland, Tutorial.tutorialBiome};

        this.field_151622_e = new BiomeGenBase[] {BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.taiga, BiomeGenBase.plains, Tutorial.tutorialBiome};

        this.field_151620_f = new BiomeGenBase[] {BiomeGenBase.icePlains, BiomeGenBase.icePlains, BiomeGenBase.icePlains, BiomeGenBase.coldTaiga};

        this.parent = par3GenLayer;

 

        if (par4WorldType == WorldType.DEFAULT_1_1)

        {

            this.field_151623_c = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.swampland, BiomeGenBase.plains, BiomeGenBase.taiga, Tutorial.tutorialBiome};

        }

    }

 

    /**

    * Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall

    * amounts, or biomeList[] indices based on the particular GenLayer subclass.

    */

    public int[] getInts(int par1, int par2, int par3, int par4)

    {

        int[] aint = this.parent.getInts(par1, par2, par3, par4);

        int[] aint1 = IntCache.getIntCache(par3 * par4);

 

        for (int i1 = 0; i1 < par4; ++i1)

        {

            for (int j1 = 0; j1 < par3; ++j1)

            {

                this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2));

                int k1 = aint[j1 + i1 * par3];

                int l1 = (k1 & 3840) >> 8;

                k1 &= -3841;

 

                if (isBiomeOceanic(k1))

                {

                    aint1[j1 + i1 * par3] = k1;

                }

                else if (k1 == BiomeGenBase.mushroomIsland.biomeID)

                {

                    aint1[j1 + i1 * par3] = k1;

                }

                else if (k1 == 1)

                {

                    if (l1 > 0)

                    {

                        if (this.nextInt(3) == 0)

                        {

                            aint1[j1 + i1 * par3] = BiomeGenBase.mesaPlateau.biomeID;

                        }

                        else

                        {

                            aint1[j1 + i1 * par3] = BiomeGenBase.mesaPlateau_F.biomeID;

                        }

                    }

                    else

                    {

                        aint1[j1 + i1 * par3] = this.field_151623_c[this.nextInt(this.field_151623_c.length)].biomeID;

                    }

                }

                else if (k1 == 2)

                {

                    if (l1 > 0)

                    {

                        aint1[j1 + i1 * par3] = BiomeGenBase.jungle.biomeID;

                    }

                    else

                    {

                        aint1[j1 + i1 * par3] = this.field_151621_d[this.nextInt(this.field_151621_d.length)].biomeID;

                    }

                }

                else if (k1 == 3)

                {

                    if (l1 > 0)

                    {

                        aint1[j1 + i1 * par3] = BiomeGenBase.megaTaiga.biomeID;

                    }

                    else

                    {

                        aint1[j1 + i1 * par3] = this.field_151622_e[this.nextInt(this.field_151622_e.length)].biomeID;

                    }

                }

                else if (k1 == 4)

                {

                    aint1[j1 + i1 * par3] = this.field_151620_f[this.nextInt(this.field_151620_f.length)].biomeID;

                }

                else

                {

                    aint1[j1 + i1 * par3] = BiomeGenBase.mushroomIsland.biomeID;

                }

            }

        }

 

        return aint1;

    }

}

 

 

This is almost a copy of the original except that i put in my Tutorial.tutorialBiome into the biome-arrays at the top.

It seems that these arrays are sorted by temperature, so you can decide where (and how often) you put in your Biome, which should be an extended BiomeGenBase of course.

 

Did i forget something?

If my code is not working for you, it's maybe because i put an error here, because i renamed some stuff for this post ;)

 

If someone can tell us more, it would be helpful. And maybe i'm wrong in some points.

The key seems to be the Forge InitBiomeGens-Event (getModdedBiomeGenerators(..) in WorldChunkManager), which seems to override the original GenLayers, even if they are not modded (newBiomeGens = original.clone()).

Because i was worried if i doubled the GenLayers .. but it's ok i think.

 

 

    public WorldChunkManager(long par1, WorldType par3WorldType)

    {

        this();

        GenLayer[] agenlayer = GenLayer.initializeAllBiomeGenerators(par1, par3WorldType);

        agenlayer = getModdedBiomeGenerators(par3WorldType, par1, agenlayer);

        this.genBiomes = agenlayer[0];

        this.biomeIndexLayer = agenlayer[1];

    }

 

 

 

ps: of course you need to define your Biome in your basemod-file, and register the Event there

[MinecraftForge.TERRAIN_GEN_BUS.register(new Tutorial_Biome_Event());]

as described above in the first post, i think ..

I also did register my biome to the Biome-Dictionary.

and with the BiomeManager you can modify the spawning, but i'm sure you know these things already ;)

Link to comment
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.
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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

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