diff options
Diffstat (limited to 'src/Generating')
-rw-r--r-- | src/Generating/ComposableGenerator.cpp | 7 | ||||
-rw-r--r-- | src/Generating/FinishGen.cpp | 112 | ||||
-rw-r--r-- | src/Generating/FinishGen.h | 12 |
3 files changed, 127 insertions, 4 deletions
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index a688e7de6..8d3f361bd 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -230,7 +230,8 @@ void cComposableGenerator::InitializeGeneratorDefaults(cIniFile & a_IniFile, eDi "NaturalPatches, " "PreSimulator, " "Animals, " - "OverworldClumpFlowers" + "OverworldClumpFlowers, " + "ForestRocks" ); break; } // dimOverworld @@ -463,6 +464,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) Gen->Init(Pillars, Radius); m_FinishGens.push_back(std::move(Gen)); } + else if (NoCaseCompare(finisher, "ForestRocks") == 0) + { + m_FinishGens.push_back(cFinishGenPtr(new cFinishGenForestRocks(m_Seed, a_IniFile))); + } else if (NoCaseCompare(finisher, "GlowStone") == 0) { m_FinishGens.push_back(std::make_unique<cFinishGenGlowStone>(m_Seed)); 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); + } + } + } +} diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 76b58e60d..dae05ffa8 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -184,6 +184,7 @@ protected: static bool CanFernGrow(EMCSBiome a_Biome); static bool CanLargeFernGrow(EMCSBiome a_Biome); static int GetBiomeDensity(EMCSBiome a_Biome); + static bool CanGrassGrow(EMCSBiome a_Biome); }; @@ -633,3 +634,14 @@ protected: + +class cFinishGenForestRocks: + public cFinishGen +{ +public: + cFinishGenForestRocks(int a_Seed, cIniFile & a_IniFile); + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + +private: + cNoise m_Noise; +}; |