summaryrefslogtreecommitdiffstats
path: root/source/Blocks/BlockCrops.h
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-11-24 15:19:41 +0100
committerAlexander Harkness <bearbin@gmail.com>2013-11-24 15:19:41 +0100
commit675b4aa878f16291ce33fced48a2bc7425f635ae (patch)
tree409914df27a98f65adf866da669429c4de141b6f /source/Blocks/BlockCrops.h
parentLineBlockTracer: Using the coord-based block faces. (diff)
downloadcuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.tar
cuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.tar.gz
cuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.tar.bz2
cuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.tar.lz
cuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.tar.xz
cuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.tar.zst
cuberite-675b4aa878f16291ce33fced48a2bc7425f635ae.zip
Diffstat (limited to 'source/Blocks/BlockCrops.h')
-rw-r--r--source/Blocks/BlockCrops.h114
1 files changed, 0 insertions, 114 deletions
diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h
deleted file mode 100644
index 9dd65aae2..000000000
--- a/source/Blocks/BlockCrops.h
+++ /dev/null
@@ -1,114 +0,0 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-
-
-
-
-
-/// Common class that takes care of carrots, potatoes and wheat
-class cBlockCropsHandler :
- public cBlockHandler
-{
-public:
- cBlockCropsHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
- {
- MTRand rand;
-
- 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
- {
- // 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;
- }
- }
- }
- }
-
-
- void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- NIBBLETYPE Light = a_World->GetBlockBlockLight(a_BlockX, a_BlockY, a_BlockZ);
- NIBBLETYPE SkyLight = a_World->GetBlockSkyLight(a_BlockX, a_BlockY, a_BlockZ);
-
- if (SkyLight > Light)
- {
- Light = SkyLight;
- }
-
- if ((Meta < 7) && (Light > 8))
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_CROPS, ++Meta);
- }
- else if (Light < 9)
- {
- a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
- }
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-