How can I open a chest or an enderchest window on a players screen? Although there's no errors when executing the "/ender" command which is supposed to open an enderchest window, the enderchest window does not open at all. Here's my latest code: PHP: /** * @param Player $p */ public function openWindow(Player $p){ $eChestCfg = PocketLegionCore::getInstance()->getConfig()->getAll()["ender_chest_position"]; $x = (int)$eChestCfg["x"]; $y = (int)$eChestCfg["y"]; $z = (int)$eChestCfg["z"]; $level = PocketLegionCore::getInstance()->getServer()->getLevelByName($eChestCfg["level"]); $eChest = new EnderChestInventory($p); $eChest->openAt(new Position($x, $y, $z, $level)); }
EnderChestInventory is a class for the ender chest invetory. It's not implemented in PocketMine though so I'm wondering if there is another way to open an enderchest window to a player's screen.
The code you sent isn't causing the problem. The only real method being called is inside EnderChestInventory, which we know absolutely nothing about, therefore we can't point out whatever may be wrong with it.
Okay. This post exemplifies a lot, but you can use $player->addWindow($chest); with $player being an instance of pocketmine\Player, and $chest being an instance of pocketmine\tile\Chest.
Are there currently any API or Class that automatically saves items? It's a struggle having to create a database and having to write all that code for just for private vaults; obviously I'm not going to save items in a YAML file it would be stupid.
Actually it should be $chest being an instance of pocketmine\inventory\ChestInventory To use this method you need to spawn a chest block to the player, either setblock or use sendblocks If you want to save items in yaml that is completely possible, see https://github.com/diamond-gold/MiniBosses/blob/master/src/MiniBosses/Main.php#L105, to convert from string to Item https://github.com/diamond-gold/MiniBosses/blob/master/src/MiniBosses/Boss.php#L59