Inventory: drop $send params from setItem() and clear()

This commit is contained in:
Dylan K. Taylor 2020-02-12 13:34:35 +00:00
parent 1c06438cbb
commit b108fb61bf
4 changed files with 14 additions and 16 deletions

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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{

View File

@ -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