mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Fix crash when new players join due to attempting to send negative inventory slot
This commit is contained in:
parent
57379b93ce
commit
2f306c3a38
@ -103,6 +103,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
|
||||
public function getItem($index){
|
||||
assert($index >= 0, "Inventory slot should not be negative");
|
||||
return isset($this->slots[$index]) ? clone $this->slots[$index] : Item::get(Item::AIR, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -214,16 +214,13 @@ class PlayerInventory extends BaseInventory{
|
||||
|
||||
if(!is_array($target)){
|
||||
$target->dataPacket($pk);
|
||||
if($target === $this->getHolder()){
|
||||
if($this->getHeldItemSlot() !== -1 and $target === $this->getHolder()){
|
||||
$this->sendSlot($this->getHeldItemSlot(), $target);
|
||||
}
|
||||
}else{
|
||||
$this->getHolder()->getLevel()->getServer()->broadcastPacket($target, $pk);
|
||||
foreach($target as $player){
|
||||
if($player === $this->getHolder()){
|
||||
$this->sendSlot($this->getHeldItemSlot(), $player);
|
||||
break;
|
||||
}
|
||||
if($this->getHeldItemSlot() !== -1 and in_array($this->getHolder(), $target)){
|
||||
$this->sendSlot($this->getHeldItemSlot(), $this->getHolder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user