Added API method Item->pop()

This commit is contained in:
Dylan K. Taylor
2017-09-27 10:55:50 +01:00
parent 7a77bb0402
commit c47f1f572c
6 changed files with 27 additions and 35 deletions

View File

@ -82,12 +82,8 @@ class ShapelessRecipe implements CraftingRecipe{
throw new \InvalidArgumentException("Shapeless recipes cannot have more than 9 ingredients");
}
$it = clone $item;
$it->setCount(1);
while($item->getCount() > 0){
$this->ingredients[] = clone $it;
$item->setCount($item->getCount() - 1);
$this->ingredients[] = $item->pop();
}
return $this;
@ -105,7 +101,7 @@ class ShapelessRecipe implements CraftingRecipe{
}
if($ingredient->equals($item, !$item->hasAnyDamageValue(), $item->hasCompoundTag())){
unset($this->ingredients[$index]);
$item->setCount($item->getCount() - 1);
$item->pop();
}
}