Skip to content

Commit

Permalink
Fix math and biomes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskarth committed May 13, 2021
1 parent fc93dd5 commit 17aa241
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ private void generateNoiseCaves(int chunkX, int chunkZ, Block[] blocks, byte[] m
}

private void generateNoiseCavesNoise(int chunkX, int chunkZ) {
BiomeGenBase[] biomes = null;
biomes = this.world.getWorldChunkManager().getBiomesForGeneration(biomes, chunkX * 4 - 2, chunkZ * 4 - 2, 10, 10);
int i = 0;

for (int x = 0; x < 5; ++x) {
Expand All @@ -298,23 +300,23 @@ private void generateNoiseCavesNoise(int chunkX, int chunkZ) {
// We iterate the entire area to ensure we're not anywhere even near an ocean
for (int x1 = -2; x1 <= 2; ++x1) {
for (int z1 = -2; z1 <= 2; ++z1) {
BiomeGenBase biome = this.biomes[x + x1 + 2 + (z + z1 + 2) * 10];
BiomeGenBase biome = biomes[x + x1 + 2 + (z + z1 + 2) * 10];

// Disable in oceans
lowestScaledDepth = Math.min(lowestScaledDepth, biome.rootHeight);
}
}

// Each unit of depth roughly corresponds to 16 blocks, but we use 20 for good measure
// We start reduction at 56 instead of 64, the sea level, as it's
// We start reduction at 56 instead of 64, the sea level, to give ourselves some more room.
double startLevel = 56 + (lowestScaledDepth * 20);
int sub = (int) (startLevel / 8);

for (int y = 0; y < 33; y++) {
double caveNoise = this.noiseCaves.sample(this.terrainNoise[i], y * 8, chunkZ * 16 + (z * 4), chunkX * 16 + (x * 4));

// Reduce so we don't break the surface
caveNoise = supercoder79.greggen.util.MathHelper.clampedLerp(caveNoise, 20, (y - sub) / 2.0);
caveNoise = supercoder79.greggen.util.MathHelper.clampedLerp(caveNoise, (lowestScaledDepth * -30) + 20, (y - sub + 2) / 2.0);

this.caveNoise[i] = caveNoise;
i++;
Expand Down

0 comments on commit 17aa241

Please sign in to comment.