Posted February 12, 201312 yr Hey, so I have made an ore called Hell Ore and I wanted it to spawn in the nether. After looking around the nether for an hour- in multiple worlds, I could not find my ore, I also tried with multiple spawn rates. Here is the code for the world gen: private void generateNether(World world, Random random, int chunkX, int chunkZ) { for(int i = 0; i < 45; i++){ int xCoord = chunkX + random.nextInt(16); int yCoord = random.nextInt(95); int zCoord = chunkZ + random.nextInt(16); (new WorldGenMinable(gemcraft.HellOre.blockID, 15)).generate(world, random, xCoord, yCoord, zCoord); } } If anyone could help me with that, that would be great. Also, when making a crafting recipe for one of my armor pieces I have come across a strange glitch. The recipe is for my Citrine Helmet and all the other recipes work fine. My glitch is that when I place the crafting table down and open it the Citrine Helmet is already in the crafting bench, as if the recipe for it is "","","". Here is my code for that: //Citrine Helmet GameRegistry.addRecipe(new ItemStack(gemcraft.CitrineHelmet), new Object[]{ "CCC", "C C", "", 'C', CitrineGem, });
February 12, 201312 yr i'll just give you the classes to save you some time: package //Your package; import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import cpw.mods.fml.common.IWorldGenerator; public class OreGeneration implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { case 1: generateEnd(world, random, chunkX * 16, chunkZ * 16); break; case 0: generateOverworld(world, random, chunkX * 16, chunkZ * 16); break; case -1: generateNeather(world, random, chunkX * 16, chunkZ * 16); break; } } private void generateNeather(World world, Random random, int X, int Z) { for(int i = 0; i < numberOfVeins; i++) { int randX = X + random.nextInt(16); int randY = random.nextInt(maxHeight); int randZ = Z + random.nextInt(16); (new WorldGenMinableNether(block.blockID, clusterSize)).generate(world, random, randX, randY, randZ); } } private void generateOverworld(World world, Random random, int X, int Z) { } private void generateEnd(World world, Random random, int X, int Z) { } } to generate in the end: package //Your package; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenMinableEnd extends WorldGenerator { /** The block ID of the ore to be placed using this generator. */ private int minableBlockId; private int metadata = 0; /** The number of blocks to generate. */ private int numberOfBlocks; public WorldGenMinableEnd(int par1, int par2) { minableBlockId = par1; numberOfBlocks = par2; } public WorldGenMinableEnd(int par1, int par2, int par3) { minableBlockId = par1; metadata = par2; numberOfBlocks = par3; } public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { float f = par2Random.nextFloat() * (float)Math.PI; double d = (float)(par3 + + (MathHelper.sin(f) * (float)numberOfBlocks) / 8F; double d1 = (float)(par3 + - (MathHelper.sin(f) * (float)numberOfBlocks) / 8F; double d2 = (float)(par5 + + (MathHelper.cos(f) * (float)numberOfBlocks) / 8F; double d3 = (float)(par5 + - (MathHelper.cos(f) * (float)numberOfBlocks) / 8F; double d4 = (par4 + par2Random.nextInt(3)) - 2; double d5 = (par4 + par2Random.nextInt(3)) - 2; for (int i = 0; i <= numberOfBlocks; i++) { double d6 = d + ((d1 - d) * (double)i) / (double)numberOfBlocks; double d7 = d4 + ((d5 - d4) * (double)i) / (double)numberOfBlocks; double d8 = d2 + ((d3 - d2) * (double)i) / (double)numberOfBlocks; double d9 = (par2Random.nextDouble() * (double)numberOfBlocks) / 16D; double d10 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D; double d11 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D; int j = MathHelper.floor_double(d6 - d10 / 2D); int k = MathHelper.floor_double(d7 - d11 / 2D); int l = MathHelper.floor_double(d8 - d10 / 2D); int i1 = MathHelper.floor_double(d6 + d10 / 2D); int j1 = MathHelper.floor_double(d7 + d11 / 2D); int k1 = MathHelper.floor_double(d8 + d10 / 2D); for (int l1 = j; l1 <= i1; l1++) { double d12 = (((double)l1 + 0.5D) - d6) / (d10 / 2D); if (d12 * d12 >= 1.0D) { continue; } for (int i2 = k; i2 <= j1; i2++) { double d13 = (((double)i2 + 0.5D) - d7) / (d11 / 2D); if (d12 * d12 + d13 * d13 >= 1.0D) { continue; } for (int j2 = l; j2 <= k1; j2++) { double d14 = (((double)j2 + 0.5D) - d8) / (d10 / 2D); if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && par1World.getBlockId(l1, i2, j2) == Block.whiteStone.blockID) { par1World.setBlockAndMetadata(l1, i2, j2, minableBlockId, metadata); } } } } } return true; } } to generate in the nether package //Your package; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenMinableNether extends WorldGenerator { /** The block ID of the ore to be placed using this generator. */ private int minableBlockId; private int metadata = 0; /** The number of blocks to generate. */ private int numberOfBlocks; public WorldGenMinableNether(int par1, int par2) { minableBlockId = par1; numberOfBlocks = par2; } public WorldGenMinableNether(int par1, int par2, int par3) { minableBlockId = par1; metadata = par2; numberOfBlocks = par3; } public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { float f = par2Random.nextFloat() * (float)Math.PI; double d = (float)(par3 + + (MathHelper.sin(f) * (float)numberOfBlocks) / 8F; double d1 = (float)(par3 + - (MathHelper.sin(f) * (float)numberOfBlocks) / 8F; double d2 = (float)(par5 + + (MathHelper.cos(f) * (float)numberOfBlocks) / 8F; double d3 = (float)(par5 + - (MathHelper.cos(f) * (float)numberOfBlocks) / 8F; double d4 = (par4 + par2Random.nextInt(3)) - 2; double d5 = (par4 + par2Random.nextInt(3)) - 2; for (int i = 0; i <= numberOfBlocks; i++) { double d6 = d + ((d1 - d) * (double)i) / (double)numberOfBlocks; double d7 = d4 + ((d5 - d4) * (double)i) / (double)numberOfBlocks; double d8 = d2 + ((d3 - d2) * (double)i) / (double)numberOfBlocks; double d9 = (par2Random.nextDouble() * (double)numberOfBlocks) / 16D; double d10 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D; double d11 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D; int j = MathHelper.floor_double(d6 - d10 / 2D); int k = MathHelper.floor_double(d7 - d11 / 2D); int l = MathHelper.floor_double(d8 - d10 / 2D); int i1 = MathHelper.floor_double(d6 + d10 / 2D); int j1 = MathHelper.floor_double(d7 + d11 / 2D); int k1 = MathHelper.floor_double(d8 + d10 / 2D); for (int l1 = j; l1 <= i1; l1++) { double d12 = (((double)l1 + 0.5D) - d6) / (d10 / 2D); if (d12 * d12 >= 1.0D) { continue; } for (int i2 = k; i2 <= j1; i2++) { double d13 = (((double)i2 + 0.5D) - d7) / (d11 / 2D); if (d12 * d12 + d13 * d13 >= 1.0D) { continue; } for (int j2 = l; j2 <= k1; j2++) { double d14 = (((double)j2 + 0.5D) - d8) / (d10 / 2D); if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && par1World.getBlockId(l1, i2, j2) == Block.netherrack.blockID) { par1World.setBlockAndMetadata(l1, i2, j2, minableBlockId, metadata); } } } } } return true; } } then in your init method in the main mod file add this GameRegistry.registerWorldGenerator(new OreGeneration()); just copy and paste most of that and you should be ok with regards to the crafting thing, try getting rid of the empty quotes, you should only need to include the lines being used. github
February 12, 201312 yr read through it for sure, otherwise you can't understand what it's doing, but the code is, mostly, straight from WorldGenMinable in the minecraft source code github
February 12, 201312 yr Author lol, thanks both of you, btw do any of you know what is wrong with this? //Citrine Helmet GameRegistry.addRecipe(new ItemStack(gemcraft.CitrineHelmet), new Object[]{ "CCC", "C C", " ", 'C', CitrineGem, });
February 12, 201312 yr Author dw I fixed it haha, I suck. And thanks, the helmet thing is also fixed. Thanks for your patience
April 10, 201312 yr dw I fixed it haha, I suck. And thanks, the helmet thing is also fixed. Thanks for your patience haha how did you fix the crashing on entering the nether?
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.