1
0
cuberite-2a/src/Items/ItemAxe.h
peterbell10 d3c1c626f5
Deal with covered switches consistently (#4161)
* Fixes a number of "<function>: not all control paths return a value" warnings on MSVC.

* Introduces the UNREACHABLE global macro and uses it instead of conditionally compiled switch defaults.

* Move cNBTParseErrorCategory from FastNBT.h into FastNBT.cpp to prevent bad calls to message()
2018-02-04 23:07:12 +00:00

57 lines
1.1 KiB
C++

#pragma once
#include "ItemHandler.h"
class cItemAxeHandler :
public cItemHandler
{
typedef cItemHandler super;
public:
cItemAxeHandler(int a_ItemType)
: cItemHandler(a_ItemType)
{
}
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
{
switch (a_Action)
{
case dlaAttackEntity: return 2;
case dlaBreakBlock: return 1;
case dlaBreakBlockInstant: return 0;
}
UNREACHABLE("Unsupported durability loss action");
}
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
{
if (!IsBlockMaterialWood(a_Block) && !IsBlockMaterialPlants(a_Block) && !IsBlockMaterialVine(a_Block))
{
return super::GetBlockBreakingStrength(a_Block);
}
else
{
switch (m_ItemType)
{
case E_ITEM_WOODEN_AXE: return 2.0f;
case E_ITEM_STONE_AXE: return 4.0f;
case E_ITEM_IRON_AXE: return 6.0f;
case E_ITEM_GOLD_AXE: return 12.0f;
case E_ITEM_DIAMOND_AXE: return 8.0f;
}
}
ASSERT(!"Something is wrong here... Maybe they are axes out of a new material?");
return 1.0f;
}
} ;