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:
committed by
GitHub
parent
757231cc6e
commit
b4aa19f329
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user