summaryrefslogtreecommitdiffstats
path: root/source/FinishGen.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-03 21:16:09 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-03 21:16:09 +0200
commit358e74ded82c12f49483b4c2adc50c2d1d043051 (patch)
treec1ca3bdd4405fd63a818df01e395af5ef195bf7a /source/FinishGen.cpp
parentTemporary jungle trees (swamp-like), based on code by STR_Warrior). Also vines don't overwrite leaves anymore. (diff)
downloadcuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.tar
cuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.tar.gz
cuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.tar.bz2
cuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.tar.lz
cuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.tar.xz
cuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.tar.zst
cuberite-358e74ded82c12f49483b4c2adc50c2d1d043051.zip
Diffstat (limited to '')
-rw-r--r--source/FinishGen.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/source/FinishGen.cpp b/source/FinishGen.cpp
index eac4a6c02..819bfff76 100644
--- a/source/FinishGen.cpp
+++ b/source/FinishGen.cpp
@@ -283,3 +283,76 @@ void cFinishGenIce::GenFinish(
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cFinishGenLilypads:
+
+int cFinishGenLilypads::GetNumLilypads(const cChunkDef::BiomeMap & a_BiomeMap)
+{
+ int res = 0;
+ for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
+ {
+ if (a_BiomeMap[i] == biSwampland)
+ {
+ res++;
+ }
+ } // for i - a_BiomeMap[]
+ return res / 64;
+}
+
+
+
+
+
+void cFinishGenLilypads::GenFinish(
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
+ cChunkDef::BlockNibbles & a_BlockMeta, // Block meta to read and change
+ cChunkDef::HeightMap & a_HeightMap, // Height map to read and change by the current data
+ const cChunkDef::BiomeMap & a_BiomeMap, // Biomes to adhere to
+ cEntityList & a_Entities, // Entities may be added or deleted
+ cBlockEntityList & a_BlockEntities // Block entities may be added or deleted
+)
+{
+ // Add Lilypads on top of water surface in Swampland
+
+ int NumLilypads = GetNumLilypads(a_BiomeMap);
+ for (int i = 0; i < NumLilypads; i++)
+ {
+ int x = m_Noise.IntNoise3DInt(a_ChunkX + a_ChunkZ, a_ChunkZ, i) % cChunkDef::Width;
+ int z = m_Noise.IntNoise3DInt(a_ChunkX - a_ChunkZ, i, a_ChunkZ) % cChunkDef::Width;
+
+ // Place a lily pad at {x, z} if possible (swampland, empty block, water below):
+ if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biSwampland)
+ {
+ // not swampland
+ continue;
+ }
+ int Height = cChunkDef::GetHeight(a_HeightMap, x, z);
+ if (Height >= cChunkDef::Height)
+ {
+ // Too high up
+ continue;
+ }
+ if (cChunkDef::GetBlock(a_BlockTypes, x, Height + 1, z) != E_BLOCK_AIR)
+ {
+ // not empty block
+ continue;
+ }
+ switch (cChunkDef::GetBlock(a_BlockTypes, x, Height, z))
+ {
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ cChunkDef::SetBlock(a_BlockTypes, x, Height + 1, z, E_BLOCK_LILY_PAD);
+ cChunkDef::SetHeight(a_HeightMap, x, z, Height + 1);
+ break;
+ }
+ } // switch (GetBlock)
+ } // for i
+}
+
+
+
+
+