mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 01:51:51 +00:00
Player: avoid doing some post-melee attack actions if attacking killed the attacker
This can happen when an attacker attacks a victim wearing thorns armour while having low health, which prior to this commit would cause the tool to be duplicated.
This commit is contained in:
parent
a5a236084f
commit
6c6630d845
@ -2529,11 +2529,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($heldItem->onAttackEntity($target) and $this->isSurvival()){ //always fire the hook, even if we are survival
|
if($this->isAlive()){
|
||||||
$this->inventory->setItemInHand($heldItem);
|
//reactive damage like thorns might cause us to be killed by attacking another mob, which
|
||||||
}
|
//would mean we'd already have dropped the inventory by the time we reached here
|
||||||
|
if($heldItem->onAttackEntity($target) and $this->isSurvival()){ //always fire the hook, even if we are survival
|
||||||
|
$this->inventory->setItemInHand($heldItem);
|
||||||
|
}
|
||||||
|
|
||||||
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
|
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user