summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Items/ItemHandler.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index bf1d4e4cb..f0a91214d 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -335,8 +335,21 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
}
-
- a_Player->UseEquippedItem();
+
+ if (!cBlockInfo::IsOneHitDig(Block))
+ {
+ a_Player->UseEquippedItem(GetDurabilityLostWithThatAction(dlaBreakBlock));
+ }
+}
+
+
+
+
+
+void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity)
+{
+ UNUSED(a_AttackedEntity);
+ a_Attacker->UseEquippedItem(GetDurabilityLostWithThatAction(dlaAttackEntity));
}
@@ -354,6 +367,20 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
+short cItemHandler::GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action)
+{
+ switch (a_Action)
+ {
+ case dlaAttackEntity: return 2;
+ case dlaBreakBlock: return 1;
+ }
+ return 0;
+}
+
+
+
+
+
char cItemHandler::GetMaxStackSize(void)
{
if (m_ItemType < 256)
@@ -505,6 +532,7 @@ bool cItemHandler::IsPlaceable(void)
bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
{
+ UNUSED(a_ItemType);
return false;
}