InventoryAPI
PocketMine-MP APIv4.0.0
Example
OneBlockInventory
use pocketmine\block\BlockLegacyIds;
use pocketmine\player\Player;
use pocketmine\network\mcpe\protocol\types\inventory\WindowTypes;
use skymin\InventoryAPI\OneBlockInventory;
class TestInv extends OneBlockInventory{
public function __construct(Player $player){
parent::__construct($player->getPosition(), BlockLegacyIds::HOPPER_BLOCK, WindowTypes::HOPPER, 5, 'test')
}
}
DoubleChestInventory
use pocketmine\player\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\item\ItemFactory;
use skymin\InventoryAPI\DoubleChestInventory;
class TestInv extends DoubleChestInventory{
protected $plugin;
public function __construct(Player $player, PluginBase $plugin){
parent::__construct($plugin->getScheduler(), $player->getPosition(), 'test');
$this->plugin = $plugin;
}
public function onOpen(Player $who) :void{
parent::onOpen($who);
$this->plugin->getScheduler()->scheduleDelayedTask(new ClosureTask(function() : void{
$this->setItem(40, ItemFactory::getInstance()->get(1));
}), 8); //If you do not do this, it may not apply.
}
}