onOpen() публичный Метод

public onOpen ( Player $who )
$who pocketmine\Player
Пример #1
0
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     if (count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 2;
         Server::broadcastPacket($this->getHolder()->getLevel()->getPlayers(), $pk);
     }
 }
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     if (count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 2;
         if (($level = $this->getHolder()->getLevel()) instanceof Level) {
             $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
         }
     }
 }
Пример #3
0
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     if ($this->levels == null) {
         $this->bookshelfAmount = $this->countBookshelf();
         if ($this->bookshelfAmount < 0) {
             $this->bookshelfAmount = 0;
         }
         if ($this->bookshelfAmount > 15) {
             $this->bookshelfAmount = 15;
         }
         $base = mt_rand(1, 8) + $this->bookshelfAmount / 2 + mt_rand(0, $this->bookshelfAmount);
         $this->levels = [0 => max($base / 3, 1), 1 => $base * 2 / 3 + 1, 2 => max($base, $this->bookshelfAmount * 2)];
     }
 }
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     if (count($this->getViewers()) === 1) {
         $pk = new BlockEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 2;
         if (($level = $this->getHolder()->getLevel()) instanceof Level) {
             $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk);
         }
     }
 }
Пример #5
0
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     if (count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 2;
         if (($level = $this->getHolder()->getLevel()) instanceof Level) {
             Server::broadcastPacket($level->getUsingChunk($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4), $pk);
         }
     }
 }
Пример #6
0
 public function onOpen(Player $who)
 {
     parent::onOpen($who);
     if (count($this->getViewers()) === 1) {
         $pk = new BlockEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 2;
         if (($level = $this->getHolder()->getLevel()) instanceof Level) {
             $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk);
         }
     }
     /** @var TrappedChest $block */
     $block = $this->getHolder()->getBlock();
     if ($block instanceof TrappedChest) {
         if (!$block->isActivated()) {
             $block->activate();
         }
     }
 }