summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemHandler.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2018-01-05 12:28:06 +0100
committerGitHub <noreply@github.com>2018-01-05 12:28:06 +0100
commitb4aa19f329b06e42eb2591fc488b70dc0df41940 (patch)
tree5b18f7bde0b3129310d273f63b68151850c43ea7 /src/Items/ItemHandler.cpp
parentAdd the fmt library (#4065) (diff)
downloadcuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.tar
cuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.tar.gz
cuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.tar.bz2
cuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.tar.lz
cuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.tar.xz
cuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.tar.zst
cuberite-b4aa19f329b06e42eb2591fc488b70dc0df41940.zip
Diffstat (limited to 'src/Items/ItemHandler.cpp')
-rw-r--r--src/Items/ItemHandler.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index e10f17db1..976ab959d 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -494,10 +494,8 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block));
}
- if (!cBlockInfo::IsOneHitDig(Block))
- {
- a_Player->UseEquippedItem(GetDurabilityLossByAction(dlaBreakBlock));
- }
+ auto Action = (cBlockInfo::IsOneHitDig(Block) ? dlaBreakBlockInstant : dlaBreakBlock);
+ a_Player->UseEquippedItem(Action);
}
@@ -507,7 +505,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity)
{
UNUSED(a_AttackedEntity);
- a_Attacker->UseEquippedItem(GetDurabilityLossByAction(dlaAttackEntity));
+ a_Attacker->UseEquippedItem(dlaAttackEntity);
}
@@ -527,15 +525,9 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action)
{
- switch (a_Action)
- {
- case dlaAttackEntity: return 2;
- case dlaBreakBlock: return 1;
- }
+ UNUSED(a_Action);
- #ifndef __clang__
return 0;
- #endif
}
@@ -865,4 +857,3 @@ float cItemHandler::GetBlockBreakingStrength(BLOCKTYPE a_Block)
{
return 1.0f;
}
-