Posted November 29, 201311 yr I created a new flower for my mod and I can generate it in a custom biome but how do I generate it so it spawns on biomes already in the game? Also is there a forge hook that allows a custom flower to spawn when bonemeal is used on grass? I'll be thankful for any help.
November 30, 201311 yr 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 I am the creator of "The Breakfast Mod". http://cache.gyazo.com/9f747cb0c5979bafb79bcd28e86c0f5b.png[/img]
November 30, 201311 yr Author I have an intermediate knowledge of java but where do I put that code? In my main class, flowerPineapple class or my world generator class?
November 30, 201311 yr Oh, I'm sorry. I was in a hurry at the time of writing that. :'( You put it in your world generator class. I am the creator of "The Breakfast Mod". http://cache.gyazo.com/9f747cb0c5979bafb79bcd28e86c0f5b.png[/img]
November 30, 201311 yr Author 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); }
November 30, 201311 yr Just don't check for a biome at all. Also, tweak your block so that it can spawn on anything. Unless you don't want it to spawn on everything, just make it spawn on BlockGrass. Most other mods' grass blocks will extend BlockGrass. Kain
November 30, 201311 yr Don't use WorldGenMineable. It's for replacing (stone) blocks with other (ores).
November 30, 201311 yr 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. I am the creator of "The Breakfast Mod". http://cache.gyazo.com/9f747cb0c5979bafb79bcd28e86c0f5b.png[/img]
December 1, 201311 yr Author 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; } }
December 1, 201311 yr 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 I am the creator of "The Breakfast Mod". http://cache.gyazo.com/9f747cb0c5979bafb79bcd28e86c0f5b.png[/img]
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.