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));
}
}
}