diff options
Diffstat (limited to 'source/Items/ItemSeeds.h')
-rw-r--r-- | source/Items/ItemSeeds.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/source/Items/ItemSeeds.h b/source/Items/ItemSeeds.h index 3eb9d6e86..f013af3be 100644 --- a/source/Items/ItemSeeds.h +++ b/source/Items/ItemSeeds.h @@ -12,8 +12,8 @@ class cItemSeedsHandler : public cItemHandler
{
public:
- cItemSeedsHandler(int a_ItemID)
- : cItemHandler(a_ItemID)
+ cItemSeedsHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
{
}
@@ -25,7 +25,7 @@ public: virtual BLOCKTYPE GetBlockType() override
{
- switch(m_ItemID)
+ switch(m_ItemType)
{
case E_ITEM_SEEDS: return E_BLOCK_CROPS;
case E_ITEM_MELON_SEEDS: return E_BLOCK_MELON_STEM;
@@ -39,18 +39,27 @@ public: return 0; //Not grown yet
}
- virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir) override
+
+ virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
- int X = a_X,
- Y = a_Y,
- Z = a_Z;
+ if (a_Dir != BLOCK_FACE_TOP)
+ {
+ // Only allow planting seeds from the top side of the block
+ return;
+ }
+
+ int X = a_BlockX;
+ int Y = a_BlockY;
+ int Z = a_BlockZ;
AddDirection(X, Y, Z, a_Dir, true);
- if(a_World->GetBlock(X, Y, Z) != E_BLOCK_FARMLAND)
+ if (a_World->GetBlock(X, Y, Z) != E_BLOCK_FARMLAND)
+ {
return;
+ }
- return cItemHandler::PlaceBlock(a_World, a_Player, a_Item, a_X, a_Y, a_Z, a_Dir);
+ return cItemHandler::PlaceBlock(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
}
} ;
|