mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Fixed Inventory->removeItem()
This commit is contained in:
parent
204915450f
commit
747fdab389
@ -124,7 +124,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
$item = clone $item;
|
$item = clone $item;
|
||||||
if($index < 0 or $index >= $this->size){
|
if($index < 0 or $index >= $this->size){
|
||||||
return false;
|
return false;
|
||||||
}elseif($item->getID() === 0){
|
}elseif($item->getID() === 0 or $item->getCount() <= 0){
|
||||||
$this->clear($index, $source);
|
$this->clear($index, $source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,16 +275,11 @@ abstract class BaseInventory implements Inventory{
|
|||||||
if($slot->equals($item, $slot->getDamage() === null ? false : true)){
|
if($slot->equals($item, $slot->getDamage() === null ? false : true)){
|
||||||
$amount = min($item->getCount(), $slot->getCount());
|
$amount = min($item->getCount(), $slot->getCount());
|
||||||
$slot->setCount($slot->getCount() - $amount);
|
$slot->setCount($slot->getCount() - $amount);
|
||||||
$old = clone $item;
|
|
||||||
$item->setCount($item->getCount() - $amount);
|
$item->setCount($item->getCount() - $amount);
|
||||||
|
$this->setItem($i, $item);
|
||||||
if($slot->getCount() <= 0){
|
if($slot->getCount() <= 0){
|
||||||
unset($slots[$index]);
|
unset($slots[$index]);
|
||||||
}
|
}
|
||||||
if($item->getCount() <= 0){
|
|
||||||
$this->clear($i);
|
|
||||||
}else{
|
|
||||||
$this->onSlotChange($i, $old);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user