public function first(Item $item) { $count = max(1, $item->getCount()); $checkDamage = $item->getDamage() === null ? false : true; $checkTags = $item->getCompoundTag() === null ? false : true; foreach ($this->getContents() as $index => $i) { if ($item->equals($i, $checkDamage, $checkTags) and $i->getCount() >= $count) { return $index; } } return -1; }
/** * @param Item $item * @return int */ public static function getCreativeItemIndex(Item $item) { foreach (Item::$creative as $i => $d) { if ($item->equals($d, !$item->isTool())) { return $i; } } return -1; }