diff options
author | Mattes D <github@xoft.cz> | 2017-02-25 10:54:44 +0100 |
---|---|---|
committer | Julian Laubstein <contact@julianlaubstein.de> | 2017-02-25 10:54:44 +0100 |
commit | 7c17f77c84711607bc0f2db5f2991887bf5c9b79 (patch) | |
tree | a6c2e6ab56d7c69953b39c2d5fcd18e0d3094a3e | |
parent | Removed a few default plugins (#3580) (diff) | |
download | cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.tar cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.tar.gz cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.tar.bz2 cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.tar.lz cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.tar.xz cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.tar.zst cuberite-7c17f77c84711607bc0f2db5f2991887bf5c9b79.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockCrops.h | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h index 4ea94cf86..5ca264774 100644 --- a/src/Blocks/BlockCrops.h +++ b/src/Blocks/BlockCrops.h @@ -14,61 +14,23 @@ class cBlockCropsHandler : public cBlockPlant { typedef cBlockPlant Super; + public: - cBlockCropsHandler(BLOCKTYPE a_BlockType) - : Super(a_BlockType, true) + + cBlockCropsHandler(BLOCKTYPE a_BlockType): + Super(a_BlockType, true) { } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override { cFastRandom rand; - // Beetroots have three stages before fully grown - if (a_Meta >= RipeMeta) + // If not fully grown, drop the "seed" of whatever is growing: + 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)); - a_Pickups.push_back(cItem(E_ITEM_SEEDS, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 - break; - } - case E_BLOCK_CARROTS: - { - a_Pickups.push_back(cItem(E_ITEM_CARROT, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 - break; - } - case E_BLOCK_POTATOES: - { - a_Pickups.push_back(cItem(E_ITEM_POTATO, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 - if (rand.NextInt(21) == 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_BEETROOTS: a_Pickups.push_back(cItem(E_ITEM_BEETROOT_SEEDS, 1, 0)); break; @@ -81,9 +43,51 @@ public: break; } } + return; } + + // Fully grown, drop the crop's produce: + switch (m_BlockType) + { + case E_BLOCK_BEETROOTS: + { + char SeedCount = static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2); // [1 .. 3] with high preference of 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); // [1 .. 3] with high preference of 2 + a_Pickups.push_back(cItem(E_ITEM_BEETROOT, BeetrootCount, 0)); + break; + } + case E_BLOCK_CROPS: + { + a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0)); + a_Pickups.push_back(cItem(E_ITEM_SEEDS, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 + break; + } + case E_BLOCK_CARROTS: + { + a_Pickups.push_back(cItem(E_ITEM_CARROT, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 + break; + } + case E_BLOCK_POTATOES: + { + a_Pickups.push_back(cItem(E_ITEM_POTATO, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 + if (rand.NextInt(21) == 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) } + + virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); @@ -103,11 +107,15 @@ public: } } + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, 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 ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); |