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()]); } }
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; }
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; }