diff options
Diffstat (limited to 'src/Generating/FinishGen.cpp')
-rw-r--r-- | src/Generating/FinishGen.cpp | 112 |
1 files changed, 109 insertions, 3 deletions
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index ca1798eb5..e9bf69f55 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -393,6 +393,7 @@ std::vector<cFinishGenClumpTopBlock::BiomeInfo> cFinishGenClumpTopBlock::ParseIn cFinishGenClumpTopBlock::ParseConfigurationString(a_IniFile.GetValueSet("Generator", a_ClumpPrefix + "-5", "Swampland; SwamplandM = brownmushroom; redmushroom; blueorchid"), Foliage); cFinishGenClumpTopBlock::ParseConfigurationString(a_IniFile.GetValueSet("Generator", a_ClumpPrefix + "-6", "MushroomIsland; MushroomShore; MegaTaiga; MegaTaigaHills; MegaSpruceTaiga; MegaSpruceTaigaHills = brownmushroom; redmushroom"), Foliage); cFinishGenClumpTopBlock::ParseConfigurationString(a_IniFile.GetValueSet("Generator", a_ClumpPrefix + "-7", "RoofedForest, 1, 5; RoofedForestM, 1, 5 = rosebush; peony; lilac; grass"), Foliage); + cFinishGenClumpTopBlock::ParseConfigurationString(a_IniFile.GetValueSet("Generator", a_ClumpPrefix + "-8", "MegaTaiga; MegaTaigaHills = deadbush"), Foliage); } return Foliage; @@ -553,7 +554,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) // Choose what long grass meta we should use: int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; - if (GrassType < 60) + if ((GrassType < 60) && CanGrassGrow(a_ChunkDesc.GetBiome(x, z))) { a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, E_META_TALL_GRASS_GRASS); } @@ -566,8 +567,15 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) // If double long grass we have to choose what type we should use: if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) { - NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? - E_META_BIG_FLOWER_DOUBLE_TALL_GRASS : E_META_BIG_FLOWER_LARGE_FERN; + NIBBLETYPE Meta; + if (CanGrassGrow(a_ChunkDesc.GetBiome(x, z))) + { + Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? E_META_BIG_FLOWER_DOUBLE_TALL_GRASS : E_META_BIG_FLOWER_LARGE_FERN; + } + else + { + Meta = E_META_BIG_FLOWER_LARGE_FERN; + } if ((Meta != E_META_BIG_FLOWER_LARGE_FERN) || CanLargeFernGrow(a_ChunkDesc.GetBiome(x, z))) { @@ -680,6 +688,26 @@ int cFinishGenTallGrass::GetBiomeDensity(EMCSBiome a_Biome) +bool cFinishGenTallGrass::CanGrassGrow(EMCSBiome a_Biome) +{ + switch (a_Biome) + { + case biMegaTaiga: + case biMegaTaigaHills: + { + return false; + } + default: + { + return true; + } + } +} + + + + + //////////////////////////////////////////////////////////////////////////////// // cFinishGenVines @@ -2185,3 +2213,81 @@ void cFinishGenOrePockets::imprintSphere( +cFinishGenForestRocks::cFinishGenForestRocks(int a_Seed, cIniFile & a_IniFile) : m_Noise(a_Seed) +{ +} + + + + + +void cFinishGenForestRocks::GenFinish(cChunkDesc & a_ChunkDesc) +{ + // Choose random position in chunk and place boulder around it + auto Pos = Vector3i( + m_Noise.IntNoise2DInt(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()) % cChunkDef::Width, + 0, + m_Noise.IntNoise2DInt(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()) % cChunkDef::Width + ); + Pos.y = a_ChunkDesc.GetHeight(Pos.x, Pos.z) % cChunkDef::Height; + + auto Biome = a_ChunkDesc.GetBiome(Pos.x, Pos.z); + if ((Biome != biMegaTaiga) && (Biome != biMegaTaigaHills)) + { + return; + } + + // Determines the size of the boulder + const int TwoLimit = 70; + const int ThreeLimit = 90; + + auto RadiusChance = m_Noise.IntNoise2DInt(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()) % 100; + int Radius = 1; + if (RadiusChance > TwoLimit && RadiusChance <= ThreeLimit) + { + Radius = 2; + } + else if (RadiusChance > ThreeLimit) + { + Radius = 3; + } + + Pos.x = Clamp(Pos.x, Radius, cChunkDef::Width - Radius - 1); + Pos.z = Clamp(Pos.z, Radius, cChunkDef::Width - Radius - 1); + + auto StartBlock = a_ChunkDesc.GetBlockType(Pos.x, Pos.y, Pos.z); + while (!((StartBlock == E_BLOCK_DIRT) || (StartBlock == E_BLOCK_GRASS))) + { + Pos.y -= 1; + if (!cChunkDef::IsValidRelPos(Pos.addedY(-Radius))) + { + return; + } + StartBlock = a_ChunkDesc.GetBlockType(Pos.x, Pos.y, Pos.z); + } + + + Pos.y -= Radius - 1; + // Pos.y = Clamp(Pos.y - m_Noise.IntNoise2DInt(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()) % Radius + 1, 0, cChunkDef::Height); + + for (int x = -Radius; x <= Radius; x++) + { + for (int y = -Radius; y <= Radius; y++) + { + for (int z = -Radius; z <= Radius; z++) + { + if (!cChunkDef::IsValidRelPos({ Pos.x + x, Pos.y + y, Pos.z + z })) + { + continue; + } + + if (Vector3d(x, y, z).SqrLength() > Radius * Radius + 1) + { + continue; + } + + a_ChunkDesc.SetBlockTypeMeta(Pos.x + x, Pos.y + y, Pos.z + z, E_BLOCK_MOSSY_COBBLESTONE, 0); + } + } + } +} |