mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Added API method Item::canStackWith()
This commit is contained in:
@ -84,7 +84,7 @@ class CraftingTransaction extends InventoryTransaction{
|
||||
$recipeItem = array_pop($recipeItems);
|
||||
$needCount = $recipeItem->getCount();
|
||||
foreach($recipeItems as $i => $otherRecipeItem){
|
||||
if($otherRecipeItem->equals($recipeItem)){ //make sure they have the same wildcards set
|
||||
if($otherRecipeItem->canStackWith($recipeItem)){ //make sure they have the same wildcards set
|
||||
$needCount += $otherRecipeItem->getCount();
|
||||
unset($recipeItems[$i]);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ class InventoryTransaction{
|
||||
|
||||
foreach($needItems as $i => $needItem){
|
||||
foreach($haveItems as $j => $haveItem){
|
||||
if($needItem->equals($haveItem)){
|
||||
if($needItem->canStackWith($haveItem)){
|
||||
$amount = min($needItem->getCount(), $haveItem->getCount());
|
||||
$needItem->setCount($needItem->getCount() - $amount);
|
||||
$haveItem->setCount($haveItem->getCount() - $amount);
|
||||
|
Reference in New Issue
Block a user