Inheritance: extends DataPacket
コード例 #1
0
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     $pk = new ContainerOpenPacket();
     $pk->windowid = $who->getWindowId($this);
     $pk->type = $this->getType()->getNetworkType();
     $pk->slots = $this->getSize();
     $holder = $this->getHolder();
     if ($holder instanceof Vector3) {
         $pk->x = $holder->getX();
         $pk->y = $holder->getY();
         $pk->z = $holder->getZ();
     } else {
         $pk->x = $pk->y = $pk->z = 0;
     }
     $who->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     $this->sendContents($who);
 }
コード例 #2
0
ファイル: PlayerHelper.php プロジェクト: robozeri/SG
 public static function openChest(Block $chest, Player $player)
 {
     if ($chest->getId() === Item::CHEST) {
         if ($player->gamemode === Player::CREATIVE) {
             $player->sendMessage("[HG] You are in creative Mode");
             return;
         }
         if (!$player->isOp()) {
             $pk = new ContainerOpenPacket();
             $pk->windowid = $player->getWindowId($player->getInventory());
             $pk->type = InventoryType::CHEST;
             $pk->slots = $player->getInventory()->getSize();
             $pk->x = $chest->x;
             $pk->y = $chest->y;
             $pk->z = $chest->z;
             $pk->encode();
             $player->directDataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
             if ($player->getInventory() != null) {
                 $player->getInventory()->sendContents($player);
             }
             $player->sendTip("chest open!");
         }
     }
 }