From b4aa19f329b06e42eb2591fc488b70dc0df41940 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Fri, 5 Jan 2018 11:28:06 +0000 Subject: Item durability loss now depends on the item used. (#4123) Armour durability also no longer changes when it is used to break blocks or attack mobs. Fixes #4119 --- src/Items/ItemHandler.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/Items/ItemHandler.cpp') 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; } - -- cgit v1.2.3