Jump to content

Recommended Posts

Posted

Hey boys and girls!

 

I've been searching high and low for an example of someone making a custom BiomeDecorator for version 1.6.2 but can't find it. Found it for earlier versions but the biome decoration code was changed for 1.6 (I think). Correct me if I'm wrong, but as I understood each biome had it's own decorator before 1.6, and now there is only one, "this.theBiomeDecorator".

 

So I have my custom biome (BiomeGenRedrock) which generates properly. And I have a custom block (BlockRedrockStone) that forms the top and the filler layers. Now I want to decorate my biome, starting with dead bushes. The problem is that plants can only be placed on sand, dirt, grass etc. So I made a replica of the vanilla BlockDeadBush (FCDeadBush) that looks and is supposed to behave kinda the same, except that it can also be placed on redrock.

 

I made a WorldGenFCDeadBush and a BiomeDecoratorRedrock in an attempt to get my bush to generate in my biome. I even commented out the check "canBlockStay", so it should spawn everywhere within the biome. But... my biome is still as barren as the moon....

 

Is there something I missed out in the code? Is this even possible, or am I completely banging my head on a stone wall... in a dead end! :)

 

***BiomeGenRedrock***

 

package fcraft.biome;

import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.DEAD_BUSH;

import java.util.Random;

import fcraft.blocks.BlockData;
import net.minecraft.block.Block;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.SpawnListEntry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.BiomeEvent;
import net.minecraftforge.event.terraingen.TerrainGen;

public class BiomeGenRedrock extends BiomeGenBase {

public BiomeDecoratorRedrock biomeRedrockDecorator = new BiomeDecoratorRedrock(this);

public BiomeGenRedrock(int par1) {
	super(par1);
	this.topBlock = (byte)BlockData.redrockStone.blockID;
	this.fillerBlock = (byte)BlockData.redrockStone.blockID;
	this.setMinMaxHeight(0.8F, 1.4F);
	this.setTemperatureRainfall(1.7F, 0.0F);
	this.setDisableRain();
	this.spawnableWaterCreatureList.clear();
	this.spawnableCreatureList.clear();
	this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 2, 4));
	this.waterColorMultiplier = 14745518;
	//biomeRedrockDecorator = (BiomeDecoratorRedrock)this.createBiomeDecorator();
	//biomeRedrockDecorator = new BiomeDecoratorRedrock(this);
	this.biomeRedrockDecorator.deadBush2PerChunk = 22;

}	

}

 

 

***BiomeDecoratorRedrock***

 

package fcraft.biome;

import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.DEAD_BUSH;
import fcraft.blocks.BlockData;
import fcraft.world.WorldGenFCDeadBush;
import net.minecraft.block.Block;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenDeadBush;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.terraingen.TerrainGen;

public class BiomeDecoratorRedrock extends BiomeDecorator{

protected int deadBush2PerChunk;
protected WorldGenerator genDeadBush2;

public BiomeDecoratorRedrock(BiomeGenBase biomegenbase)
{
	super(biomegenbase);
	genDeadBush2 = new WorldGenFCDeadBush(BlockData.fc_deadBush.blockID);
}

@Override
protected void decorate()
{
	super.decorate();
	boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH);
        for (int j = 0; doGen && j < this.deadBush2PerChunk; ++j)
        {
            int rx = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
            int ry = 60 + this.randomGenerator.nextInt(50);
            int rz = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
            genDeadBush2.generate(this.currentWorld, this.randomGenerator, rx, ry, rz);
        }
}

}

 

 

***FCDeadBush***

 

package fcraft.blocks;

import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;

public class FCDeadBush extends BlockFlower
{
    protected FCDeadBush(int par1)
    {
        super(par1, Material.vine);
        float f = 0.4F;
        this.setCreativeTab(CreativeTabs.tabDecorations);
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
    }
    
    @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg){
	this.blockIcon = reg.registerIcon("fc_images:deadbush2");
}

    /** Gets passed in the blockID of the block below and supposed to return true if it can grow on current block */
    protected boolean canThisPlantGrowOnThisBlockID(int par1)
    {
        if(par1 == Block.sand.blockID || par1 == BlockData.redrockStone.blockID)
        	return true;
        else
        	return false;
    }

    /**
     * Returns the ID of the items to drop on destruction.
     */
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return -1;
    }

    /**
     * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
     * block and l is the block's subtype/damage.
     */
    public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
    {
        if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID)
        {
            par2EntityPlayer.addStat(StatList.mineBlockStatArray[block.deadBush.blockID], 1);
            this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.deadBush, 1, par6));
        }
        else
        {
            super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
        }
    }
    
    /**
     * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
     */
    public boolean canBlockStay(World par1World, int par2, int par3, int par4)
    {
        Block soil = blocksList[par1World.getBlockId(par2, par3 - 1, par4)];
        return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && 
                (soil != null && soil.blockID == BlockData.redrockStone.blockID);
    }
}

 

 

***WorldGenFCDeadBush***

 

package fcraft.world;

import java.util.Random;

import fcraft.blocks.BlockData;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenFCDeadBush extends WorldGenerator
{
    /** stores the ID for WorldGenFCDeadBush */
    private int deadBush2ID;

    public WorldGenFCDeadBush(int par1)
    {
        this.deadBush2ID = par1;
    }

   // @Override
    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    {
        int l;

        Block block = null;
        Block blockUnder = null;
        
        do 
        {
            block = Block.blocksList[par1World.getBlockId(par3,  par4, par5)];
            if (block != null && !block.isLeaves(par1World, par3, par4, par5))
            {
                break;
            }
            par4--;
        } while (par4 > 0);

        for (int i1 = 0; i1 < 4; ++i1)
        {
            int j1 = par3 + par2Random.nextInt( - par2Random.nextInt(;
            int k1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
            int l1 = par5 + par2Random.nextInt( - par2Random.nextInt(;

            //if (par1World.isAirBlock(j1, k1, l1) && BlockData.fc_deadBush.canBlockStay(par1World, j1, k1, l1))
            //{
                par1World.setBlock(j1, k1, l1, this.deadBush2ID, 0, 2);
            //}
        }

        return true;
    }
}

 

 

 

Thanks in advance for your help. /Frepo

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.