1
0

Adding Emeralds to generation (#4817)

* Adding Emeralds to generation

* fixed crash

* fixed documentation and changed function name to match others

* forgot to change the name in the doc

* removed debug output - sorry build servers

Co-authored-by: 12xx12 <12xx12100@gmail.com>
This commit is contained in:
12xx12
2020-08-09 22:49:40 +02:00
committed by GitHub
parent f65679d1d4
commit fed03048ad
4 changed files with 72 additions and 1 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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)
{