Randomize potential oil biome spawns on worldseed

Also reduced Oil Ocean Biome chances again.

Previously it was using the same noise field for all seeds. Now it
randomly offsets the noise field based on the world seed. Its not truly
random, but at least you won't be able to travel to the same coordinates
in every world and find an Oil Biome.
This commit is contained in:
CovertJaguar 2013-06-10 13:52:14 -07:00
parent f404eccb3d
commit 8d5e520c96
4 changed files with 98 additions and 54 deletions

View file

@ -16,14 +16,28 @@ public class BiomeInitializer {
@ForgeSubscribe
public void initBiomes(WorldTypeEvent.InitBiomeGens event) {
if (BuildCraftEnergy.biomeOilDesert != null) {
event.newBiomeGens[0] = new GenLayerAddOilDesert(1500L, event.newBiomeGens[0]);
event.newBiomeGens[1] = new GenLayerAddOilDesert(1500L, event.newBiomeGens[1]);
event.newBiomeGens[2] = new GenLayerAddOilDesert(1500L, event.newBiomeGens[2]);
event.newBiomeGens[0] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[0]);
event.newBiomeGens[1] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[1]);
event.newBiomeGens[2] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[2]);
}
if (BuildCraftEnergy.biomeOilOcean != null) {
event.newBiomeGens[0] = new GenLayerAddOilOcean(1500L, event.newBiomeGens[0]);
event.newBiomeGens[1] = new GenLayerAddOilOcean(1500L, event.newBiomeGens[1]);
event.newBiomeGens[2] = new GenLayerAddOilOcean(1500L, event.newBiomeGens[2]);
event.newBiomeGens[0] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[0]);
event.newBiomeGens[1] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[1]);
event.newBiomeGens[2] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[2]);
}
// int range = GenLayerBiomeReplacer.OFFSET_RANGE;
// Random rand = new Random(event.seed);
// double xOffset = rand.nextInt(range) - (range / 2);
// double zOffset = rand.nextInt(range) - (range / 2);
// double noiseScale = GenLayerAddOilOcean.NOISE_FIELD_SCALE;
// double noiseThreshold = GenLayerAddOilOcean.NOISE_FIELD_THRESHOLD;
// for (int x = -5000; x < 5000; x += 128) {
// for (int z = -5000; z < 5000; z += 128) {
// if (SimplexNoise.noise((x + xOffset) * noiseScale, (z + zOffset) * noiseScale) > noiseThreshold) {
// System.out.printf("Oil Biome: %d, %d\n", x, z);
// }
// }
// }
}
}

View file

@ -3,38 +3,22 @@ package buildcraft.energy.worldgen;
import buildcraft.BuildCraftEnergy;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class GenLayerAddOilDesert extends GenLayer {
public class GenLayerAddOilDesert extends GenLayerBiomeReplacer {
public GenLayerAddOilDesert(final long size, final GenLayer genLayer) {
super(size);
parent = genLayer;
protected static final double NOISE_FIELD_SCALE = 0.001;
protected static final double NOISE_FIELD_THRESHOLD = 0.7;
public GenLayerAddOilDesert(final long worldSeed, final long seed, final GenLayer parent) {
super(worldSeed, seed, parent, NOISE_FIELD_SCALE, NOISE_FIELD_THRESHOLD, BuildCraftEnergy.biomeOilDesert.biomeID);
}
@Override
public int[] getInts(final int x, final int y, final int width, final int length) {
final int[] inputBiomeIDs = parent.getInts(x - 1, y - 1, width + 2, length + 2);
final int[] outputBiomeIDs = IntCache.getIntCache(width * length);
for (int yIter = 0; yIter < length; ++yIter) {
for (int xIter = 0; xIter < width; ++xIter) {
initChunkSeed(xIter + x, yIter + y);
final int currentBiomeId = inputBiomeIDs[xIter + 1 + (yIter + 1) * (width + 2)];
if (currentBiomeId == BiomeGenBase.desert.biomeID
&& SimplexNoise.noise((xIter + x) * 0.001, (yIter + y) * 0.001) > 0.7) {
outputBiomeIDs[xIter + yIter * width] = BuildCraftEnergy.biomeOilDesert.biomeID;
} else {
outputBiomeIDs[xIter + yIter * width] = currentBiomeId;
}
}
}
return outputBiomeIDs;
protected boolean canReplaceBiome(int biomeId) {
return biomeId == BiomeGenBase.desert.biomeID;
}
}

View file

@ -3,38 +3,22 @@ package buildcraft.energy.worldgen;
import buildcraft.BuildCraftEnergy;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class GenLayerAddOilOcean extends GenLayer {
public class GenLayerAddOilOcean extends GenLayerBiomeReplacer {
public GenLayerAddOilOcean(final long size, final GenLayer genLayer) {
super(size);
parent = genLayer;
public static final double NOISE_FIELD_SCALE = 0.0005;
public static final double NOISE_FIELD_THRESHOLD = 0.9;
public GenLayerAddOilOcean(final long worldSeed, final long seed, final GenLayer parent) {
super(worldSeed, seed, parent, NOISE_FIELD_SCALE, NOISE_FIELD_THRESHOLD, BuildCraftEnergy.biomeOilOcean.biomeID);
}
@Override
public int[] getInts(final int x, final int y, final int width, final int length) {
final int[] inputBiomeIDs = parent.getInts(x - 1, y - 1, width + 2, length + 2);
final int[] outputBiomeIDs = IntCache.getIntCache(width * length);
for (int yIter = 0; yIter < length; ++yIter) {
for (int xIter = 0; xIter < width; ++xIter) {
initChunkSeed(xIter + x, yIter + y);
final int currentBiomeId = inputBiomeIDs[xIter + 1 + (yIter + 1) * (width + 2)];
if (currentBiomeId == BiomeGenBase.ocean.biomeID
&& SimplexNoise.noise((xIter + x) * 0.0006, (yIter + y) * 0.0006) > 0.85) {
outputBiomeIDs[xIter + yIter * width] = BuildCraftEnergy.biomeOilOcean.biomeID;
} else {
outputBiomeIDs[xIter + yIter * width] = currentBiomeId;
}
}
}
return outputBiomeIDs;
protected boolean canReplaceBiome(int biomeId) {
return biomeId == BiomeGenBase.ocean.biomeID;
}
}

View file

@ -0,0 +1,62 @@
package buildcraft.energy.worldgen;
import java.util.Random;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public abstract class GenLayerBiomeReplacer extends GenLayer {
public static final int OFFSET_RANGE = 500000;
protected final double xOffset;
protected final double zOffset;
protected final double noiseScale;
protected final double noiseThreshold;
protected final int newBiomeId;
/**
*
* @param worldSeed
* @param seed
* @param parent
* @param noiseScale The scale of the noise field, smaller numbers zoom in
* the noise field.
* @param noiseThreshold The strength the field must reach to replace the
* biome. Larger numbers result in smaller patches.
* @param newBiomeId
*/
public GenLayerBiomeReplacer(final long worldSeed, final long seed, final GenLayer parent, double noiseScale, double noiseThreshold, int newBiomeId) {
super(seed);
this.parent = parent;
this.noiseScale = noiseScale;
this.noiseThreshold = noiseThreshold;
this.newBiomeId = newBiomeId;
Random rand = new Random(worldSeed);
xOffset = rand.nextInt(OFFSET_RANGE) - (OFFSET_RANGE / 2);
zOffset = rand.nextInt(OFFSET_RANGE) - (OFFSET_RANGE / 2);
}
protected abstract boolean canReplaceBiome(int biomeId);
@Override
public int[] getInts(final int x, final int z, final int width, final int length) {
final int[] inputBiomeIDs = parent.getInts(x - 1, z - 1, width + 2, length + 2);
final int[] outputBiomeIDs = IntCache.getIntCache(width * length);
for (int xIter = 0; xIter < width; ++xIter) {
for (int zIter = 0; zIter < length; ++zIter) {
initChunkSeed(xIter + x, zIter + z);
final int currentBiomeId = inputBiomeIDs[xIter + 1 + (zIter + 1) * (width + 2)];
if (canReplaceBiome(currentBiomeId) && SimplexNoise.noise((xIter + x + xOffset) * noiseScale, (zIter + z + zOffset) * noiseScale) > noiseThreshold) {
outputBiomeIDs[xIter + zIter * width] = newBiomeId;
// System.out.printf("Replaced Biome at %d, %d\n", xIter + x, zIter + z);
} else {
outputBiomeIDs[xIter + zIter * width] = currentBiomeId;
}
}
}
return outputBiomeIDs;
}
}