From 1cbb38fb028dd0dd6f515b22a40f2fd813f63432 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 13 Sep 2013 20:17:39 +0100 Subject: Removed place on top and side preventions --- source/Blocks/BlockCrops.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source/Blocks/BlockCrops.h') diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h index 4bc76fd50..9e19b14ec 100644 --- a/source/Blocks/BlockCrops.h +++ b/source/Blocks/BlockCrops.h @@ -20,12 +20,6 @@ public: } - virtual bool DoesAllowBlockOnTop() override - { - return false; - } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override { MTRand rand; -- cgit v1.2.3 From c74d1ffb91bc9af406599dfba00062efa6e47643 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Sat, 12 Oct 2013 15:25:47 -0600 Subject: Crop blocks now respect water and light. Currently a block has to be "watered" or the crop has a chance of breaking anyways. --- source/Blocks/BlockCrops.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/Blocks/BlockCrops.h') diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h index 9e19b14ec..81d35a06c 100644 --- a/source/Blocks/BlockCrops.h +++ b/source/Blocks/BlockCrops.h @@ -78,10 +78,17 @@ public: 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); - if (Meta < 7) + NIBBLETYPE Water = a_World->GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); + NIBBLETYPE Light = a_World->GetBlockBlockLight(a_BlockX, a_BlockY, a_BlockZ); + + if ((Meta < 7) && (Water > 0) && (Light > 8)) { a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_CROPS, ++Meta); } + else if ((!Water) || (Light < 9)) + { + a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); + } } -- cgit v1.2.3 From 277a18626deedb55db0cacc557a9d8292f65fc7e Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Sat, 12 Oct 2013 16:38:07 -0600 Subject: Removed faulty code dealing with water. --- source/Blocks/BlockCrops.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/Blocks/BlockCrops.h') diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h index 81d35a06c..e7b320eac 100644 --- a/source/Blocks/BlockCrops.h +++ b/source/Blocks/BlockCrops.h @@ -78,14 +78,13 @@ public: 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 Water = a_World->GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); NIBBLETYPE Light = a_World->GetBlockBlockLight(a_BlockX, a_BlockY, a_BlockZ); - if ((Meta < 7) && (Water > 0) && (Light > 8)) + if ((Meta < 7) && (Light > 8)) { a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_CROPS, ++Meta); } - else if ((!Water) || (Light < 9)) + else if (Light < 9) { a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); } -- cgit v1.2.3 From 570aedb927e706109b66e7bea6a7acf505382dc7 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 14 Nov 2013 09:53:09 -0700 Subject: Fixed growing issue with crops. --- source/Blocks/BlockCrops.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/Blocks/BlockCrops.h') diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h index e7b320eac..9dd65aae2 100644 --- a/source/Blocks/BlockCrops.h +++ b/source/Blocks/BlockCrops.h @@ -79,6 +79,12 @@ public: { 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)) { -- cgit v1.2.3 From 675b4aa878f16291ce33fced48a2bc7425f635ae Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 24 Nov 2013 14:19:41 +0000 Subject: Moved source to src --- source/Blocks/BlockCrops.h | 114 --------------------------------------------- 1 file changed, 114 deletions(-) delete mode 100644 source/Blocks/BlockCrops.h (limited to 'source/Blocks/BlockCrops.h') 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"; - } -} ; - - - - -- cgit v1.2.3