Jump to content

[1.7.10] generate seaweed underwater instead of clay using BiomeDecorator


Glistre

Recommended Posts

Trying to make my custom seaweedgenerate in place of the clay block in my custom Glistering  biome.

 

I created a new WorldGenSeaweed class for seaweed modeled after WorldGenClay class.  I created a new BiomeDecorator class called BiomeDecoratorGlistre, and trying to generate my Seaweed block instead of Blocks.clay.

 

Cannot seem to get it to work

 

WorldGenSeaweed:

 

package com.glistre.glistremod.biome;

import java.util.Random;

import com.glistre.glistremod.BlockRegistry;
import com.glistre.glistremod.MyBlock;
import com.glistre.glistremod.atlantis.BlockSeaweed;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenClay;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenSeaweed extends WorldGenClay
{
    public BlockSeaweed fieldseaweed;
    /** The number of blocks to generate. */
    private int numberOfBlocks;
//   private static final String __OBFID = "CL_00000405";

    public WorldGenSeaweed(int p_i2011_1_)
    {
    	super(p_i2011_1_);
        this.fieldseaweed = (BlockSeaweed) BlockRegistry.blockSeaweed;
        this.numberOfBlocks = p_i2011_1_;
//        this.numberOfBlocks = 16;
    }

    public boolean generate(World world, Random random, int par2, int par3, int par4)
    {
        if (world.getBlock(par2, par3, par4).getMaterial() != Material.water)
        {
            return false;
        }
        else
        {
            int l = random.nextInt(this.numberOfBlocks - 2) + 2;
            byte b0 = 1;

            for (int i1 = par2 - l; i1 <= par2 + l; ++i1)
            {
                for (int j1 = par4 - l; j1 <= par4 + l; ++j1)
                {
                    int k1 = i1 - par2;
                    int l1 = j1 - par4;

                    if (k1 * k1 + l1 * l1 <= l * l)
                    {
                        for (int i2 = par3 - b0; i2 <= par3 + b0; ++i2)
                        {
                            Block block = world.getBlock(i1, i2, j1);

                            if (block == Blocks.dirt || block == Blocks.sand || block == Blocks.gravel || block == Blocks.clay)
                            {
                                world.setBlock(i1, i2, j1, this.fieldseaweed, 0, 2);
                            }
                        }
                    }
                }
            }

            return true;
        }
    }
}

 

BiomeDecoratorGlistre:

 

package com.glistre.glistremod.biome;

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

import java.util.Random;

import com.glistre.glistremod.BlockRegistry;
import com.glistre.glistremod.GlistreBiome;

import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenClay;
import net.minecraft.world.gen.feature.WorldGenLiquids;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import net.minecraftforge.event.terraingen.TerrainGen;

public class BiomeDecoratorGlistre extends BiomeDecorator
{
 /** The world the BiomeDecorator is currently decorating */
    public World currentWorld;
    /** The Biome Decorator's random number generator. */
    public Random randomGenerator;
    /** The X-coordinate of the chunk currently being decorated */
    public int chunk_X;
    /** The Z-coordinate of the chunk currently being decorated */
    public int chunk_Z;
    public int seaweedPerChunk;
    /** The clay/seaweed generator. */
//    public WorldGenerator clayGen = new WorldGenClay(4);
   //added next two lines no idea if will work 
    public WorldGenerator seaweedGen = new WorldGenSeaweed(2);


public BiomeDecoratorGlistre()
{
	super();
//		seaweedPerChunk = new WorldGenSeaweed(16);
	seaweedGen = new WorldGenSeaweed(2);
	this.seaweedPerChunk = 1600;

}

@Override
public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_,
		int p_150512_5_) {
	super.decorateChunk(p_150512_1_, p_150512_2_, p_150512_3_, p_150512_4_, p_150512_5_);
	 if (this.currentWorld != null)
        {
            throw new RuntimeException("Already decorating!!");
        }
        else
        {
            this.currentWorld = p_150512_1_;
            this.randomGenerator = p_150512_2_;
            this.chunk_X = p_150512_4_;
            this.chunk_Z = p_150512_5_;
            this.genDecorations(p_150512_3_);
            this.currentWorld = null;
            this.randomGenerator = null;
        }
}

@Override
protected void genDecorations(BiomeGenBase p_150513_1_) {
	super.genDecorations(p_150513_1_);
	MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z));
        this.generateOres();
        int i;
        int j;
        int k;
        int i1;
        int l;

//       boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND);
       boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY);
        for (j = 0; doGen && j < this.seaweedPerChunk; ++j)
//        	for (j = 0; doGen && j < this.deadBushPerChunk; ++j)
        	{
        	k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
        	l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
        	i1 = this.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
//           (new WorldGenSeaweed()).generate(this.currentWorld, this.randomGenerator, k, l, i1);
        	(new WorldGenSeaweed(2)).generate(this.currentWorld, this.randomGenerator, k, i1, l);
        	
//         this.seaweedGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(k, i1), l);
        	MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z));

        	
        	}
        	}
        
        private int nextInt(int i) {
        	if (i <= 1)
        	return 0;
        	return this.randomGenerator.nextInt(i);

}

}

 

CustomBiome  glistering Biome:

 

package com.glistre.glistremod;

import java.util.Random;

import com.glistre.glistremod.biome.BiomeDecoratorGlistre;
import com.glistre.glistremod.biome.WaterGeneration;
import com.glistre.glistremod.biome.WorldGenSeaweed;
import com.glistre.glistremod.entities.EntityTobieSkel;

import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenClay;
import net.minecraft.world.gen.feature.WorldGenHugeTrees;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTallGrass;
import net.minecraft.world.gen.feature.WorldGenerator;

public class GlistreBiome extends BiomeGenBase
{
BiomeDecoratorGlistre customBiomeDecorator;
    public GlistreBiome(int id)
    {
        super(id);
        
        this.setBiomeName("Glistering Biome");
        this.topBlock = Blocks.grass;
	this.fillerBlock = Blocks.dirt;
	this.theBiomeDecorator = new BiomeDecoratorGlistre();
	customBiomeDecorator = new BiomeDecoratorGlistre();
	customBiomeDecorator =(BiomeDecoratorGlistre)theBiomeDecorator;
	this.theBiomeDecorator = this.createBiomeDecorator();
	this.customBiomeDecorator.seaweedPerChunk = 1600;
	this.customBiomeDecorator.seaweedGen = new WorldGenSeaweed(2);
	this.theBiomeDecorator.clayPerChunk = 2;

	//		customBiomeDecorator.seaweedGen = 2;
        
/*        this.theBiomeDecorator.treesPerChunk = 2;
        this.theBiomeDecorator.waterlilyPerChunk = 300;
        this.theBiomeDecorator.bigMushroomsPerChunk = 1;
        this.theBiomeDecorator.reedsPerChunk = 10;
        this.theBiomeDecorator.grassPerChunk = 10;*/
//        this.customBiomeDecorator.seaweedGen = new WorldGenSeaweed(16);



       
        

        this.spawnableCreatureList.add(new SpawnListEntry(EntityOcelot.class, 2, 1, 1));      
        this.spawnableCreatureList.add(new SpawnListEntry(EntityHorse.class, 2, 5, 7));
        this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 1, 2, 7));     
        this.spawnableMonsterList.add(new SpawnListEntry(EntitySkeleton.class, 1, 1, 1));
        this.spawnableMonsterList.add(new SpawnListEntry(EntityZombie.class, 2, 1, 2));
        this.spawnableCreatureList.add(new SpawnListEntry(EntityGlistreWolf.class, 1, 1, 5));
        this.spawnableCreatureList.add(new SpawnListEntry(EntityTobieSkel.class, 10, 3, 7));
        this.spawnableCreatureList.clear();
        this.spawnableWaterCreatureList.clear();
        this.spawnableMonsterList.clear();        
//this.spawnableMonsterList.add(new SpawnListEntry(EntityWitch.class, 200, 1, 1));
    
        this.addFlower(Blocks.red_flower, 4, 3);
        this.addFlower(Blocks.pumpkin, 7, 20);
//       this.addFlower(Blocks.red_flower, 5, 3);       
//        this.addFlower(Blocks.red_flower, 7, 3);       
//       this.addFlower(Blocks.red_flower, 0, 20);       
//      this.addFlower(Blocks.yellow_flower, 0, 30);

        
//       this.setColor(0x7F007F);
//        this.setColor(0x443333);
        this.setColor(0x003000);
        this.setEnableSnow();
        this.setMinMaxHeight(0.7F, 1.1F);
        this.setTemperatureRainfall(0.75F, .25F);
       
    }
    
/*   public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_)
    {
        super.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_);
    } */
/*	@Override
public BiomeGenBase.TempCategory getTempCategory()
{
	return TempCategory.COLD;
}*/



private void setMinMaxHeight(float f, float g) 
{

}
//    @SideOnly(Side.CLIENT)
/*   public int getBiomeGrassColor()
    {
    	return 0x443333;
    }
//   @SideOnly(Side.CLIENT)
    public int getBiomeFoliageColor()
    {
    	return 0x443333;
    }*/
//   @SideOnly(Side.CLIENT)
    public int getSkyColorByTemp(float par1)
    {
    	return 0x443333;
    }

    /**
     * Gets a WorldGen appropriate for this biome.
    */ 
/*this is supposed to have WorldGenTallGrass not Water Generation block.seaweed{
BiomeGenBase b = world.getBiomeGenForCoords(i, j);
if(b.biomeName.equals("biomeGlistre")) {*/
    
    public WorldGenerator getRandomWorldGenForGrass(Random random){
        return random.nextInt(2) == 0 ? new WaterGeneration(BlockRegistry.blockSeaweed, 1) : new WorldGenTallGrass(BlockRegistry.blockSeaweed, 2);
        
    }
    public WorldGenerator getRandomWorldGenForTrees(Random par1Random){
    	return(WorldGenerator)(par1Random.nextInt(1) == 0 ? this.worldGeneratorBigTree : (par1Random.nextInt(6) == 0 ? this.worldGeneratorSwamp : par1Random.nextInt(20) == 0 ? this.worldGeneratorTrees : this.worldGeneratorTrees));
    }

    public void generateSurface (World world, Random random, int i, int j){
    
    	for(int f = 0; f <20; f++);{
    	int x = i + random.nextInt(16);
    	int y = random.nextInt(128);
    	int z = j + random.nextInt(16);
    	new WaterGeneration(BlockRegistry.blockSeaweed, 20).generate(world, random, x, y, z);
    	}
    	}

             
       

}
    /** Adds Huge Trees to your Biome */
/*   public WorldGenerator getRandomWorldGenForTrees(Random random)
   {
        return (WorldGenerator)
        new WorldGenHugeTrees(false, 20 + random.nextInt(10), 1, 3, 3);
        }
      /*   Wood/Leaf Metadata: 0=Oak, 1=Spruce, 2=Birch, 3=Jungle Wood */
    

 

Any ideas? Would I have to create a new event instead of using the CLAY event?  Or is there something really obvious I am missing?

Link to comment
Share on other sites

I changed

  public WorldGenerator getRandomWorldGenForGrass(Random random){
        return random.nextInt(2) == 0 ? new WaterGeneration(BlockRegistry.blockSeaweed, 1) : new WorldGenTallGrass(BlockRegistry.blockSeaweed, 2); 

 

to

    public WorldGenerator getRandomWorldGenForGrass(Random random){
        return random.nextInt(2) == 0 ? new WaterGeneration(BlockRegistry.blockSeaweed, 2) : new WorldGenSeaweed(3);

 

and it did generate a small amount of seaweed but only like five blocks.  I am not sure why. . . it looks like it was already working but just very, very, very small amount of seaweed .

 

So, I know I do not need to add a "SEAWEED" event and the CLAY event might be okay. .

 

I still need way more seaweed though

 

UPDATE:  increased the frequency of the seaweed substantially --changed the "number of blocks of my WaterGen class from 10 to 2000 :  my code now looks like this :

    public WorldGenerator getRandomWorldGenForGrass(Random random){
       return random.nextInt(2) == 0 ?  new WorldGenSeaweed(3) : new WorldGenSeaweed(10);
        
   }
    public WorldGenerator getRandomWorldGenForTrees(Random par1Random){
    	return(WorldGenerator)(par1Random.nextInt(1) == 0 ? this.worldGeneratorBigTree : (par1Random.nextInt(6) == 0 ? this.worldGeneratorSwamp : par1Random.nextInt(20) == 0 ? this.worldGeneratorTrees : this.worldGeneratorTrees));
    }

    public void generateSurface (World world, Random random, int i, int j){
    
    	for(int f = 0; f <200; f++);{
    	int x = i + random.nextInt(16);
    	int y = random.nextInt(128);
    	int z = j + random.nextInt(16);
    	new WaterGeneration(BlockRegistry.blockSeaweed, 2000).generate(world, random, x, y, z);
    	}
    	}

 

I still don't have this right though I have not connected all the dots on how its working

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



×
×
  • Create New...

Important Information

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