2012-09-23 18:09:57 -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"
|
|
|
|
#include "../Player.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-10-18 15:41:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemShearsHandler :
|
|
|
|
public cItemHandler
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-18 15:41:29 -04:00
|
|
|
cItemShearsHandler(int a_ItemType) :
|
|
|
|
cItemHandler(a_ItemType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
}
|
2012-10-18 15:41:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
virtual bool IsTool(void) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2012-10-18 15:41:29 -04:00
|
|
|
|
|
|
|
|
2013-05-19 14:22:37 -04:00
|
|
|
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const 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
|
|
|
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
if (Block == E_BLOCK_LEAVES)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
cItems Drops;
|
2013-02-16 06:12:56 -05:00
|
|
|
Drops.push_back(cItem(E_BLOCK_LEAVES, 1, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)));
|
2012-10-18 15:41:29 -04:00
|
|
|
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-10-18 15:41:29 -04:00
|
|
|
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
2012-07-15 16:36:34 -04:00
|
|
|
a_Player->UseEquippedItem();
|
|
|
|
return true;
|
|
|
|
}
|
2012-10-18 15:41:29 -04:00
|
|
|
// TODO: cobweb, vines
|
2012-07-15 16:36:34 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-18 15:41:29 -04:00
|
|
|
switch (a_BlockType)
|
|
|
|
{
|
|
|
|
case E_BLOCK_COBWEB:
|
|
|
|
case E_BLOCK_VINES:
|
|
|
|
case E_BLOCK_LEAVES:
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-04-06 14:20:06 -04:00
|
|
|
} // switch (a_BlockType)
|
2012-10-18 15:41:29 -04:00
|
|
|
return false;
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
2012-10-18 15:41:29 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|