2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
2013-08-19 05:39:13 -04:00
|
|
|
#include "../Entities/Player.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#include "../Blocks/BlockHandler.h"
|
2014-02-02 09:49:37 -05:00
|
|
|
#include "../BlockInServerPluginInterface.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemShovelHandler : public cItemHandler
|
|
|
|
{
|
2014-07-26 07:23:11 -04:00
|
|
|
typedef cItemHandler super;
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
|
|
|
cItemShovelHandler(int a_ItemType)
|
|
|
|
: cItemHandler(a_ItemType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-04 13:59:05 -05: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 07:13:03 -04:00
|
|
|
{
|
|
|
|
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
if (Block == E_BLOCK_SNOW)
|
|
|
|
{
|
2014-02-02 09:49:37 -05:00
|
|
|
cChunkInterface ChunkInterface(a_World->GetChunkMap());
|
|
|
|
cBlockInServerPluginInterface PluginInterface(*a_World);
|
2014-07-19 08:53:41 -04:00
|
|
|
BlockHandler(Block)->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
|
|
|
a_Player->UseEquippedItem();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
|
|
|
{
|
2014-07-26 07:23:11 -04:00
|
|
|
if (a_BlockType == E_BLOCK_SNOW)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super::CanHarvestBlock(a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2014-04-30 18:47:57 -04:00
|
|
|
|
2014-05-06 13:38:09 -04:00
|
|
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
2014-04-30 18:47:57 -04:00
|
|
|
{
|
|
|
|
switch (m_ItemType)
|
|
|
|
{
|
2014-05-06 13:38:09 -04: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 18:47:57 -04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-13 10:21:30 -05:00
|
|
|
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
|
2016-11-06 13:30:19 -05:00
|
|
|
{
|
|
|
|
switch (a_Block)
|
|
|
|
{
|
|
|
|
case E_BLOCK_CLAY:
|
|
|
|
case E_BLOCK_DIRT:
|
|
|
|
case E_BLOCK_FARMLAND:
|
|
|
|
case E_BLOCK_GRASS:
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_GRASS_PATH:
|
2016-11-06 13:30:19 -05:00
|
|
|
case E_BLOCK_GRAVEL:
|
|
|
|
case E_BLOCK_MYCELIUM:
|
|
|
|
case E_BLOCK_SAND:
|
|
|
|
case E_BLOCK_SNOW:
|
|
|
|
case E_BLOCK_SNOW_BLOCK:
|
|
|
|
case E_BLOCK_SOULSAND:
|
|
|
|
{
|
|
|
|
switch (m_ItemType)
|
|
|
|
{
|
|
|
|
case E_ITEM_WOODEN_SHOVEL: return 2.0f;
|
|
|
|
case E_ITEM_STONE_SHOVEL: return 4.0f;
|
|
|
|
case E_ITEM_IRON_SHOVEL: return 6.0f;
|
|
|
|
case E_ITEM_GOLD_SHOVEL: return 12.0f;
|
|
|
|
case E_ITEM_DIAMOND_SHOVEL: return 8.0f;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: return super::GetBlockBreakingStrength(a_Block);
|
|
|
|
}
|
|
|
|
ASSERT(!"Something is wrong here... Maybe they are shovels out of a new material?");
|
|
|
|
return 1.0f;
|
|
|
|
}
|
2014-02-02 09:49:37 -05:00
|
|
|
};
|