summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-08-09 22:49:40 +0200
committerGitHub <noreply@github.com>2020-08-09 22:49:40 +0200
commitfed03048ad699fb8bc4e216c8ad2ae4d57e5a17f (patch)
treea44291edf9509a237c250a20ce6b521448932186
parentFix arrows preventing block placement (diff)
downloadcuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.tar
cuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.tar.gz
cuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.tar.bz2
cuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.tar.lz
cuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.tar.xz
cuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.tar.zst
cuberite-fed03048ad699fb8bc4e216c8ad2ae4d57e5a17f.zip
-rw-r--r--Server/Plugins/APIDump/APIDesc.lua17
-rw-r--r--src/BiomeDef.cpp23
-rw-r--r--src/BiomeDef.h3
-rw-r--r--src/Generating/FinishGen.cpp30
4 files changed, 72 insertions, 1 deletions
diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua
index a55c2cade..2146a8353 100644
--- a/Server/Plugins/APIDump/APIDesc.lua
+++ b/Server/Plugins/APIDump/APIDesc.lua
@@ -13630,6 +13630,23 @@ end
},
Notes = "Returns true if the biome is very cold (has snow on ground everywhere, turns top water to ice, has snowfall instead of rain everywhere). Doesn't report mildly cold biomes (where it snows above certain elevation), use IsBiomeCold() for those.",
},
+ IsBiomeMountain =
+ {
+ Params =
+ {
+ {
+ Name = "Biome",
+ Type = "EMCSBiome",
+ }
+ },
+ Returns =
+ {
+ {
+ Type = "boolean",
+ },
+ },
+ Notes = "Returns if the biome is a mountain type biome. So mutations of the extreme hills biome"
+ },
IsValidBlock =
{
Params =
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)
{