summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Generating/ComposableGenerator.cpp10
-rw-r--r--src/Generating/FinishGen.cpp120
-rw-r--r--src/Generating/FinishGen.h23
3 files changed, 150 insertions, 3 deletions
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index 87c4d2c52..cfa7e9c6f 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -367,10 +367,10 @@ void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
int Seed = m_ChunkGenerator.GetSeed();
- AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
-
eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
- AStringVector Str = StringSplitAndTrim(Structures, ",");
+
+ AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
+ AStringVector Str = StringSplitAndTrim(Finishers, ",");
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
{
// Finishers, alpha-sorted:
@@ -396,6 +396,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
}
+ else if (NoCaseCompare(*itr, "NetherClumpFoliage") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenNetherClumpFoliage(Seed));
+ }
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
{
m_FinishGens.push_back(new cFinishGenPreSimulator);
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 4915e6818..02045f76a 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -13,6 +13,7 @@
#include "../Noise.h"
#include "../BlockID.h"
#include "../Simulator/FluidSimulator.h" // for cFluidSimulator::CanWashAway()
+#include "../Simulator/FireSimulator.h"
#include "../World.h"
@@ -40,6 +41,125 @@ static inline bool IsWater(BLOCKTYPE a_BlockType)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cFinishGenNetherClumpFoliage:
+
+void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
+{
+ double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates.
+ double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1;
+
+ NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f));
+ NOISE_DATATYPE Val2 = m_Noise.CubicNoise2D((float) (ChunkX / ChunkZ / 0.01f), (float) (ChunkZ * ChunkX / 0.01f));
+
+ if (Val1 < 0)
+ {
+ Val1 = -Val1;
+ }
+
+ if (Val2 < 0)
+ {
+ Val2 = -Val2;
+ }
+
+ int PosX, PosZ;
+ // Calculate PosX
+ if (Val1 <= 1)
+ {
+ PosX = (int) floor(Val1 * 16);
+ }
+ else
+ {
+ PosX = (int) floor(16 / Val1);
+ }
+
+ // Calculate PosZ
+ if (Val2 <= 1)
+ {
+ PosZ = (int) floor(Val2 * 16);
+ }
+ else
+ {
+ PosZ = (int) floor(16 / Val2);
+ }
+
+ for (int y = 1; y < cChunkDef::Height; y++)
+ {
+ if (a_ChunkDesc.GetBlockType(PosX, y, PosZ) != E_BLOCK_AIR)
+ {
+ continue;
+ }
+ if (!g_BlockIsSolid[a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ)]) // Only place on solid blocks
+ {
+ continue;
+ }
+
+ NOISE_DATATYPE BlockType = m_Noise.CubicNoise1D((float) (ChunkX * ChunkZ) / (y * 0.1f));
+ if (BlockType < -0.7)
+ {
+ TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_BROWN_MUSHROOM);
+ }
+ else if (BlockType < 0)
+ {
+ TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_RED_MUSHROOM);
+ }
+ else if (BlockType < 0.7)
+ {
+ TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_FIRE);
+ }
+ }
+}
+
+
+
+
+
+void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block)
+{
+ bool IsFireBlock = a_Block == E_BLOCK_FIRE;
+
+ for (int x = a_RelX - 4; x < a_RelX + 4; x++)
+ {
+ float xx = (float) a_ChunkDesc.GetChunkX() * cChunkDef::Width + x;
+ for (int z = a_RelZ - 4; z < a_RelZ + 4; z++)
+ {
+ float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z;
+ for (int y = a_RelY - 2; y < a_RelY + 2; y++)
+ {
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks.
+ {
+ continue;
+ }
+
+ BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z);
+ if (!g_BlockIsSolid[BlockBelow]) // Only place on solid blocks
+ {
+ continue;
+ }
+
+ if (IsFireBlock) // don't place fire on non-forever burning blocks.
+ {
+ if (!cFireSimulator::DoesBurnForever(BlockBelow))
+ {
+ continue;
+ }
+ }
+
+
+ NOISE_DATATYPE Val = m_Noise.CubicNoise2D(xx, zz);
+ if (Val < -0.70)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, a_Block);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cFinishGenSprinkleFoliage:
bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ)
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index d89ffed15..2e5732929 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -47,6 +47,28 @@ protected:
+class cFinishGenNetherClumpFoliage :
+ public cFinishGen
+{
+public:
+ cFinishGenNetherClumpFoliage(int a_Seed) :
+ m_Noise(a_Seed),
+ m_Seed(a_Seed)
+ {
+ }
+
+protected:
+ cNoise m_Noise;
+ int m_Seed;
+
+ void TryPlaceClump(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block);
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
+
class cFinishGenSprinkleFoliage :
public cFinishGen
{
@@ -117,6 +139,7 @@ public:
{
}
+ int GetLevel(void) const { return m_Level; }
protected:
int m_Level;