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