Player: Stop setting held item post entity attack if changed (#3348)

closes #3340
This commit is contained in:
Andrés Arias 2020-03-10 11:09:31 +01:00 committed by GitHub
parent a6ca37429c
commit 89ea7f0a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2590,7 +2590,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($this->isAlive()){
//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
if($heldItem->onAttackEntity($target) and $this->isSurvival() and $heldItem->equalsExact($this->inventory->getItemInHand())){ //always fire the hook, even if we are survival
$this->inventory->setItemInHand($heldItem);
}