diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-07 23:07:21 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-07 23:07:21 +0200 |
commit | 876014b8e8941f6de69f07e3b4cc354e9bdf3e57 (patch) | |
tree | f6fab0234d43774675f4a4d69b3c711b6aaafb33 /source/cWorld.cpp | |
parent | Nightbuild: bindings are automatically update before the build (diff) | |
download | cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.tar cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.tar.gz cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.tar.bz2 cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.tar.lz cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.tar.xz cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.tar.zst cuberite-876014b8e8941f6de69f07e3b4cc354e9bdf3e57.zip |
Diffstat (limited to 'source/cWorld.cpp')
-rw-r--r-- | source/cWorld.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp index 7288dc303..fb2517a80 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -844,6 +844,94 @@ void cWorld::GrowTreeImage(const sSetBlockVector & a_Blocks) +void cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
+ switch (BlockType)
+ {
+ case E_BLOCK_CROPS:
+ {
+ if (BlockMeta < 7)
+ {
+ FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
+ }
+ break;
+ }
+
+ case E_BLOCK_MELON_STEM:
+ case E_BLOCK_PUMPKIN_STEM:
+ {
+ if (BlockMeta < 7)
+ {
+ FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
+ }
+ else
+ {
+ GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, BlockType);
+ }
+ break;
+ }
+
+ case E_BLOCK_SAPLING:
+ {
+ GrowTreeFromSapling(a_BlockX, a_BlockY, a_BlockZ, BlockMeta);
+ break;
+ }
+
+ case E_BLOCK_GRASS:
+ {
+ MTRand r1;
+ for (int i = 0; i < 60; i++)
+ {
+ int OfsX = (r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3;
+ int OfsY = r1.randInt(3) + r1.randInt(3) - 3;
+ int OfsZ = (r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3;
+ BLOCKTYPE Ground = GetBlock(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ);
+ if (Ground != E_BLOCK_GRASS)
+ {
+ continue;
+ }
+ BLOCKTYPE Above = GetBlock(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ);
+ if (Above != E_BLOCK_AIR)
+ {
+ continue;
+ }
+ BLOCKTYPE SpawnType;
+ NIBBLETYPE SpawnMeta = 0;
+ switch (r1.randInt(10))
+ {
+ case 0: SpawnType = E_BLOCK_YELLOW_FLOWER; break;
+ case 1: SpawnType = E_BLOCK_RED_ROSE; break;
+ default:
+ {
+ SpawnType = E_BLOCK_TALL_GRASS;
+ SpawnMeta = E_META_TALL_GRASS_GRASS;
+ break;
+ }
+ } // switch (random spawn block)
+ FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, SpawnType, SpawnMeta);
+ } // for i - 50 times
+ break;
+ }
+ } // switch (BlockType)
+}
+
+
+
+
+
+void cWorld::GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockType)
+{
+ MTRand Rand;
+ m_ChunkMap->GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, Rand);
+}
+
+
+
+
+
int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
{
return m_ChunkMap->GetBiomeAt(a_BlockX, a_BlockZ);
|