1
0
cuberite-2a/src/Items/ItemSword.h

86 lines
1.5 KiB
C
Raw Normal View History

#pragma once
#include "ItemHandler.h"
#include "../BlockInfo.h"
2020-04-13 12:38:06 -04:00
class cItemSwordHandler:
public cItemHandler
{
2020-04-13 12:38:06 -04:00
using Super = cItemHandler;
public:
2020-04-13 12:38:06 -04:00
cItemSwordHandler(int a_ItemType):
2020-04-13 12:38:06 -04:00
Super(a_ItemType)
{
}
2014-07-23 10:32:09 -04:00
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
if (a_BlockType == E_BLOCK_COBWEB)
{
return true;
}
2020-04-13 12:38:06 -04:00
return Super::CanHarvestBlock(a_BlockType);
}
2014-04-30 18:47:57 -04:00
2014-07-23 10:32:09 -04:00
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
2014-04-30 18:47:57 -04:00
{
switch (m_ItemType)
{
case E_ITEM_WOODEN_SWORD: return (a_ItemType == E_BLOCK_PLANKS);
case E_ITEM_STONE_SWORD: return (a_ItemType == E_BLOCK_COBBLESTONE);
case E_ITEM_IRON_SWORD: return (a_ItemType == E_ITEM_IRON);
case E_ITEM_GOLD_SWORD: return (a_ItemType == E_ITEM_GOLD);
case E_ITEM_DIAMOND_SWORD: return (a_ItemType == E_ITEM_DIAMOND);
2014-04-30 18:47:57 -04:00
}
return false;
}
2014-07-23 10:32:09 -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
{
switch (a_Action)
2014-07-23 10:32:09 -04:00
{
case dlaAttackEntity: return 1;
case dlaBreakBlock: return 2;
case dlaBreakBlockInstant: return 0;
2014-07-23 10:32:09 -04:00
}
UNREACHABLE("Unsupported durability loss action");
2014-07-23 10:32:09 -04:00
}
2016-11-13 10:21:30 -05:00
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
{
if (a_Block == E_BLOCK_COBWEB)
{
return 15.0f;
}
else
{
if (
IsBlockMaterialPlants(a_Block) ||
IsBlockMaterialVine(a_Block) ||
IsBlockMaterialLeaves(a_Block) ||
IsBlockMaterialGourd(a_Block)
)
{
return 1.5f;
}
else
{
return 1.0f;
}
}
}
} ;