mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39:45 +00:00
Inventory: drop $send params from setItem() and clear()
This commit is contained in:
parent
1c06438cbb
commit
b108fb61bf
@ -58,8 +58,8 @@ class CraftingGrid extends BaseInventory{
|
||||
return $this->gridWidth;
|
||||
}
|
||||
|
||||
public function setItem(int $index, Item $item, bool $send = true) : void{
|
||||
parent::setItem($index, $item, $send);
|
||||
public function setItem(int $index, Item $item) : void{
|
||||
parent::setItem($index, $item);
|
||||
$this->seekRecipeBounds();
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
}
|
||||
|
||||
public function setItem(int $index, Item $item, bool $send = true) : void{
|
||||
public function setItem(int $index, Item $item) : void{
|
||||
if($item->isNull()){
|
||||
$item = ItemFactory::air();
|
||||
}else{
|
||||
@ -129,7 +129,7 @@ abstract class BaseInventory implements Inventory{
|
||||
$oldItem = $this->getItem($index);
|
||||
|
||||
$this->slots[$index] = $item->isNull() ? null : $item;
|
||||
$this->onSlotChange($index, $oldItem, $send);
|
||||
$this->onSlotChange($index, $oldItem);
|
||||
}
|
||||
|
||||
public function contains(Item $item) : bool{
|
||||
@ -313,8 +313,8 @@ abstract class BaseInventory implements Inventory{
|
||||
return $itemSlots;
|
||||
}
|
||||
|
||||
public function clear(int $index, bool $send = true) : void{
|
||||
$this->setItem($index, ItemFactory::air(), $send);
|
||||
public function clear(int $index) : void{
|
||||
$this->setItem($index, ItemFactory::air());
|
||||
}
|
||||
|
||||
public function clearAll(bool $send = true) : void{
|
||||
@ -359,14 +359,12 @@ abstract class BaseInventory implements Inventory{
|
||||
unset($this->viewers[spl_object_id($who)]);
|
||||
}
|
||||
|
||||
protected function onSlotChange(int $index, Item $before, bool $send) : void{
|
||||
protected function onSlotChange(int $index, Item $before) : void{
|
||||
foreach($this->listeners as $listener){
|
||||
$listener->onSlotChange($this, $index);
|
||||
}
|
||||
if($send){
|
||||
foreach($this->viewers as $viewer){
|
||||
$viewer->getNetworkSession()->getInvManager()->syncSlot($this, $index);
|
||||
}
|
||||
foreach($this->viewers as $viewer){
|
||||
$viewer->getNetworkSession()->getInvManager()->syncSlot($this, $index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,10 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
|
||||
return $index < $this->left->getSize() ? $this->left->getItem($index) : $this->right->getItem($index - $this->left->getSize());
|
||||
}
|
||||
|
||||
public function setItem(int $index, Item $item, bool $send = true) : void{
|
||||
public function setItem(int $index, Item $item) : void{
|
||||
$old = $this->getItem($index);
|
||||
$index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send);
|
||||
$this->onSlotChange($index, $old, $send);
|
||||
$index < $this->left->getSize() ? $this->left->setItem($index, $item) : $this->right->setItem($index - $this->left->getSize(), $item);
|
||||
$this->onSlotChange($index, $old);
|
||||
}
|
||||
|
||||
public function getContents(bool $includeEmpty = false) : array{
|
||||
|
@ -43,7 +43,7 @@ interface Inventory{
|
||||
/**
|
||||
* Puts an Item in a slot.
|
||||
*/
|
||||
public function setItem(int $index, Item $item, bool $send = true) : void;
|
||||
public function setItem(int $index, Item $item) : void;
|
||||
|
||||
/**
|
||||
* Stores the given Items in the inventory. This will try to fill
|
||||
@ -122,7 +122,7 @@ interface Inventory{
|
||||
/**
|
||||
* Will clear a specific slot
|
||||
*/
|
||||
public function clear(int $index, bool $send = true) : void;
|
||||
public function clear(int $index) : void;
|
||||
|
||||
/**
|
||||
* Clears all the slots
|
||||
|
Loading…
x
Reference in New Issue
Block a user