Fixed giving large amount of items, updated player inventory to correct size

This commit is contained in:
Shoghi Cervantes
2014-05-25 16:26:46 +02:00
parent 4f2856dc09
commit 933a28537b
2 changed files with 12 additions and 1 deletions

View File

@ -205,6 +205,17 @@ abstract class BaseInventory implements Inventory{
public function addItem(){
/** @var Item[] $slots */
$slots = func_get_args();
foreach($slots as $i => $slot){
if($slot->getCount() > $slot->getMaxStackSize()){
while($slot->getCount() > $slot->getMaxStackSize()){
$slots[] = Item::get($slot->getID(), $slot->getDamage(), $slot->getMaxStackSize());
$slot->setCount($slot->getCount() - $slot->getMaxStackSize());
if(count($slots) > $this->getSize()){ //Protect against large give commands
break;
}
}
}
}
for($i = 0; $i < $this->size; ++$i){
$item = $this->getItem($i);
if($item->getID() === Item::AIR){