mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
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.
This commit is contained in:
parent
cef1fe9524
commit
d8198d8130
@ -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()){
|
if($this->canInteract($pos->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 7) and !$this->isSpectator()){
|
||||||
$item = $this->inventory->getItemInHand();
|
$item = $this->inventory->getItemInHand();
|
||||||
|
$oldItem = clone $item;
|
||||||
if($this->level->useBreakOn($pos, $item, $this, true)){
|
if($this->level->useBreakOn($pos, $item, $this, true)){
|
||||||
if($this->isSurvival()){
|
if($this->isSurvival()){
|
||||||
if(!$item->equalsExact($this->inventory->getItemInHand())){
|
if(!$item->equalsExact($oldItem)){
|
||||||
$this->inventory->setItemInHand($item);
|
$this->inventory->setItemInHand($item);
|
||||||
}
|
}
|
||||||
$this->exhaust(0.025, PlayerExhaustEvent::CAUSE_MINING);
|
$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()){
|
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
|
$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->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);
|
$this->inventory->setItemInHand($item);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user