summaryrefslogtreecommitdiffstats
path: root/source/Generating
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-31 21:05:41 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-31 21:05:41 +0200
commit41e0927843a8060fc381e7695faf4cf8d3c875e6 (patch)
tree4eaf4693230410109dc89cefc14c7dc580137c2c /source/Generating
parentMineShafts: Limited the mineshafts generation into a settable-size cuboid (diff)
downloadcuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.tar
cuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.tar.gz
cuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.tar.bz2
cuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.tar.lz
cuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.tar.xz
cuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.tar.zst
cuberite-41e0927843a8060fc381e7695faf4cf8d3c875e6.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/ChunkDesc.cpp37
-rw-r--r--source/Generating/ChunkDesc.h26
2 files changed, 62 insertions, 1 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();
diff --git a/source/Generating/ChunkDesc.h b/source/Generating/ChunkDesc.h
index a18b26142..5ec3759a9 100644
--- a/source/Generating/ChunkDesc.h
+++ b/source/Generating/ChunkDesc.h
@@ -142,7 +142,31 @@ public:
a_DstType, a_DstMeta
);
}
-
+
+ /// Fills the relative cuboid with specified block with a random chance; allows cuboid out of range of this chunk
+ void 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
+ );
+
+ /// Fills the relative cuboid with specified block with a random chance; allows cuboid out of range of this chunk
+ void RandomFillRelCuboid(
+ const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ int a_RandomSeed, int a_ChanceOutOf10k
+ )
+ {
+ RandomFillRelCuboid(
+ a_RelCuboid.p1.x, a_RelCuboid.p2.x,
+ a_RelCuboid.p1.y, a_RelCuboid.p2.y,
+ a_RelCuboid.p1.z, a_RelCuboid.p2.z,
+ a_BlockType, a_BlockMeta,
+ a_RandomSeed, a_ChanceOutOf10k
+ );
+ }
+
// tolua_end