diff options
author | 12xx12 <44411062+12xx12@users.noreply.github.com> | 2020-09-19 18:51:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 18:51:26 +0200 |
commit | 1a211b6c46b1f71d42799b2f1dabb1790174b81f (patch) | |
tree | e2e7a937c41f8680ed9c16460f65de6b850e061a | |
parent | added 12xx12 to CONTRIBUTORS (#4896) (diff) | |
download | cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.tar cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.tar.gz cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.tar.bz2 cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.tar.lz cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.tar.xz cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.tar.zst cuberite-1a211b6c46b1f71d42799b2f1dabb1790174b81f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Generating/Trees.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index cd2748ddd..0d6a40291 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "Trees.h" #include "../BlockType.h" +#include "../World.h" @@ -58,7 +59,7 @@ static const Vector3d & pickBranchDirection(const cNoise a_Noise, Vector3i a_Blo } }; - size_t index = static_cast<size_t>(a_Noise.IntNoise3DInt(a_BlockPos.x, a_BlockPos.y + a_Seq, a_BlockPos.z)) % directions.size(); + size_t index = static_cast<size_t>(a_Noise.IntNoise3DInt(a_BlockPos * a_Seq)) % directions.size(); return directions[index]; } @@ -1266,11 +1267,12 @@ void GetLargeJungleTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, s {2, 1, 2}, {2, 0, 2}, // East face }; - int Height = 20 + (a_Noise.IntNoise3DInt(a_BlockPos.addedXZ(32 * a_Seq, 32 * a_Seq)) / 11) % 12; + int Height = 10 + ((a_Noise.IntNoise3DInt(a_BlockPos.addedXZ(32 * a_Seq, 32 * a_Seq)) / 11) % 20); // 10 < Height < 29 a_LogBlocks.reserve(static_cast<size_t>(Height) * 4); a_OtherBlocks.reserve(2 * ARRAYCOUNT(BigO5Jungle) + ARRAYCOUNT(BigO4Jungle) + ARRAYCOUNT(BigO3Jungle) + static_cast<size_t>(Height) * 4 + 50); + // Generates the main trunk for (int i = 0; i < Height; i++) { a_LogBlocks.push_back(sSetBlock(a_BlockPos.addedY(i), E_BLOCK_LOG, E_META_LOG_JUNGLE)); @@ -1288,7 +1290,6 @@ void GetLargeJungleTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, s a_OtherBlocks.push_back(sSetBlock(a_BlockPos.addedXZ(VinesTrunk[j].x, VinesTrunk[j].z).addedY(i), E_BLOCK_VINES, VinesTrunk[j].Meta)); } } - int hei = a_BlockPos.y + Height - 2; // Prevent floating trees by placing dirt under them for (int i = 1; i < 5; i++) @@ -1299,26 +1300,41 @@ void GetLargeJungleTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, s a_OtherBlocks.push_back(sSetBlock(a_BlockPos.addedY(-i).addedXZ(1, 1), E_BLOCK_DIRT, E_META_DIRT_NORMAL)); } - int numBranches = (a_Noise.IntNoise2DInt(a_BlockPos.x * a_Seq, a_BlockPos.z * a_Seq) / 11) % 3 + 1; - int branchStartHeight = 8 + Height % 11; - int branchInterval = (Height - branchStartHeight) / numBranches; - for (int i = branchStartHeight; i < (Height - 6); i += branchInterval) + int NumBranches = std::max( + (a_Noise.IntNoise2DInt(a_BlockPos.x * a_Seq, a_BlockPos.z * a_Seq) / 10) % 4, // The Original Calculation + FloorC(Height / 10.0f) // Just to assure that no massive trees spawn with just one branch + ); + int BranchStartHeight = 6 + Height % 5; // 6 < BranchStartHeight < 10 + int BranchInterval = (Height - 6 - BranchStartHeight) / NumBranches; + for (int i = BranchStartHeight; i < (Height - 6); i += BranchInterval) // Stop 6 blocks before reaching the top { // Get a direction for the trunk to go to. Vector3d BranchStartDirection = pickBranchDirection(a_Noise, a_BlockPos.addedY(i), a_Seq); Vector3d BranchDirection = pickBranchDirection(a_Noise, a_BlockPos.addedY(i * a_Seq), a_Seq) / 3; - int BranchLength = 2 + a_Noise.IntNoise3DInt(a_BlockPos * a_Seq) % 2; Vector3i BranchEndPosition = GetTreeBranch(E_BLOCK_LOG, E_META_LOG_JUNGLE, a_BlockPos.addedY(i), BranchLength, BranchStartDirection, BranchDirection, a_LogBlocks).Floor(); - PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y, BranchEndPosition.z, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); - PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y + 1, BranchEndPosition.z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); - a_OtherBlocks.push_back(sSetBlock(BranchEndPosition.x, BranchEndPosition.y + 1, BranchEndPosition.z, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE)); + + // There's a chance that there is a third leaf level on a branch + if ((a_Noise.IntNoise3DInt(a_BlockPos.x * a_Seq, a_BlockPos.y * a_Seq, a_BlockPos.z * a_Seq) % 4) == 0) // A quarter chance + { + PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y, BranchEndPosition.z, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); + PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y + 1, BranchEndPosition.z, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); + PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y + 2, BranchEndPosition.z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); + a_OtherBlocks.push_back(sSetBlock(BranchEndPosition.x, BranchEndPosition.y + 2, BranchEndPosition.z, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE)); + } + else + { + PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y, BranchEndPosition.z, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); + PushCoordBlocks(BranchEndPosition.x, BranchEndPosition.y + 1, BranchEndPosition.z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); + a_OtherBlocks.push_back(sSetBlock(BranchEndPosition.x, BranchEndPosition.y + 1, BranchEndPosition.z, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE)); + } } // Place the canopy. + int CanopyHeight = a_BlockPos.y + Height - 2; for (size_t i = 0; i < ARRAYCOUNT(BigOJungleLayers); i++) { - PushCoordBlocks(a_BlockPos.x, hei++, a_BlockPos.z, a_OtherBlocks, BigOJungleLayers[i].Coords, BigOJungleLayers[i].Count, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); + PushCoordBlocks(a_BlockPos.x, CanopyHeight++, a_BlockPos.z, a_OtherBlocks, BigOJungleLayers[i].Coords, BigOJungleLayers[i].Count, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE); } } |