Jump to content

Recommended Posts

Posted

I have a custom biome already implemented and generating in the world randomly. However it is currently just a plain biome and i'm looking to add my custom tree to spawn in this biome Only. I also noticed that despite having the decorator statements as shown below i do not believe that they have any effect on the biome.

 

 

 

        this.theBiomeDecorator.flowersPerChunk = -999;
        this.theBiomeDecorator.deadBushPerChunk = 2;
        this.theBiomeDecorator.mushroomsPerChunk = 8;
        this.theBiomeDecorator.reedsPerChunk = 10;
        this.theBiomeDecorator.clayPerChunk = 5;
        this.theBiomeDecorator.waterlilyPerChunk = 4;
        this.waterColorMultiplier = 14745518;

 

 

 

Here is the BiomeGen code for my biome (includes the statements I posted above):

 

 

package infection.mod;

import java.util.ArrayList;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.SpawnListEntry;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenForest;
import net.minecraft.world.gen.feature.WorldGenSwamp;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;

public class BiomeGenLagoon extends BiomeGenBase
{
    public BiomeGenLagoon(int par1)
    {
        super(par1);
        this.topBlock = (byte)mod_MainClass.LGrass.blockID;
        this.fillerBlock = (byte)mod_MainClass.LagoonDirt.blockID;
        this.theBiomeDecorator.flowersPerChunk = -999;
        this.theBiomeDecorator.deadBushPerChunk = 2;
        this.theBiomeDecorator.mushroomsPerChunk = 8;
        this.theBiomeDecorator.reedsPerChunk = 10;
        this.theBiomeDecorator.clayPerChunk = 5;
        this.theBiomeDecorator.waterlilyPerChunk = 4;
        this.waterColorMultiplier = 14745518;
    }
    

    public void decorate(World par1World, Random par2Random, int par3, int par4)
    {
        super.decorate(par1World, par2Random, par3, par4);
    }
    

  
    }

 

 

 

And then this is the WorldGenerator class for the Tree:

 

 

 

package infection.mod;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class WorldGeneratorLagoon implements IWorldGenerator{
    
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
        
	switch(world.provider.dimensionId){
            case 1:
                generateNether(world, random, chunkX * 16, chunkZ * 16);
            case 0:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
            case -1:
                generateEnd(world, random, chunkX * 16, chunkZ * 16);
	}

}
    
private void generateEnd(World world, Random random, int chunkX, int chunkZ){

}
    
private void generateSurface(World world, Random random, int BlockX, int BlockZ) {

	for(int i = 0; i < 20; i++){
		int Xcoord1 = BlockX + random.nextInt(16);
		int Ycoord1 = random.nextInt(90);
		int Zcoord1 = BlockZ + random.nextInt(16);

		(new WorldGenLagoonTree(false, 15, 0, 0)).generate(world, random, Xcoord1, Ycoord1, Zcoord1);
	}	
		}
    
private void generateNether(World world, Random random, int chunkX, int chunkZ){

}


    
}

 

 

 

I'm trying to add that tree to that biome.

 

This is the WorldGen for the tree as well, however I do not think this is needed:

 

 

package infection.mod;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.ForgeDirection;

public class WorldGenLagoonTree extends WorldGenerator
{
    /** The base height of the tree */
    private final int baseHeight;

    /** Sets the metadata for the wood blocks used */
    private final int woodMetadata;

    /** Sets the metadata for the leaves used in huge trees */
    private final int leavesMetadata;

    public WorldGenLagoonTree(boolean par1, int par2, int par3, int par4)
    {
        super(par1);
        this.baseHeight = par2;
        this.woodMetadata = par3;
        this.leavesMetadata = par4;
    }

    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    {
        int var6 = par2Random.nextInt(3) + this.baseHeight;
        boolean var7 = true;

        if (par4 >= 1 && par4 + var6 + 1 <= 256)
        {
            int var8;
            int var10;
            int var11;
            int var12;

            for (var8 = par4; var8 <= par4 + 1 + var6; ++var8)
            {
                byte var9 = 2;

                if (var8 == par4)
                {
                    var9 = 1;
                }

                if (var8 >= par4 + 1 + var6 - 2)
                {
                    var9 = 2;
                }

                for (var10 = par3 - var9; var10 <= par3 + var9 && var7; ++var10)
                {
                    for (var11 = par5 - var9; var11 <= par5 + var9 && var7; ++var11)
                    {
                        if (var8 >= 0 && var8 < 256)
                        {
                            var12 = par1World.getBlockId(var10, var8, var11);
                            Block block = Block.blocksList[var12];

                            if (block != null &&
                               !block.isLeaves(par1World, var10, var8, var11) &&
                               !block.canSustainPlant(par1World, var10, var8, var11, ForgeDirection.UP, (LagoonSapling)mod_MainClass.LagoonSapling) && 
                               !block.isWood(par1World, var10, var8, var11) &&
                               var12 != mod_MainClass.LagoonSapling.blockID)
                            {
                                var7 = false;
                            }
                        }
                        else
                        {
                            var7 = false;
                        }
                    }
                }
            }

            if (!var7)
            {
                return false;
            }
            else
            {
                var8 = par1World.getBlockId(par3, par4 - 1, par5);
                Block soil = Block.blocksList[var8];
                boolean isValidSoil = soil != null && soil.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (LagoonSapling)mod_MainClass.LagoonSapling);

                if (isValidSoil && par4 < 256 - var6 - 1)
                {
                    onPlantGrow(par1World, par3,     par4 - 1, par5,     par3, par4, par5);
                    onPlantGrow(par1World, par3 + 1, par4 - 1, par5,     par3, par4, par5);
                    onPlantGrow(par1World, par3,     par4 - 1, par5 + 1, par3, par4, par5);
                    onPlantGrow(par1World, par3 + 1, par4 - 1, par5 + 1, par3, par4, par5);
                    this.growLeaves(par1World, par3, par5, par4 + var6, 2, par2Random);

                    for (int var14 = par4 + var6 - 2 - par2Random.nextInt(4); var14 > par4 + var6 / 2; var14 -= 2 + par2Random.nextInt(4))
                    {
                        float var15 = par2Random.nextFloat() * (float)Math.PI * 2.0F;
                        var11 = par3 + (int)(0.5F + MathHelper.cos(var15) * 4.0F);
                        var12 = par5 + (int)(0.5F + MathHelper.sin(var15) * 4.0F);
                        this.growLeaves(par1World, var11, var12, var14, 0, par2Random);

                        for (int var13 = 0; var13 < 5; ++var13)
                        {
                            var11 = par3 + (int)(1.5F + MathHelper.cos(var15) * (float)var13);
                            var12 = par5 + (int)(1.5F + MathHelper.sin(var15) * (float)var13);
                            this.setBlockAndMetadata(par1World, var11, var14 - 3 + var13 / 2, var12, mod_MainClass.LagoonLog.blockID, this.woodMetadata);
                        }
                    }

                    for (var10 = 0; var10 < var6; ++var10)
                    {
                        var11 = par1World.getBlockId(par3, par4 + var10, par5);

                        if (var11 == 0 || Block.blocksList[var11] == null || Block.blocksList[var11].isLeaves(par1World, par3, par4 + var10, par5))
                        {
                            this.setBlockAndMetadata(par1World, par3, par4 + var10, par5, mod_MainClass.LagoonLog.blockID, this.woodMetadata);

                            if (var10 > 0)
                            {
                                if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + var10, par5))
                                {
                                    this.setBlockAndMetadata(par1World, par3 - 1, par4 + var10, par5, Block.vine.blockID, ;
                                }

                                if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + var10, par5 - 1))
                                {
                                    this.setBlockAndMetadata(par1World, par3, par4 + var10, par5 - 1, Block.vine.blockID, 1);
                                }
                            }
                        }

                        if (var10 < var6 - 1)
                        {
                            var11 = par1World.getBlockId(par3 + 1, par4 + var10, par5);

                            if (var11 == 0 || Block.blocksList[var11] == null || Block.blocksList[var11].isLeaves(par1World, par3 + 1, par4 + var10, par5))
                            {
                                this.setBlockAndMetadata(par1World, par3 + 1, par4 + var10, par5, mod_MainClass.LagoonLog.blockID, this.woodMetadata);

                                if (var10 > 0)
                                {
                                    if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 2, par4 + var10, par5))
                                    {
                                        this.setBlockAndMetadata(par1World, par3 + 2, par4 + var10, par5, Block.vine.blockID, 2);
                                    }

                                    if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + var10, par5 - 1))
                                    {
                                        this.setBlockAndMetadata(par1World, par3 + 1, par4 + var10, par5 - 1, Block.vine.blockID, 1);
                                    }
                                }
                            }

                            var11 = par1World.getBlockId(par3 + 1, par4 + var10, par5 + 1);

                            if (var11 == 0 || Block.blocksList[var11] == null || Block.blocksList[var11].isLeaves(par1World, par3 + 1, par4 + var10, par5 + 1))
                            {
                                this.setBlockAndMetadata(par1World, par3 + 1, par4 + var10, par5 + 1, mod_MainClass.LagoonLog.blockID, this.woodMetadata);

                                if (var10 > 0)
                                {
                                    if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 2, par4 + var10, par5 + 1))
                                    {
                                        this.setBlockAndMetadata(par1World, par3 + 2, par4 + var10, par5 + 1, Block.vine.blockID, 2);
                                    }

                                    if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + var10, par5 + 2))
                                    {
                                        this.setBlockAndMetadata(par1World, par3 + 1, par4 + var10, par5 + 2, Block.vine.blockID, 4);
                                    }
                                }
                            }

                            var11 = par1World.getBlockId(par3, par4 + var10, par5 + 1);

                            if (var11 == 0 || Block.blocksList[var11] == null || Block.blocksList[var11].isLeaves(par1World, par3, par4 + var10, par5 + 1))
                            {
                                this.setBlockAndMetadata(par1World, par3, par4 + var10, par5 + 1, mod_MainClass.LagoonLog.blockID, this.woodMetadata);

                                if (var10 > 0)
                                {
                                    if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + var10, par5 + 1))
                                    {
                                        this.setBlockAndMetadata(par1World, par3 - 1, par4 + var10, par5 + 1, Block.vine.blockID, ;
                                    }

                                    if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + var10, par5 + 2))
                                    {
                                        this.setBlockAndMetadata(par1World, par3, par4 + var10, par5 + 2, Block.vine.blockID, 4);
                                    }
                                }
                            }
                        }
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        else
        {
            return false;
        }
    }

    private void growLeaves(World par1World, int par2, int par3, int par4, int par5, Random par6Random)
    {
        byte var7 = 2;

        for (int var8 = par4 - var7; var8 <= par4; ++var8)
        {
            int var9 = var8 - par4;
            int var10 = par5 + 1 - var9;

            for (int var11 = par2 - var10; var11 <= par2 + var10 + 1; ++var11)
            {
                int var12 = var11 - par2;

                for (int var13 = par3 - var10; var13 <= par3 + var10 + 1; ++var13)
                {
                    int var14 = var13 - par3;

                    Block block = Block.blocksList[par1World.getBlockId(var11, var8, var13)];

                    if ((var12 >= 0 || var14 >= 0 || var12 * var12 + var14 * var14 <= var10 * var10) && 
                        (var12 <= 0 && var14 <= 0 || var12 * var12 + var14 * var14 <= (var10 + 1) * (var10 + 1)) && 
                        (par6Random.nextInt(4) != 0 || var12 * var12 + var14 * var14 <= (var10 - 1) * (var10 - 1)) && 
                        (block == null || block.canBeReplacedByLeaves(par1World, var11, var8, var13)))
                    {
                        this.setBlockAndMetadata(par1World, var11, var8, var13, mod_MainClass.LagoonLeaf.blockID, this.leavesMetadata);
                    }
                }
            }
        }
    }
    
    private void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ)
    {
        Block block = Block.blocksList[world.getBlockId(x, y, z)];
        if (block != null)
        {
            block.onPlantGrow(world, x, y, z, sourceX, sourceY, sourceZ);
        }
    }
}

 

 

 

Lastly this is the code implemented into my main mod class that registers my biome:

 

 

//Biomes
    Lagoon = (new BiomeGenLagoon(23).setBiomeName("LagoonBiome").setMinMaxHeight(-0.2F,0.2F).setTemperatureRainfall(0.8F, 0.9F));
    GameRegistry.addBiome(Lagoon);

 

 

 

Any help getting the tree to spawn in Only that biome would incredibly helpful. On another note I also need to know how to spawn a custom mob in only this same biome.

 

Thanks in advanced for anyone that can provide any assistance.

 

 

  • 2 weeks later...
Posted

If you still haven't figured it out (seeing as this thread is a little bit old), your problem is that you're not overriding the BiomeGenBase method:

 

public WorldGenerator getRandomWorldGenForTrees(Random random)

 

If you don't override this method, Java will just use the one in BiomeGenBase, which, I think, gives you the default tree generator.

 

You also may need to change the BiomeDecorator's treesPerChunk field, and make sure your trees can spawn on your biome's top block.

 

Certain BiomeDecorator fields only change the way the biome is decorated if certain conditions are met. For the decorator to spawn dead bushes, the top block must be sand, mushrooms only spawn in low light levels (I think), clay only spawns underwater in a biome of the top block is dirt or grass. reeds also need either dirt, grass, sand, or gravel to spawn. Lilypads need water in the biome, so the minimum height must be negative.

 

Also, there's no need to override the decorate() method from BiomeGenBase if all you're doing is calling the one in BiomeGenBase.

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

    • Well, when I log in to the server, sometimes within an hour, sometimes within a minute, the server closes and informs me that there was a Ticking entity error. Below is the crash report
    • Try switching to Windowed or Borderless Window mode in Minecraft. These modes make it easier for the recorder to capture gameplay, as it still has access to the display without the game taking up all of the graphics resources.
    • This forum is for Forge, not NeoForge. Please go to them for support.
    • Forge version: 55.0.0 Minecraft version: 1.21.5 Downloads: As this is the start of a new version, it is recommended that you check the downloads page and use the latest version to receive any bug fixes. Downloads page Intro: Good evening! Today, we have released our initial build of Forge 55.0 for Minecraft 1.21.5. 1.21.5 is the newest member of the 1.21 family of versions, which was released yesterday on March 25, 2025. As a reminder, the first minor (X.0) of a Forge version is a beta. Forge betas are marked as such on the bottom left of the title screen and are candidates for any breaking changes. Additionally, there are a couple of important things to note about this update, which I've made sure to mention in this post as well. Feel free to chat with us about bugs or these implementation changes on GitHub and in our Discord server. As always, we will continue to keep all versions of 1.21 and 1.20 in active support as covered by our tiered support policy. Cheers, happy modding, and good luck porting! Rendering Refactor For those who tuned in to Minecraft Live on March 22, 2025, you may already know that Mojang have announced their intention to bring their new Vibrant Visuals overhaul to Java in the future. They've taken the first steps toward this by refactoring how rendering pipelines and render types are handled internally. This has, in turn, made many of Forge's rendering APIs that have existed for years obsolete, as they (for the most part) can be done directly in vanilla. If there was a rendering API that was provided by Forge which you believe should be re-implemented, we're happy to discuss on GitHub through an issue or a pull request. Deprecation of weapon-like ToolActions In 1.21.5, Minecraft added new data components for defining the characteristics of weapons in data. This includes attack speed, block tags which define efficient blocks, and more. As such, we will begin marking our ToolActions solution for this as deprecated. ToolActions were originally added to address the problem of creating modded tools that needed to perform the same actions as vanilla tools. There are still a few tool actions that will continue to be used, such as the shears tool action for example. There are some existing Forge tool actions that are currently obsolete and have no effect given the way the new data components are implemented. We will continue to work on these deprecations and invite you to chat with us on GitHub or Discord if you have any questions.
    • In summary, a full mod to adjust mining progress in such a specific way does not yet exist in its exact form, but it is possible to find mods that change certain aspects of progression (e.g. "Harder Ores").
  • Topics

×
×
  • Create New...

Important Information

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