diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-07-23 16:32:09 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-07-23 16:32:09 +0200 |
commit | 396739cc0faf01a099acbe669c5a9def98d3aaae (patch) | |
tree | 91cff4c6ac486b2158edefce878174fe95e2fb3d /src/Items/ItemHandler.cpp | |
parent | CheckBasicStyle: Added a lua shebang. (diff) | |
download | cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.tar cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.tar.gz cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.tar.bz2 cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.tar.lz cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.tar.xz cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.tar.zst cuberite-396739cc0faf01a099acbe669c5a9def98d3aaae.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemHandler.cpp | 32 |
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; } |