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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-13 12:38:06 -04:00
|
|
|
class cItemShearsHandler:
|
2013-07-29 07:13:03 -04:00
|
|
|
public cItemHandler
|
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cItemHandler;
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
2020-04-13 12:38:06 -04:00
|
|
|
|
|
|
|
cItemShearsHandler(int a_ItemType):
|
|
|
|
Super(a_ItemType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual bool IsTool(void) override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool OnDiggingBlock(
|
|
|
|
cWorld * a_World,
|
|
|
|
cPlayer * a_Player,
|
|
|
|
const cItem & a_HeldItem,
|
|
|
|
const Vector3i a_ClickedBlockPos,
|
|
|
|
eBlockFace a_ClickedBlockFace
|
|
|
|
) override
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-10-07 12:21:39 -04:00
|
|
|
BLOCKTYPE Block;
|
|
|
|
NIBBLETYPE BlockMeta;
|
2020-04-21 16:19:22 -04:00
|
|
|
a_World->GetBlockTypeMeta(a_ClickedBlockPos, Block, BlockMeta);
|
2014-10-07 12:21:39 -04:00
|
|
|
|
2014-03-16 09:01:22 -04:00
|
|
|
if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES))
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
a_World->DropBlockAsPickups(a_ClickedBlockPos, a_Player, &a_HeldItem);
|
2013-07-29 07:13:03 -04:00
|
|
|
return true;
|
|
|
|
}
|
2014-10-07 12:21:39 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
|
|
|
{
|
|
|
|
switch (a_BlockType)
|
|
|
|
{
|
|
|
|
case E_BLOCK_COBWEB:
|
2017-02-26 05:09:06 -05:00
|
|
|
case E_BLOCK_DEAD_BUSH:
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_VINES:
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-07 12:21:39 -04:00
|
|
|
}
|
2020-04-13 12:38:06 -04:00
|
|
|
return Super::CanHarvestBlock(a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2014-07-23 10:32:09 -04:00
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-26 07:26:14 -04:00
|
|
|
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
|
2014-07-23 10:32:09 -04:00
|
|
|
{
|
2018-01-05 06:28:06 -05:00
|
|
|
switch (a_Action)
|
|
|
|
{
|
|
|
|
case dlaAttackEntity: return 0;
|
|
|
|
case dlaBreakBlock: return 0;
|
|
|
|
case dlaBreakBlockInstant: return 1;
|
|
|
|
}
|
2018-02-04 18:07:12 -05:00
|
|
|
UNREACHABLE("Unsupported durability loss action");
|
2014-07-23 10:32:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-06 13:30:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-13 10:21:30 -05:00
|
|
|
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
|
2016-11-06 13:30:19 -05:00
|
|
|
{
|
2020-04-03 02:57:01 -04:00
|
|
|
if ((a_Block == E_BLOCK_COBWEB) || IsBlockMaterialLeaves(a_Block))
|
2016-11-06 13:30:19 -05:00
|
|
|
{
|
|
|
|
return 15.0f;
|
|
|
|
}
|
2020-04-03 02:57:01 -04:00
|
|
|
else if (a_Block == E_BLOCK_WOOL)
|
2017-06-20 10:42:14 -04:00
|
|
|
{
|
|
|
|
return 5.0f;
|
|
|
|
}
|
2016-11-06 13:30:19 -05:00
|
|
|
else
|
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
return Super::GetBlockBreakingStrength(a_Block);
|
2016-11-06 13:30:19 -05:00
|
|
|
}
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|