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

64 lines
1.1 KiB
C
Raw Normal View History

#pragma once
#include "ItemHandler.h"
#include "../World.h"
#include "../Entities/Player.h"
class cItemSwordHandler :
public cItemHandler
{
2014-07-23 14:32:09 +00:00
typedef cItemHandler super;
public:
cItemSwordHandler(int a_ItemType)
: cItemHandler(a_ItemType)
{
}
2014-07-23 14:32:09 +00:00
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
if (a_BlockType == E_BLOCK_COBWEB)
{
return true;
}
return super::CanHarvestBlock(a_BlockType);
}
2014-04-30 22:47:57 +00:00
2014-07-23 14:32:09 +00:00
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
2014-04-30 22:47:57 +00: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 22:47:57 +00:00
}
return false;
}
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)
2014-07-23 14:32:09 +00:00
{
case dlaAttackEntity: return 1;
case dlaBreakBlock: return 2;
}
2016-02-05 21:45:45 +00:00
#ifndef __clang__
2014-07-23 14:32:09 +00:00
return 0;
#endif
2014-07-23 14:32:09 +00:00
}
} ;