Skip to content

Commit

Permalink
Implemented a vines finisher that creates vines in jungle biomes
Browse files Browse the repository at this point in the history
  • Loading branch information
NiLSPACE committed Feb 28, 2015
1 parent 24bb911 commit 19d7ec5
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Generating/ComposableGenerator.cpp
Expand Up @@ -616,6 +616,10 @@ 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)
{
m_FinishGens.push_back(cFinishGenPtr(new cFinishGenVines(Seed)));
}
else if (NoCaseCompare(*itr, "WaterLakes") == 0)
{
int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
Expand Down
94 changes: 94 additions & 0 deletions src/Generating/FinishGen.cpp
Expand Up @@ -243,6 +243,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.IntNoise2D(xx, zz) < 0.5)
{
continue;
}

int Height = a_ChunkDesc.GetHeight(x, z);
for (int y = Height; y > 40; y--)
{
if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
{
// Can't place vines in non-air blocks
continue;
}

if (m_Noise.IntNoise3D(xx, y, zz) < 0.5)
{
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:

Expand Down
21 changes: 21 additions & 0 deletions src/Generating/FinishGen.h
Expand Up @@ -118,6 +118,27 @@ class cFinishGenTallGrass :



class cFinishGenVines :
public cFinishGen
{
public:
cFinishGenVines(int a_Seed) :
m_Noise(a_Seed)
{
}

bool IsJungleVariant(EMCSBiome a_Biome);

protected:
cNoise m_Noise;

virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
};





class cFinishGenSoulsandRims :
public cFinishGen
{
Expand Down

0 comments on commit 19d7ec5

Please sign in to comment.