summaryrefslogtreecommitdiffstats
path: root/source/Generating/ChunkDesc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Generating/ChunkDesc.cpp')
-rw-r--r--source/Generating/ChunkDesc.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp
index 81e6851a4..f0927f294 100644
--- a/source/Generating/ChunkDesc.cpp
+++ b/source/Generating/ChunkDesc.cpp
@@ -7,6 +7,7 @@
#include "ChunkDesc.h"
#include "../BlockArea.h"
#include "../Cuboid.h"
+#include "../Noise.h"
@@ -489,6 +490,42 @@ void cChunkDesc::FloorRelCuboid(
+void cChunkDesc::RandomFillRelCuboid(
+ int a_MinX, int a_MaxX,
+ int a_MinY, int a_MaxY,
+ int a_MinZ, int a_MaxZ,
+ BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ int a_RandomSeed, int a_ChanceOutOf10k
+)
+{
+ cNoise Noise(a_RandomSeed);
+ int MinX = std::max(a_MinX, 0);
+ int MinY = std::max(a_MinY, 0);
+ int MinZ = std::max(a_MinZ, 0);
+ int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
+ int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ int rnd = (Noise.IntNoise3DInt(x, y, z) / 7) % 10000;
+ if (rnd <= a_ChanceOutOf10k)
+ {
+ SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta);
+ }
+ }
+ } // for z
+ } // for y
+}
+
+
+
+
+
void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
{
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();