mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-29 22:59:59 +00:00
PlayerInventory: Send updates to viewers automatically on setItemInHand()
This commit is contained in:
parent
c90e3e351d
commit
ff6d590d0c
@ -2227,7 +2227,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
if($this->isSurvival()){
|
if($this->isSurvival()){
|
||||||
if(!$item->equalsExact($this->inventory->getItemInHand())){
|
if(!$item->equalsExact($this->inventory->getItemInHand())){
|
||||||
$this->inventory->setItemInHand($item);
|
$this->inventory->setItemInHand($item);
|
||||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
|
||||||
}
|
}
|
||||||
$this->exhaust(0.025, PlayerExhaustEvent::CAUSE_MINING);
|
$this->exhaust(0.025, PlayerExhaustEvent::CAUSE_MINING);
|
||||||
}
|
}
|
||||||
@ -2272,7 +2271,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
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($this->inventory->getItemInHand())){
|
||||||
$this->inventory->setItemInHand($item);
|
$this->inventory->setItemInHand($item);
|
||||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,12 @@ class PlayerInventory extends BaseInventory{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setItemInHand(Item $item) : bool{
|
public function setItemInHand(Item $item) : bool{
|
||||||
return $this->setItem($this->getHeldItemIndex(), $item);
|
if($this->setItem($this->getHeldItemIndex(), $item)){
|
||||||
|
$this->sendHeldItem($this->holder->getViewers());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user