示例#1
0
 public function despawnFrom(Player $player)
 {
     if (isset($this->hasSpawned[$player->getLoaderId()])) {
         $pk = new RemovePlayerPacket();
         $pk->eid = $this->getId();
         $pk->clientId = $this->getUniqueId();
         $player->dataPacket($pk);
         unset($this->hasSpawned[$player->getLoaderId()]);
     }
 }
示例#2
0
 public function requestChunk($x, $z, Player $player)
 {
     $index = Level::chunkHash($x, $z);
     if (!isset($this->chunkSendQueue[$index])) {
         $this->chunkSendQueue[$index] = [];
     }
     $this->chunkSendQueue[$index][$player->getLoaderId()] = $player;
 }
示例#3
0
 public function onActivate(Item $item, Player $player = null)
 {
     if (($this->getDamage() & 0x8) === 0x8) {
         // Top
         $down = $this->getSide(0);
         if ($down->getId() === $this->getId()) {
             $meta = $down->getDamage() ^ 0x4;
             $this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), true);
             $players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
             if ($player instanceof Player) {
                 unset($players[$player->getLoaderId()]);
             }
             $this->getLevel()->addSound(new DoorSound($this));
             return true;
         }
         return false;
     } else {
         $this->meta ^= 0x4;
         $this->getLevel()->setBlock($this, $this, true);
         $players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
         if ($player instanceof Player) {
             unset($players[$player->getLoaderId()]);
         }
         $this->getLevel()->addSound(new DoorSound($this));
     }
     return true;
 }