summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/BiomeDef.cpp23
-rw-r--r--src/BiomeDef.h3
-rw-r--r--src/Generating/FinishGen.cpp30
3 files changed, 55 insertions, 1 deletions
diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp
index bef808ef2..ebb45f5e9 100644
--- a/src/BiomeDef.cpp
+++ b/src/BiomeDef.cpp
@@ -223,6 +223,29 @@ bool IsBiomeCold(EMCSBiome a_Biome)
+bool IsBiomeMountain(EMCSBiome a_Biome)
+{
+ switch (a_Biome)
+ {
+ case biExtremeHills:
+ case biExtremeHillsEdge:
+ case biExtremeHillsM:
+ case biExtremeHillsPlus:
+ case biExtremeHillsPlusM:
+ {
+ return true;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+}
+
+
+
+
+
int GetSnowStartHeight(EMCSBiome a_Biome)
{
switch (a_Biome)
diff --git a/src/BiomeDef.h b/src/BiomeDef.h
index 9c7afd478..050c641d3 100644
--- a/src/BiomeDef.h
+++ b/src/BiomeDef.h
@@ -151,6 +151,9 @@ extern bool IsBiomeVeryCold(EMCSBiome a_Biome);
Doesn't report Very Cold biomes, use IsBiomeVeryCold() for those. */
extern bool IsBiomeCold(EMCSBiome a_Biome);
+/** Returns true if the biome is a mountain type */
+extern bool IsBiomeMountain(EMCSBiome a_Biome);
+
/** Returns the height when a biome when a biome starts snowing. */
extern int GetSnowStartHeight(EMCSBiome a_Biome);
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 1593c6928..71be3e497 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -1622,6 +1622,7 @@ const cFinishGenOres::OreInfos & cFinishGenOres::DefaultOverworldOres(void)
{E_BLOCK_REDSTONE_ORE, 0, 16, 8, 7},
{E_BLOCK_DIAMOND_ORE, 0, 15, 1, 7},
{E_BLOCK_LAPIS_ORE, 0, 30, 1, 6},
+ {E_BLOCK_EMERALD_ORE, 0, 32, 11, 1},
};
return res;
}
@@ -1750,6 +1751,24 @@ void cFinishGenOreNests::GenerateOre(
// It does so by making a random XYZ walk and adding ore along the way in cuboids of different (random) sizes
// Only "terraformable" blocks get replaced with ore, all other blocks stay (so the nest can actually be smaller than specified).
+ // If there is a try to generate Emerald ores in chunk where there's no mountains biome abort
+ // There are just four points sampled to avoid searching the whole 16 * 16 Blocks
+ if (a_OreType == E_BLOCK_EMERALD_ORE)
+ {
+ auto BiomeSampleOne = a_ChunkDesc.GetBiome( 4, 4);
+ auto BiomeSampleTwo = a_ChunkDesc.GetBiome( 4, 12);
+ auto BiomeSampleThree = a_ChunkDesc.GetBiome(12, 4);
+ auto BiomeSampleFour = a_ChunkDesc.GetBiome(12, 12);
+
+ if (! (IsBiomeMountain(BiomeSampleOne) ||
+ (IsBiomeMountain(BiomeSampleTwo)) ||
+ (IsBiomeMountain(BiomeSampleThree)) ||
+ (IsBiomeMountain(BiomeSampleFour))))
+ {
+ return;
+ }
+ }
+
auto chunkX = a_ChunkDesc.GetChunkX();
auto chunkZ = a_ChunkDesc.GetChunkZ();
auto & blockTypes = a_ChunkDesc.GetBlockTypes();
@@ -1763,7 +1782,16 @@ void cFinishGenOreNests::GenerateOre(
nestRnd /= cChunkDef::Width;
int BaseY = nestRnd % a_MaxHeight;
nestRnd /= a_MaxHeight;
- int NestSize = a_NestSize + (nestRnd % (a_NestSize / 4)); // The actual nest size may be up to 1 / 4 larger
+ // if the NestSize is smaller then four this breaks
+ int NestSize;
+ if (a_NestSize >= 4)
+ {
+ NestSize = a_NestSize + (nestRnd % (a_NestSize / 4)); // The actual nest size may be up to 1 / 4 larger
+ }
+ else
+ {
+ NestSize = a_NestSize;
+ }
int Num = 0;
while (Num < NestSize)
{