2012-07-29 08:07:22 -04:00
|
|
|
|
2012-07-15 16:36:34 -04:00
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-07-29 08:07:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemSeedsHandler :
|
|
|
|
public cItemHandler
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-18 15:41:29 -04:00
|
|
|
cItemSeedsHandler(int a_ItemType)
|
|
|
|
: cItemHandler(a_ItemType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
virtual bool IsPlaceable() override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
virtual BLOCKTYPE GetBlockType() override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-18 15:41:29 -04:00
|
|
|
switch(m_ItemType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-07-29 08:07:22 -04:00
|
|
|
case E_ITEM_SEEDS: return E_BLOCK_CROPS;
|
|
|
|
case E_ITEM_MELON_SEEDS: return E_BLOCK_MELON_STEM;
|
|
|
|
case E_ITEM_PUMPKIN_SEEDS: return E_BLOCK_PUMPKIN_STEM;
|
|
|
|
default: return E_BLOCK_AIR;
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 08:07:22 -04:00
|
|
|
virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return 0; //Not grown yet
|
|
|
|
}
|
|
|
|
|
2012-10-18 15:41:29 -04:00
|
|
|
|
|
|
|
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
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-18 15:41:29 -04:00
|
|
|
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;
|
2012-07-15 16:36:34 -04:00
|
|
|
|
|
|
|
AddDirection(X, Y, Z, a_Dir, true);
|
|
|
|
|
2012-10-18 15:41:29 -04:00
|
|
|
if (a_World->GetBlock(X, Y, Z) != E_BLOCK_FARMLAND)
|
|
|
|
{
|
2012-07-15 16:36:34 -04:00
|
|
|
return;
|
2012-10-18 15:41:29 -04:00
|
|
|
}
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-10-18 15:41:29 -04:00
|
|
|
return cItemHandler::PlaceBlock(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
2012-07-29 08:07:22 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|