Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created May 10, 2020 07:38
Show Gist options
  • Save PJZ9n/d162ad7942faaca1de7c039247cd580e to your computer and use it in GitHub Desktop.
Save PJZ9n/d162ad7942faaca1de7c039247cd580e to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
use pocketmine\item\Item;
/** @var \pocketmine\Player $player */
$count = 0;//アイテムの個数
//調べたいアイテム
$item = Item::get(Item::STONE);
//インベントリの中からそのアイテムを全取得
foreach ($player->getInventory()->all($item) as $value) {
$count += $value->getCount();//個数を$countに足す
}
//$countに数が入る
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment