diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2015-02-28 22:37:33 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2015-02-28 22:37:33 +0100 |
commit | 19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d (patch) | |
tree | 273cef95f3c52e462dc5e196f79d2279b1df4d23 /src/Generating/FinishGen.cpp | |
parent | Merge pull request #1769 from mc-server/snowweather (diff) | |
download | cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.tar cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.tar.gz cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.tar.bz2 cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.tar.lz cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.tar.xz cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.tar.zst cuberite-19d7ec51a0a4cb70d5f1e4a62fcf3e944e072a5d.zip |
Diffstat (limited to 'src/Generating/FinishGen.cpp')
-rw-r--r-- | src/Generating/FinishGen.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index d8fb9c8c0..5b8965906 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.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: bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ) |