summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2014-01-17 22:58:01 +0100
committerSTRWarrior <niels.breuker@hotmail.nl>2014-01-17 22:58:01 +0100
commit7c787de2615fb50169e92bbda388c4ef6b29d90a (patch)
treeaa14fd3adac8bb573d03aaf126127c0ced795f7b
parentAdded cFinishGenNetherSprinkleFoliage. (diff)
downloadcuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.tar
cuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.tar.gz
cuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.tar.bz2
cuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.tar.lz
cuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.tar.xz
cuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.tar.zst
cuberite-7c787de2615fb50169e92bbda388c4ef6b29d90a.zip
-rw-r--r--src/Generating/FinishGen.cpp84
-rw-r--r--src/Generating/FinishGen.h1
2 files changed, 63 insertions, 22 deletions
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 8c05b2135..87f00cbab 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -44,46 +44,86 @@ static inline bool IsWater(BLOCKTYPE a_BlockType)
void cFinishGenNetherSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
{
- double ChunkX = a_ChunkDesc.GetChunkX() + 0.5; // We can't devide through 0 so lets add 0.5 to all the chunk coordinates.
- double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.5;
+ 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 Val = m_Noise.CubicNoise2D((float) ChunkX, (float) ChunkZ);
+
+ int Pos;
+ if (Val <= 0)
+ {
+ Pos = (int) (Val + 1) * 16;
+ }
+ else if (Val <= 1)
+ {
+ Pos = (int) Val * 16;
+ }
+ else
+ {
+ Pos = (int) 16 / Val;
+ }
+
+ for (int y = 1; y < cChunkDef::Height; y++)
+ {
+ if (a_ChunkDesc.GetBlockType(Pos, y, Pos) != E_BLOCK_AIR)
+ {
+ continue;
+ }
+ if (!g_BlockIsSolid[a_ChunkDesc.GetBlockType(Pos, y - 1, Pos)]) // Only place on solid blocks
+ {
+ continue;
+ }
+
+ NOISE_DATATYPE BlockType = m_Noise.CubicNoise2D(ChunkX / ChunkZ, y * 0.01f);
+ if (BlockType > 0.08)
+ {
+ TryPlaceClumb(a_ChunkDesc, Pos, y, Pos, E_BLOCK_BROWN_MUSHROOM);
+ }
+ else if (BlockType > -0.18)
+ {
+ TryPlaceClumb(a_ChunkDesc, Pos, y, Pos, E_BLOCK_RED_MUSHROOM);
+ }
+ else if (BlockType > -0.28)
+ {
+ TryPlaceClumb(a_ChunkDesc, Pos, y, Pos, E_BLOCK_FIRE);
+ }
+ }
+}
- for (int z = 0; z < cChunkDef::Width; z++)
+
+
+
+
+void cFinishGenNetherSprinkleFoliage::TryPlaceClumb(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block)
+{
+ a_ChunkDesc.SetBlockType(a_RelX, a_RelY, a_RelZ, a_Block);
+ for (int x = a_RelX - 4; x < a_RelX + 4; x++)
{
- for (int x = 0; x < cChunkDef::Width; x++)
+ float xx = (float) a_ChunkDesc.GetChunkX() * cChunkDef::Width + x;
+ for (int z = a_RelZ - 4; x < a_RelX + 4; x++)
{
- for (int y = 1; y < cChunkDef::Height; y++)
+ float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z;
+ for (int y = a_RelY - 2; y < a_RelY + 2; y++)
{
- if (!g_BlockIsSolid[a_ChunkDesc.GetBlockType(x, y - 1, z)]) // Only place on solid blocks
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks.
{
continue;
}
- if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
+ if (!g_BlockIsSolid[a_ChunkDesc.GetBlockType(x, y - 1, z)]) // Only place on solid blocks
{
continue;
}
- NOISE_DATATYPE Val = m_Noise.CubicNoise1D((float) ((ChunkX * x) * (ChunkZ * z) * y));
- if (Val < -0.98)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_BROWN_MUSHROOM);
- }
- else if (Val < -0.96)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_RED_MUSHROOM);
- }
- else if (Val < -0.94)
+ NOISE_DATATYPE Val = m_Noise.CubicNoise1D(xx * zz * 0.1f / y);
+ if (Val > 1)
{
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_FIRE);
+ a_ChunkDesc.SetBlockType(x, y, z, a_Block);
}
}
}
}
}
-
-
-
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cFinishGenSprinkleFoliage:
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index e6007a174..1e00ffa6c 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -61,6 +61,7 @@ protected:
cNoise m_Noise;
int m_Seed;
+ void TryPlaceClumb(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block);
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;