Hi, I have been getting this error on this particular line. Anyone know why? I have used the correct "use" functions but still throws up this error. PHP: // Item gather $ds = Item::getItem(276, 0, 1); // D Sword - line 117 $h = Item::getItem(310, 0, 1); // D Helmet $c = Item::getItem(311, 0, 1); // D Chestpiece $l = Item::getItem(312, 0, 1); // D Legging $b = Item::getItem(313, 0, 1); // D Boot // close Item gather PHP: Error:21.12 04:49:06 [Server] Server thread/CRITICAL Unhandled exception executing command 'kit infinity' in kit: Call to undefined method pocketmine\item\Item::getItem() Thanks
You cannot use Item::getItem() anyways (it doesn't exist in Item.php and extensions, and is a non-static function in BaseInventory). It's better to read the source and understand, than predicting.
Yes it works, but as Jack said it's bad practice; same as Server::getInstance(); it's bad practice. Just because something works doesn't mean that it should be done that way.
It sometimes doesn't work, because Item::get() returns an item with the proper class while new Item() always returns objects in Item type instead of using the proper subclass. This may result in some items displaying wrong names, or not behaving in the special actions as they should (e.g. when they are used on a block).