So I get this error: [00:16:07] [Server thread/CRITICAL]: Could not execute task Sean_M\LootCrate\LootCrate: Call to a member function getInventory() on null [00:16:07] [Server thread/CRITICAL]: Error: "Call to a member function getInventory() on null" (EXCEPTION) in "/plugins/LootCrate-master/src/Sean_M/LootCrate/LootCrate" at line 38 This is my code: PHP: <?phpnamespace Sean_M\LootCrate;use pocketmine\block\Block;use pocketmine\inventory\Inventory;use pocketmine\level\Level;use pocketmine\scheduler\PluginTask;use pocketmine\utils\TextFormat as TF;use pocketmine\Server;use pocketmine\event\Listener;use pocketmine\math\Vector3;class LootCrate extends PluginTask implements listener { ##Rhorerien LEVEL NAME FOR REFERENCE ##$this->getOwner()->getServer() public $plugin; public function __construct(Main $plugin) { parent::__construct($plugin); $this->plugin = $plugin; } public function onRun($currentTick) { $level = $this->getOwner()->getServer()->getLevelByName("Rhorerien"); $x = mt_rand(0,255); $y = mt_rand(0,255); $z = mt_rand(0,255); $pos = new Vector3($x, $y, $z); $block = Block::get(Block::CHEST); $level->setBlock($pos, $block); $chest = $level->getTile($pos); $slot = mt_rand(0,27); foreach($this->getOwner()->getconfig()->get("items") as $item){ $chest->getInventory()->setItem($slot, $item); $cx = $chest->getX(); $cy = $chest->getY(); $cz = $chest->getZ(); $cpos = new Vector3($cx, $cy, $cz); if($this->config->get("broadcast.message") == "true"){ $this->getServer()->broadcastMessage($this->config->get("message", str_replace("{CHEST}", $cpos))); } } }}
There is no chest tile at $pos You tried to set a chest block, but not a tile. Please check the chest code in PM on how to create a tile
Simply call https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/block/Chest.php#L71 place() with the proper params.