https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/inventory/BaseInventory.php#L202 foreach the output of $inventory->all(Item) and total the getCount() function from each returned item into one variable
I know this is an old thread, but how can I "total the getCount() function from each returned item into one variable?" This is what I've done so far: $items = Item::get(4, 0, 1); foreach ($inventory->all($items) as $item){ $count = $item->getCount(); return $count; }
PHP: $item_count = 0;/** @var Item $item */foreach($inventory->all(Item::get(Item::COBBLESTONE)) as $item) { $item_count += $item->getCount();}