From d397dd263f121340ef4633904e3c01419786856c Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 5 Apr 2013 13:45:00 +0000 Subject: Added carrots and potatoes handling, bonemealing and proper lighting. FS #166 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1359 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Blocks/BlockCrops.h | 59 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) (limited to 'source/Blocks/BlockCrops.h') 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)); } -- cgit v1.2.3