summaryrefslogtreecommitdiffstats
path: root/source/Blocks/BlockCrops.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-05 15:45:00 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-05 15:45:00 +0200
commitd397dd263f121340ef4633904e3c01419786856c (patch)
treeaddea805f20127475b5a632efdddf1d3adb3d2f1 /source/Blocks/BlockCrops.h
parentFixed personal crafting grid not being tossed on inventory close. (diff)
downloadcuberite-d397dd263f121340ef4633904e3c01419786856c.tar
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.gz
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.bz2
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.lz
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.xz
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.zst
cuberite-d397dd263f121340ef4633904e3c01419786856c.zip
Diffstat (limited to '')
-rw-r--r--source/Blocks/BlockCrops.h59
1 files changed, 55 insertions, 4 deletions
diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h
index 6b33a400c..7658d2633 100644
--- a/source/Blocks/BlockCrops.h
+++ b/source/Blocks/BlockCrops.h
@@ -1,9 +1,17 @@
+
#pragma once
+
#include "BlockHandler.h"
#include "../MersenneTwister.h"
#include "../World.h"
-class cBlockCropsHandler : public cBlockHandler
+
+
+
+
+/// Common class that takes care of carrots, potatoes and wheat
+class cBlockCropsHandler :
+ public cBlockHandler
{
public:
cBlockCropsHandler(BLOCKTYPE a_BlockType)
@@ -22,11 +30,54 @@ public:
{
MTRand rand;
- if (a_Meta == 0x7) // Is fully grown
+ if (a_Meta == 0x7)
+ {
+ // Is fully grown, drop the entire produce:
+ switch (m_BlockType)
+ {
+ case E_BLOCK_CROPS:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
+ a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
+ case E_BLOCK_CARROTS:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_CARROT, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
+ case E_BLOCK_POTATOES:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_POTATO, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ if (rand.randInt(20) == 0)
+ {
+ // With a 5% chance, drop a poisonous potato as well
+ a_Pickups.push_back(cItem(E_ITEM_POISONOUS_POTATO, 1, 0));
+ }
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unhandled block type");
+ break;
+ }
+ } // switch (m_BlockType)
+ }
+ else
{
- a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
+ // 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;
+ default:
+ {
+ ASSERT(!"Unhandled block type");
+ break;
+ }
+ }
}
- a_Pickups.push_back(cItem(E_ITEM_SEEDS, (rand.randInt(3) == 0) ? 2 : 1, 0));
}