How i can open a chest inventory Code: <?php /* * Plugin created by Denzel Code */ namespace ChestCommands\Commands; // Plugin use pocketmine\utils\TextFormat as Color; use ChestCommands\Main; // Commands use pocketmine\command\{Command, CommandSender}; // Player use pocketmine\Player; use pocketmine\entity\Entity; // Vector use pocketmine\math\Vector3; // Level use pocketmine\level\Level; // Particles use pocketmine\level\particle\FloatingTextParticle; // Tiles use pocketmine\tile\Tile; use pocketmine\tile\Sign; // Nbt use pocketmine\nbt\NBT; use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\CompoundTag; /** * Main Class * * @author Denzel Code */ class ChestCommands extends Command { private $main; public function __construct(Main $plugin) { $this->main = $plugin; parent::__construct('chestcommands', 'ChestCommand Command', '/chestcommands <argument>', [ 'cc', 'ccmd' ]); } public function getMain() { return $this->main; } public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender instanceof Player) { $position = [ $sender->getX(), $sender->getY(), $sender->getZ() ]; $level = $sender->getLevel(); // $position = new Vector3($position[0], $position[1], $position[2]); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new StringTag("CustomName", "Insert Custom Name Here"), new IntTag("x", $position[0]), new IntTag("y", $position[1]), new IntTag("z", $position[2]) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $chest = Tile::createTile(Tile::CHEST, $level, $nbt); if ($chest instanceof \pocketmine\tile\Chest) { $sender->addWindow($chest->getInventory()); } else { $sender->sendMessage("cant"); } $sender->sendMessage("Testing"); } } } ?>
What do you mean, you could do $addWindow($player->getInventory()); Or do you want it to open a chest inventory?
PHP: if ($sender instanceof Player) { $position = [$sender->getX() - 2, $sender->getY() - 2, $sender->getZ() - 2]; // two blocks under the player so it isn't seen $level = $sender->getLevel(); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new StringTag("CustomName", "Insert Custom Name Here"), new IntTag("x", $position[0]), new IntTag("y", $position[1]), new IntTag("z", $position[2]) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $chest = Tile::createTile(Tile::CHEST, $level, $nbt); if ($chest instanceof \pocketmine\tile\Chest) { $sender->addWindow($chest->getInventory()); } else { $sender->sendMessage("Failed to create Chest Tile"); } $sender->sendMessage("End of Command"); }
$addWindow isn't a function, it's a variable... $player->addWindow($chest->getInventory()); $chest is ChestTile
Yes i know, but I never said that $addWindow was a function and also didn't use $chest so really i don't get your point.
I already mentioned that $chest is a "chest tile", read my full post instead of replying with excitement