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:
|
2013-01-11 23:46:01 -05:00
|
|
|
cItemSeedsHandler(int a_ItemType) :
|
|
|
|
cItemHandler(a_ItemType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual bool IsPlaceable(void) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual bool GetPlacementBlockTypeMeta(
|
|
|
|
cWorld * a_World, cPlayer * a_Player,
|
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
|
|
|
|
int a_CursorX, int a_CursorY, int a_CursorZ,
|
|
|
|
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
|
|
|
) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_BlockFace != BLOCK_FACE_TOP)
|
2012-10-18 15:41:29 -04:00
|
|
|
{
|
|
|
|
// Only allow planting seeds from the top side of the block
|
2013-01-11 23:46:01 -05:00
|
|
|
return false;
|
2012-10-18 15:41:29 -04:00
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
// Only allow placement on farmland
|
2012-10-18 15:41:29 -04:00
|
|
|
int X = a_BlockX;
|
|
|
|
int Y = a_BlockY;
|
|
|
|
int Z = a_BlockZ;
|
2013-01-11 23:46:01 -05:00
|
|
|
AddFaceDirection(X, Y, Z, a_BlockFace, true);
|
2012-10-18 15:41:29 -04:00
|
|
|
if (a_World->GetBlock(X, Y, Z) != E_BLOCK_FARMLAND)
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
return false;
|
2012-10-18 15:41:29 -04:00
|
|
|
}
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
a_BlockMeta = 0;
|
|
|
|
switch (m_ItemType)
|
|
|
|
{
|
2013-04-05 09:45:00 -04:00
|
|
|
case E_ITEM_CARROT: a_BlockType = E_BLOCK_CARROTS; return true;
|
2013-01-11 23:46:01 -05:00
|
|
|
case E_ITEM_MELON_SEEDS: a_BlockType = E_BLOCK_MELON_STEM; return true;
|
2013-04-05 09:45:00 -04:00
|
|
|
case E_ITEM_POTATO: a_BlockType = E_BLOCK_POTATOES; return true;
|
2013-01-11 23:46:01 -05:00
|
|
|
case E_ITEM_PUMPKIN_SEEDS: a_BlockType = E_BLOCK_PUMPKIN_STEM; return true;
|
2013-04-05 09:45:00 -04:00
|
|
|
case E_ITEM_SEEDS: a_BlockType = E_BLOCK_CROPS; return true;
|
2013-01-11 23:46:01 -05:00
|
|
|
default: a_BlockType = E_BLOCK_AIR; return true;
|
|
|
|
}
|
|
|
|
return false;
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
2012-07-29 08:07:22 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|