summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockCrops.h
diff options
context:
space:
mode:
authormathiascode <mathiascode@users.noreply.github.com>2017-02-14 11:13:55 +0100
committerMattes D <github@xoft.cz>2017-02-14 11:13:55 +0100
commit4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6 (patch)
tree7164954ec1ca29c34623248ff413d007268a17e8 /src/Blocks/BlockCrops.h
parentImproved easyinstall.sh to support macOS and FreeBSD (#3557) (diff)
downloadcuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.tar
cuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.tar.gz
cuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.tar.bz2
cuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.tar.lz
cuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.tar.xz
cuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.tar.zst
cuberite-4311f4a658fe2bef362aeb9b4bdbcd59c9617ad6.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockCrops.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index cc18a2b18..4ea94cf86 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -8,7 +8,8 @@
-/** Common class that takes care of carrots, potatoes and wheat */
+/** Common class that takes care of beetroots, carrots, potatoes and wheat */
+template <NIBBLETYPE RipeMeta>
class cBlockCropsHandler :
public cBlockPlant
{
@@ -23,11 +24,20 @@ public:
{
cFastRandom rand;
- if (a_Meta == 0x7)
+ // Beetroots have three stages before fully grown
+ if (a_Meta >= RipeMeta)
{
// Is fully grown, drop the entire produce:
switch (m_BlockType)
{
+ case E_BLOCK_BEETROOTS:
+ {
+ char SeedCount = static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2);
+ a_Pickups.push_back(cItem(E_ITEM_BEETROOT_SEEDS, SeedCount, 0));
+ char BeetrootCount = static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2);
+ a_Pickups.push_back(cItem(E_ITEM_BEETROOT, BeetrootCount, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
case E_BLOCK_CROPS:
{
a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
@@ -61,9 +71,10 @@ public:
// Drop 1 item of whatever is growing
switch (m_BlockType)
{
- case E_BLOCK_CROPS: a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0)); break;
- case E_BLOCK_CARROTS: a_Pickups.push_back(cItem(E_ITEM_CARROT, 1, 0)); break;
- case E_BLOCK_POTATOES: a_Pickups.push_back(cItem(E_ITEM_POTATO, 1, 0)); break;
+ case E_BLOCK_BEETROOTS: a_Pickups.push_back(cItem(E_ITEM_BEETROOT_SEEDS, 1, 0)); break;
+ case E_BLOCK_CROPS: a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0)); break;
+ case E_BLOCK_CARROTS: a_Pickups.push_back(cItem(E_ITEM_CARROT, 1, 0)); break;
+ case E_BLOCK_POTATOES: a_Pickups.push_back(cItem(E_ITEM_POTATO, 1, 0)); break;
default:
{
ASSERT(!"Unhandled block type");
@@ -82,7 +93,7 @@ public:
// If there is still room to grow and the plant can grow, then grow.
// Otherwise if the plant needs to die, then dig it up
- if ((Meta < 7) && (Action == paGrowth))
+ if ((Meta < RipeMeta) && (Action == paGrowth))
{
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, ++Meta);
}