Skip to content

Commit

Permalink
Make 3d noise map gen themes use biomes too
Browse files Browse the repository at this point in the history
Also log less messages when generating a realistic themed map
  • Loading branch information
UnknownShadow200 committed Jan 15, 2023
1 parent 2ee4c4d commit c839f35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
28 changes: 19 additions & 9 deletions MCGalaxy/Generator/LibNoise/AdvNoiseGen.cs
Expand Up @@ -58,17 +58,17 @@ public static class AdvNoiseGen

static bool GenPerlin3D(Player p, Level lvl, string seed) {
Perlin module = new Perlin();
return Gen3D(lvl, module, seed);
return Gen3D(p, lvl, module, seed);
}

static bool GenPerlin3DYAdjust(Player p, Level lvl, string seed) {
Perlin module = new Perlin();
return Gen3DYAdjust(lvl, module, seed);
return Gen3DYAdjust(p, lvl, module, seed);
}

static bool GenBillow3D(Player p, Level lvl, string seed) {
Billow module = new Billow();
return Gen3D(lvl, module, seed);
return Gen3D(p, lvl, module, seed);
}

#endregion
Expand Down Expand Up @@ -112,35 +112,45 @@ public static class AdvNoiseGen
return true;
}

static bool Gen3D(Level lvl, IModule module, string seed) {
module.Seed = MapGen.MakeInt(seed);
static bool Gen3D(Player p, Level lvl, IModule module, string seed) {
module.Frequency = 1 / 100.0;

MapGenBiomeName theme = MapGenBiomeName.Forest;
if (!MapGen.ParseArgs(p, seed, out module.Seed, ref theme)) return false;
MapGenBiome biome = MapGenBiome.Get(theme);

int width = lvl.Width, height = lvl.Height, length = lvl.Length;
for (int y = 0; y < height; y++)
for (int z = 0; z < length; ++z)
for (int x = 0; x < width; ++x)
{
double value = module.GetValue(x, y, z);
if (value >= 0.1)
lvl.SetTile((ushort)x, (ushort)y, (ushort)z, Block.Grass);
lvl.SetTile((ushort)x, (ushort)y, (ushort)z, biome.Surface);
}

biome.ApplyEnv(lvl.Config);
return true;
}

static bool Gen3DYAdjust(Level lvl, IModule module, string seed) {
module.Seed = MapGen.MakeInt(seed);
static bool Gen3DYAdjust(Player p, Level lvl, IModule module, string seed) {
module.Frequency = 1 / 100.0;

MapGenBiomeName theme = MapGenBiomeName.Forest;
if (!MapGen.ParseArgs(p, seed, out module.Seed, ref theme)) return false;
MapGenBiome biome = MapGenBiome.Get(theme);

int width = lvl.Width, height = lvl.Height, length = lvl.Length;
for (int y = 0; y < height; y++)
for (int z = 0; z < length; ++z)
for (int x = 0; x < width; ++x)
{
double value = Math.Floor((module.GetValue(x, y, z) + 2) * 10);
if (value > 30 * y / height)
lvl.SetTile((ushort)x, (ushort)y, (ushort)z, Block.Grass);
lvl.SetTile((ushort)x, (ushort)y, (ushort)z, biome.Surface);
}

biome.ApplyEnv(lvl.Config);
return true;
}
}
Expand Down
5 changes: 1 addition & 4 deletions MCGalaxy/Generator/Realistic/RealisticMapGen.cs
Expand Up @@ -66,15 +66,13 @@ public sealed class RealisticMapGen

GenerateFault(terrain, lvl);
FilterAverage(lvl);
Logger.Log(LogType.SystemActivity, "Creating overlay");
Logger.Log(LogType.SystemActivity, "Generating terrain..");
GeneratePerlinNoise(overlay, lvl);

if (args.GenOverlay2) {
Logger.Log(LogType.SystemActivity, "Planning trees");
GeneratePerlinNoise(overlayT, lvl);
}

Logger.Log(LogType.SystemActivity, "Converting height map, and applying overlays");
float rangeLo = args.RangeLow;
float rangeHi = args.RangeHigh;
treeDens = args.TreeDensity;
Expand Down Expand Up @@ -270,7 +268,6 @@ public sealed class RealisticMapGen

//applys the average filter
void FilterAverage(Level lvl) {
Logger.Log(LogType.SystemActivity, "Applying average filtering");
float[] filtered = new float[terrain.Length];

for (int i = 0; i < filtered.Length; i++)
Expand Down

0 comments on commit c839f35

Please sign in to comment.