This is possibly a good example to use in your code PHP: public function matchItem(Item $neededItem) { $items = $player->getInventory()->getContents(); foreach($items as $key => $item) { if($item->equals($neededItem)) { return $key; } return false; }} Note that unless the other parameters are set properly, the Item will only check for an exact match in the NBT tree and Item damage. https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/Item.php#L948
But it "should" work. Or you are doing something wrong. There's an alternative way if you want to check "deepEquals". PHP: /** @var BaseInventory $inv */?/** @var Item $item */$contents = $inv->getContents();$slot = array_search($item, $contents);if($slot === false){//don't use "==" here! //Item not found.}else{ //Item found and slot is $slot}