I'm working on a pouches plugin and I need to know how to open an anvil inventory to a player on PlayerInteractEvent and add items to it!!
PHP: /** @var $player pocketmine\Player *//** @var $pos pocketmine\level\Position */$inv = new pocketmine\inventory\AnvilInventory($pos); //This is basically a normal inv, you can handle it like a player inventory with just 2 slots./** @var $item1 pocketmine\item\Item *//** @var $item2 pocketmine\item\Item */$inv->addItem($item1, $item2); //Add items to the inv, like a player inv.$player->addWindow($inv);
Are you trying to do this? Spoiler: long screenshot I don't think you can do that in OOP. I don't know much about function aliases in namespaces. Player itself is an instance of \pocketmine\Player. You can call the function from that player instance. PHP: /** @var Player */$player->addWindow(...); Look into PocketMine's source code to see how it's being called and handled.
Read the code: @var $pos pocketmine\level\Position Therefore $pos is a Positon object. (The position of the anvil)