1
0
Fork 0
cuberite-2a/src/Items/ItemShears.h

111 lines
1.6 KiB
C
Raw Normal View History

#pragma once
#include "ItemHandler.h"
#include "../World.h"
#include "../Entities/Player.h"
2020-04-13 16:38:06 +00:00
class cItemShearsHandler:
public cItemHandler
{
2020-04-13 16:38:06 +00:00
using Super = cItemHandler;
public:
2020-04-13 16:38:06 +00:00
cItemShearsHandler(int a_ItemType):
Super(a_ItemType)
{
}
2016-02-05 21:45:45 +00:00
virtual bool IsTool(void) override
{
return true;
}
2016-02-05 21:45:45 +00:00
virtual bool OnDiggingBlock(
cWorld * a_World,
cPlayer * a_Player,
const cItem & a_HeldItem,
const Vector3i a_ClickedBlockPos,
eBlockFace a_ClickedBlockFace
) override
{
BLOCKTYPE Block;
NIBBLETYPE BlockMeta;
a_World->GetBlockTypeMeta(a_ClickedBlockPos, Block, BlockMeta);
2014-03-16 13:01:22 +00:00
if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES))
{
a_World->DropBlockAsPickups(a_ClickedBlockPos, a_Player, &a_HeldItem);
return true;
}
return false;
}
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
switch (a_BlockType)
{
case E_BLOCK_COBWEB:
2017-02-26 10:09:06 +00:00
case E_BLOCK_DEAD_BUSH:
case E_BLOCK_VINES:
{
return true;
}
}
2020-04-13 16:38:06 +00:00
return Super::CanHarvestBlock(a_BlockType);
}
2014-07-23 14:32:09 +00:00
2014-07-26 11:26:14 +00:00
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
2014-07-23 14:32:09 +00:00
{
switch (a_Action)
{
case dlaAttackEntity: return 0;
case dlaBreakBlock: return 0;
case dlaBreakBlockInstant: return 1;
}
UNREACHABLE("Unsupported durability loss action");
2014-07-23 14:32:09 +00:00
}
2016-11-13 15:21:30 +00:00
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
{
if ((a_Block == E_BLOCK_COBWEB) || IsBlockMaterialLeaves(a_Block))
{
return 15.0f;
}
else if (a_Block == E_BLOCK_WOOL)
{
return 5.0f;
}
else
{
2020-04-13 16:38:06 +00:00
return Super::GetBlockBreakingStrength(a_Block);
}
}
} ;