mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Player: fix weapons not taking damage from attacks (bug introduced by #3348)
This commit is contained in:
parent
636c35dcf1
commit
517f9a3c3a
@ -2535,6 +2535,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$cancelled = false;
|
$cancelled = false;
|
||||||
|
|
||||||
$heldItem = $this->inventory->getItemInHand();
|
$heldItem = $this->inventory->getItemInHand();
|
||||||
|
$oldItem = clone $heldItem;
|
||||||
|
|
||||||
if(!$this->canInteract($target, 8)){
|
if(!$this->canInteract($target, 8)){
|
||||||
$cancelled = true;
|
$cancelled = true;
|
||||||
@ -2594,7 +2595,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
if($this->isAlive()){
|
if($this->isAlive()){
|
||||||
//reactive damage like thorns might cause us to be killed by attacking another mob, which
|
//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
|
//would mean we'd already have dropped the inventory by the time we reached here
|
||||||
if($heldItem->onAttackEntity($target) and $this->isSurvival() and $heldItem->equalsExact($this->inventory->getItemInHand())){ //always fire the hook, even if we are survival
|
if($heldItem->onAttackEntity($target) and $this->isSurvival() and $oldItem->equalsExact($this->inventory->getItemInHand())){ //always fire the hook, even if we are survival
|
||||||
$this->inventory->setItemInHand($heldItem);
|
$this->inventory->setItemInHand($heldItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user