1
0

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
This commit is contained in:
Alexander Harkness
2018-01-05 11:28:06 +00:00
committed by GitHub
parent 757231cc6e
commit b4aa19f329
30 changed files with 111 additions and 208 deletions

View File

@@ -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;
}