Hello all, I have a preblem. My inventory do not send to player when I use this: $player->addWindow($chest->getInventory); Can you help me ? Code of my inventory : https://pastebin.com/gz9tfjjR Thanks for your help.
Code: public function onOpen(Player $who) : void{ parent::onOpen($who); if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){ $this->broadcastBlockEventPacket(true); $this->getHolder()->getLevelNonNull()->broadcastLevelSoundEvent($this->getHolder()->add(0.5, 0.5, 0.5), $this->getOpenSound()); } $this->sendContents($who); }
Code: public function onOpen(Player $who) : void{ parent::onOpen($who); $this->sendContents($who); if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){ $this->broadcastBlockEventPacket(true); $this->getHolder()->getLevelNonNull()->broadcastLevelSoundEvent($this->getHolder()->add(0.5, 0.5, 0.5), $this->getOpenSound()); } }
Code when i send inventory : Code: public function onActivate(Item $item, Player $player = null): bool { if($player instanceof Player){ $t = $this->getLevelNonNull()->getTile($this); $chest = null; if($t instanceof DrawerTile){ $chest = $t; }else{ $chest = Tile::createTile(Tile::DRAWER, $this->getLevelNonNull(), DrawerTile::createNBT($this)); if(!($chest instanceof DrawerTile)){ return true; } } $player->addWindow($chest->getInventory()); } return true; }