summaryrefslogtreecommitdiffstats
path: root/source/cChunk.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 14:03:49 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 14:03:49 +0200
commitec61713221292914cd8e9e12bb77fac9e76e42eb (patch)
tree99acb7704519206e83e91235c78fa0f1ec22cd83 /source/cChunk.cpp
parentBonemeal is consumed in survival mode when used on growable blocks (diff)
downloadcuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.tar
cuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.tar.gz
cuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.tar.bz2
cuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.tar.lz
cuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.tar.xz
cuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.tar.zst
cuberite-ec61713221292914cd8e9e12bb77fac9e76e42eb.zip
Diffstat (limited to 'source/cChunk.cpp')
-rw-r--r--source/cChunk.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 1b70e84d1..526300972 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -572,6 +572,7 @@ void cChunk::TickBlocks(MTRand & a_TickRandom)
case E_BLOCK_MELON_STEM: TickMelonPumpkin(m_BlockTickX, m_BlockTickY, m_BlockTickZ, Index, ID, a_TickRandom); break;
case E_BLOCK_FARMLAND: TickFarmland (m_BlockTickX, m_BlockTickY, m_BlockTickZ); break;
case E_BLOCK_SUGARCANE: GrowSugarcane (m_BlockTickX, m_BlockTickY, m_BlockTickZ, 1); break;
+ case E_BLOCK_CACTUS: GrowCactus (m_BlockTickX, m_BlockTickY, m_BlockTickZ, 1); break;
case E_BLOCK_SAPLING:
{
@@ -846,6 +847,52 @@ void cChunk::GrowSugarcane(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks)
{
UnboundedRelFastSetBlock(a_RelX, Top + i, a_RelZ, E_BLOCK_SUGARCANE, 0);
}
+ else
+ {
+ break;
+ }
+ } // for i
+}
+
+
+
+
+
+void cChunk::GrowCactus(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks)
+{
+ // Check the total height of the sugarcane blocks here:
+ int Top = a_RelY + 1;
+ while (
+ (Top < cChunkDef::Height) &&
+ (GetBlock(a_RelX, Top, a_RelZ) == E_BLOCK_CACTUS)
+ )
+ {
+ ++Top;
+ }
+ int Bottom = a_RelY - 1;
+ while (
+ (Bottom > 0) &&
+ (GetBlock(a_RelX, Bottom, a_RelZ) == E_BLOCK_CACTUS)
+ )
+ {
+ --Bottom;
+ }
+
+ // Grow by at most a_NumBlocks, but no more than height 3:
+ int ToGrow = std::min(a_NumBlocks, 4 - (Top - Bottom));
+ for (int i = 0; i < ToGrow; i++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (UnboundedRelGetBlock(a_RelX, Top + i, a_RelZ, BlockType, BlockMeta) && (BlockType == E_BLOCK_AIR))
+ {
+ // TODO: Check the surrounding blocks, if they aren't air, break the cactus block into pickups (and continue breaking blocks above in the next loop iterations)
+ UnboundedRelFastSetBlock(a_RelX, Top + i, a_RelZ, E_BLOCK_CACTUS, 0);
+ }
+ else
+ {
+ break;
+ }
} // for i
}