summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-01 22:52:40 +0100
committerMattes D <github@xoft.cz>2015-03-01 22:52:40 +0100
commit7767af9493fca6a04a1fae45679a471960fcbe99 (patch)
tree6e5ea976a849843eaec3463dc55f0f930a5e8ba0
parentMerge pull request #1780 from DevToaster/master (diff)
parentRemoved trailing whitespace (diff)
downloadcuberite-7767af9493fca6a04a1fae45679a471960fcbe99.tar
cuberite-7767af9493fca6a04a1fae45679a471960fcbe99.tar.gz
cuberite-7767af9493fca6a04a1fae45679a471960fcbe99.tar.bz2
cuberite-7767af9493fca6a04a1fae45679a471960fcbe99.tar.lz
cuberite-7767af9493fca6a04a1fae45679a471960fcbe99.tar.xz
cuberite-7767af9493fca6a04a1fae45679a471960fcbe99.tar.zst
cuberite-7767af9493fca6a04a1fae45679a471960fcbe99.zip
-rw-r--r--src/Generating/ComposableGenerator.cpp5
-rw-r--r--src/Generating/FinishGen.cpp94
-rw-r--r--src/Generating/FinishGen.h23
3 files changed, 122 insertions, 0 deletions
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index bda45ad92..4a670b064 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -616,6 +616,11 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
int MaxDensity = a_IniFile.GetValueSetI("Generator", "VillageMaxDensity", 80);
m_FinishGens.push_back(std::make_shared<cVillageGen>(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, MinDensity, MaxDensity, m_BiomeGen, m_CompositedHeightCache));
}
+ else if (NoCaseCompare(*itr, "Vines") == 0)
+ {
+ int Level = a_IniFile.GetValueSetI("Generator", "VinesLevel", 40);
+ m_FinishGens.push_back(std::make_shared<cFinishGenVines>(Seed, Level));
+ }
else if (NoCaseCompare(*itr, "WaterLakes") == 0)
{
int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index d8fb9c8c0..260253d62 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -244,6 +244,100 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
////////////////////////////////////////////////////////////////////////////////
+// cFinishGenVines
+
+bool cFinishGenVines::IsJungleVariant(EMCSBiome a_Biome)
+{
+ switch (a_Biome)
+ {
+ case biJungle:
+ case biJungleEdge:
+ case biJungleEdgeM:
+ case biJungleHills:
+ case biJungleM:
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+
+
+void cFinishGenVines::GenFinish(cChunkDesc & a_ChunkDesc)
+{
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ if (!IsJungleVariant(a_ChunkDesc.GetBiome(x, z)))
+ {
+ // Current biome isn't a jungle
+ continue;
+ }
+
+ if ((m_Noise.IntNoise2DInt(xx, zz) % 101) < 50)
+ {
+ continue;
+ }
+
+ int Height = a_ChunkDesc.GetHeight(x, z);
+ for (int y = Height; y > m_Level; y--)
+ {
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
+ {
+ // Can't place vines in non-air blocks
+ continue;
+ }
+
+ if ((m_Noise.IntNoise3DInt(xx, y, zz) % 101) < 50)
+ {
+ continue;
+ }
+
+ std::vector<NIBBLETYPE> Places;
+ if ((x + 1 < cChunkDef::Width) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x + 1, y, z)))
+ {
+ Places.push_back(8);
+ }
+
+ if ((x - 1 > 0) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x - 1, y, z)))
+ {
+ Places.push_back(2);
+ }
+
+ if ((z + 1 < cChunkDef::Width) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x, y, z + 1)))
+ {
+ Places.push_back(1);
+ }
+
+ if ((z - 1 > 0) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x, y, z - 1)))
+ {
+ Places.push_back(4);
+ }
+
+ if (Places.size() == 0)
+ {
+ continue;
+ }
+
+ NIBBLETYPE Meta = Places[m_Noise.IntNoise3DInt(xx, y, zz) % Places.size()];
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_VINES, Meta);
+ }
+ }
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// 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 ae6dee590..70696c4f8 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -118,6 +118,29 @@ protected:
+class cFinishGenVines :
+ public cFinishGen
+{
+public:
+ cFinishGenVines(int a_Seed, int a_Level) :
+ m_Noise(a_Seed),
+ m_Level(a_Level)
+ {
+ }
+
+ bool IsJungleVariant(EMCSBiome a_Biome);
+
+protected:
+ cNoise m_Noise;
+ int m_Level;
+
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+};
+
+
+
+
+
class cFinishGenSoulsandRims :
public cFinishGen
{