Jump to content

[UNSOLVED] Generating Custom Flowers in Prexisting Biomes?


Tyler_Watson

Recommended Posts

Ahoj. :)

 

I was hesitant to post this at first, because, knowing my coding habits, this is probably the worst way to do something like this. You have been extremely patient though, so I'll give you something you can at least start on.

 

 

You can use this:

 

                        BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);

                        if(biomegenbase instanceof BiomeGenPlains)

 

and then your "for loop"

 

 

I hope this helps a bit. :)

 

--Tenyar

 

Link to comment
Share on other sites

I'm at a loss when it comes to fixing things in forge. Should it look like this?

                BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(firstBlockXCoord, firstBlockZCoord);
                if(biomegenbase instanceof BiomeGenDesert)
            	for(int l = 0; l < 10; l++){
            		int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenMinable(PenguinMod.flowerPineapple.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            	}

Link to comment
Share on other sites

Make a seperate class for your flower.

 

It will look something like this...

 

http://pastebin.com/iUKqa9Lw

 

 

and then change

(new WorldGenMinable(PenguinMod.flowerPineapple.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);

           

to

 

(new WorldGenYourFlower()).generate(world, random, RandPosX, RandPosY, RandPosZ);

       

Like I said, I have bad habits. I don't always do things the "best" or "most efficient" way. If it works; it works. I guess thats what happens when you are almost entirely self taught. ¯\_(ツ)_/¯

 

 

EDIT: ^ What GoTo said. Hi GoTo. :)

Link to comment
Share on other sites

As far as I'm aware the code is correct an I have no errors but the pineapple won't spawn. Is anything wrong with my code? Thanks for all the help so far.

 

WorldGenPineapple

package TylerWatson.Mod;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenPineapple extends WorldGenerator
{
public boolean generate(World par1World, Random par2Random, int X, int Y, int Z)
{
	if (par1World.isAirBlock(X, Y, Z) && PenguinMod.flowerPineapple.canBlockStay(par1World, X, Y, Z))
	par1World.setBlock(X, Y, Z, PenguinMod.flowerPineapple.blockID);

	return true;
}
}

 

PenguinWorldGenerator:

package TylerWatson.Mod;

import java.util.Random;

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

public class PenguinWorldGenerator 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);
	    break;
	case 0:
	    generateSurface(world, random, chunkX * 16, chunkZ * 16);
	    break;
	case 1:
	    generateEnd(world, random, chunkX * 16, chunkZ * 16);
	    break;
	}
}

private void generateEnd(World world, Random random, int i, int j) {

}

private void generateSurface(World world, Random random, int i, int j) {
        for(int k = 0; k < 5; k++){
        	int firstBlockXCoord = i + random.nextInt(16);
        	int firstBlockYCoord = random.nextInt(30);
        	int firstBlockZCoord = j + random.nextInt(16);
        	(new WorldGenMinable(PenguinMod.quicksilverOre.blockID, 3)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        
        	for(int p = 0; p < 10; p++){
        		int x = i + random.nextInt(16);
            	int y = random.nextInt(30);
            	int z = j + random.nextInt(16);
            	(new WorldGenMinable(PenguinMod.copperOre.blockID, 5)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	}
                for(int q = 0; q < 10; q++){
                	int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenMinable(PenguinMod.cobaltOre.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            }
            	for(int l = 0; l < 10; l++){
            		int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenMinable(PenguinMod.rubyOre.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            	}
            	for(int c = 0; c < 10; c++){
            		int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenPineapple()).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            	}
        	}
}

private void generateNether(World world, Random random, int i, int j) {

}

}

 

FlowerPineapple:

package TylerWatson.Mod;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;

public class FlowerPineapple extends BlockFlower{

public FlowerPineapple(int par1) {
	super(par1);
}
    public boolean canThisPlantGrowOnThisBlockID(int par1)
    {
        return par1 == Block.grass.blockID || par1 == Block.dirt.blockID || par1 == Block.sand.blockID;
    }

}

Link to comment
Share on other sites

I think I have your solution.

 

First, where are you getting "firstBlockXCoord, firstBlockYCoord, firstBlockZCoord" from? How is Eclipse not screaming at you? Switch them out for "x, y, z" respectively.

 

Second, change the number in "for(int c = 0; c < 10; c++)" to something higher, like.. "for(int c = 0; c < 80; c++)"

 

 

--Tenyar

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.