Jump to content

splatterdodge

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by splatterdodge

  1. I tried to do that with numForOres by checking for a random number between 0-99, and if it is 0, 1, 2, 3, 4, or 5 generate ores in that chunk. Is that bad? Is there a better way?
  2. I have successfully turned off Minecraft's vanilla generation and successfully implemented my own. The problem is I say I only want one very large vein of each ore in about 1/100 chunks, but fail. It appears to successfully generate the very large veins of ore, but I don't get them far apart. I tried using code similar to Minecraft's slime chunk code to keep it seed specific and not have it happen in every chunk, but it happens many more times then the 1/100 chances I give it. Most of the time I will get these rich ore chunks on the spawn chunk, and despite me trying to restrict it so it only gets one ore a chunk, I still get several ores in the same chunk. What am I doing wrong? package realisticOreGeneration.world; import java.util.Random; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.fml.common.IWorldGenerator; public class oreWorldGen implements IWorldGenerator { private WorldGenerator gen_iron; private WorldGenerator gen_coal; private WorldGenerator gen_gold; private WorldGenerator gen_diamond; private WorldGenerator gen_redstone; private WorldGenerator gen_lapis; private static final int perOreGen = 99; @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkprovider){ long seed = world.getSeed(); Random randForOres = new Random(seed + (long) (chunkX * chunkX * 0x4c1906) + (long) (chunkX * 0x5ac0db) + (long) (chunkZ * chunkZ) * 0x4307a7L + (long) (chunkZ * 0x5f24f) ^ 0x3ad8025f); switch (world.provider.getDimension()){ case 0: //Overworld int numForOres = randForOres.nextInt(perOreGen); if (numForOres == 0){ this.runGenerator(this.gen_iron, world, random, chunkX, chunkZ, 1, 1, 50); } if (numForOres == 1){ this.runGenerator(this.gen_coal, world, random, chunkX, chunkZ, 1, 1, 64); } if (numForOres == 2){ this.runGenerator(this.gen_gold, world, random, chunkX, chunkZ, 1, 1, 34); } if (numForOres == 3){ this.runGenerator(this.gen_diamond, world, random, chunkX, chunkZ, 1, 1, 16); } if (numForOres == 4){ this.runGenerator(this.gen_redstone, world, random, chunkX, chunkZ, 1, 1, 16); } if (numForOres == 5){ this.runGenerator(this.gen_lapis, world, random, chunkX, chunkZ, 1, 1, 34); } break; case -1: //nether break; case 1: //end break; } } public oreWorldGen(){ this.gen_iron = new WorldGenMinable(Blocks.IRON_ORE.getDefaultState(), 400); this.gen_coal = new WorldGenMinable(Blocks.COAL_ORE.getDefaultState(), 450); this.gen_gold = new WorldGenMinable(Blocks.GOLD_ORE.getDefaultState(), 350); this.gen_diamond = new WorldGenMinable(Blocks.DIAMOND_ORE.getDefaultState(), 200); this.gen_redstone = new WorldGenMinable(Blocks.REDSTONE_ORE.getDefaultState(), 300); this.gen_lapis = new WorldGenMinable(Blocks.LAPIS_ORE.getDefaultState(), 300); } private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight){ if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight) throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator"); int heightdiff = maxHeight - minHeight +1; for (int i=0; i<chancesToSpawn; i++){ int x =chunk_X * 16 +rand.nextInt(16); int y = minHeight + rand.nextInt(heightdiff); int z = chunk_Z * 16 + rand.nextInt(16); generator.generate(world, rand, new BlockPos(x, y, z)); } } }
  3. OK, so I managed to do everything I wanted to do, for the most part. I am generating Iron in large single veins. Now I would like to be able to tell the terrain generator to skip certain chunks and to not generate a resource type in every chunk, maybe more like one in every sixty-four chunks public class oreWorldGen implements IWorldGenerator { private WorldGenerator gen_iron; @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkprovider){ switch (world.provider.getDimension()){ case 0: //Overworld this.runGenerator(this.gen_iron, world, random, chunkX, chunkZ, 1, 10, 50); break; case -1: //nether break; case 1: //end break; } } public oreWorldGen(){ this.gen_iron = new WorldGenMinable(Blocks.IRON_ORE.getDefaultState(), 64); } private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight){ if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight) throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator"); int heightdiff = maxHeight - minHeight +1; for (int i=0; i<chancesToSpawn; i++){ int x =chunk_X * 16 +rand.nextInt(16); int y = minHeight + rand.nextInt(heightdiff); int z = chunk_Z * 16 + rand.nextInt(16); generator.generate(world, rand, new BlockPos(x, y, z)); } } } This is the code I have so far. Thoughts?
  4. I might just be stupid I am trying to hastily ask this question before class, but from a few quick google searches these functions will allow me to change vein size, if they appear in a chunk, and how many veins appear in a chunk, correct?
  5. This may sound like a really basic question, but I can't seem to find anything with google searches, multiple different keywords going several pages deeper then I care to admit. In short, how do I change the games base terrain generation? I would like to change the ore spawn frequency and vein size. My first issue is I can not seem to find how to interact with that code via forge. I feel what I want to do is straight forward and shouldn't be too hard once I know how to interact with the ore generation code; or am I just being extremely naive? Thanks!
×
×
  • Create New...

Important Information

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