From d8198d81301c55aab5ee9cb75d2f97310e627682 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 14 Aug 2018 16:44:14 +0100 Subject: [PATCH] Fixed setItemInHand() regressions when placing or breaking blocks this was causing any items set into the hand during these events _at all_ to get overwritten, rather than just tools. That's a bit of a problem for buckets because buckets rely on a bad hack to handle the modified items. This doesn't fix the tools bug, but that's a job for another time. --- src/pocketmine/Player.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 7431086ec..7c1edd21d 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2233,9 +2233,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if($this->canInteract($pos->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 7) and !$this->isSpectator()){ $item = $this->inventory->getItemInHand(); + $oldItem = clone $item; if($this->level->useBreakOn($pos, $item, $this, true)){ if($this->isSurvival()){ - if(!$item->equalsExact($this->inventory->getItemInHand())){ + if(!$item->equalsExact($oldItem)){ $this->inventory->setItemInHand($item); } $this->exhaust(0.025, PlayerExhaustEvent::CAUSE_MINING); @@ -2278,8 +2279,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if($this->canInteract($pos->add(0.5, 0.5, 0.5), 13) and !$this->isSpectator()){ $item = $this->inventory->getItemInHand(); //this is a copy of the real item + $oldItem = clone $item; if($this->level->useItemOn($pos, $item, $face, $clickOffset, $this, true)){ - if($this->isSurvival() and !$item->equalsExact($this->inventory->getItemInHand())){ + if($this->isSurvival() and !$item->equalsExact($oldItem)){ $this->inventory->setItemInHand($item); } return true;