2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
2013-08-19 09:39:13 +00:00
|
|
|
#include "../Entities/Player.h"
|
2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
#include "../Blocks/BlockHandler.h"
|
2014-02-02 14:49:37 +00:00
|
|
|
#include "../BlockInServerPluginInterface.h"
|
2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemShovelHandler : public cItemHandler
|
|
|
|
{
|
2014-07-26 11:23:11 +00:00
|
|
|
typedef cItemHandler super;
|
2013-07-29 11:13:03 +00:00
|
|
|
public:
|
|
|
|
cItemShovelHandler(int a_ItemType)
|
|
|
|
: cItemHandler(a_ItemType)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-02-04 18:59:05 +00:00
|
|
|
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
|
2013-07-29 11:13:03 +00:00
|
|
|
{
|
|
|
|
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
if (Block == E_BLOCK_SNOW)
|
|
|
|
{
|
2014-02-02 14:49:37 +00:00
|
|
|
cChunkInterface ChunkInterface(a_World->GetChunkMap());
|
|
|
|
cBlockInServerPluginInterface PluginInterface(*a_World);
|
2014-07-19 12:53:41 +00:00
|
|
|
BlockHandler(Block)->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
|
|
|
a_Player->UseEquippedItem();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
|
|
|
{
|
2014-07-26 11:23:11 +00:00
|
|
|
if (a_BlockType == E_BLOCK_SNOW)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super::CanHarvestBlock(a_BlockType);
|
2013-07-29 11:13:03 +00:00
|
|
|
}
|
2014-04-30 22:47:57 +00:00
|
|
|
|
2014-05-06 17:38:09 +00:00
|
|
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
2014-04-30 22:47:57 +00:00
|
|
|
{
|
|
|
|
switch (m_ItemType)
|
|
|
|
{
|
2014-05-06 17:38:09 +00:00
|
|
|
case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS);
|
|
|
|
case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE);
|
|
|
|
case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON);
|
|
|
|
case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD);
|
|
|
|
case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND);
|
2014-04-30 22:47:57 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-02 14:49:37 +00:00
|
|
|
};
|