public function spawnTo(Player $player) { if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) { $this->hasSpawned[$player->getLoaderId()] = $player; $pk = new AddPlayerPacket(); $pk->uuid = $this->getUniqueId(); $pk->username = $this->getName(); $pk->eid = $this->getId(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = 0; $pk->speedY = 0; $pk->speedZ = 0; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $item = $this->getInventory()->getItemInHand(); $pk->item = $item; if ($player->hasPermission("slapper.seeownskin")) { $pk->skin = $player->getSkinData(); $pk->slim = $player->isSkinSlim(); } else { $pk->skin = $this->skin; $pk->slim = $this->isSlim; } $pk->metadata = [2 => [4, $this->getDataProperty(2)], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]]; $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); $this->inventory->sendArmorContents($player); } }
public function spawnTo(Player $player) { if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) { $this->hasSpawned[$player->getLoaderId()] = $player; $uuid = $this->getUniqueId(); $entityId = $this->getId(); $pk = new AddPlayerPacket(); $pk->uuid = $uuid; $pk->username = ""; $pk->eid = $entityId; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->item = $this->getInventory()->getItemInHand(); $pk->metadata = [2 => [4, str_ireplace("{name}", $player->getName(), str_ireplace("{display_name}", $player->getDisplayName(), $player->hasPermission("slapper.seeId") ? $this->getDataProperty(2) . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $entityId : $this->getDataProperty(2)))], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]]; $player->dataPacket($pk); $this->inventory->sendArmorContents($player); $add = new PlayerListPacket(); $add->type = 0; $add->entries[] = [$uuid, $entityId, isset($this->namedtag->MenuName) ? $this->namedtag["MenuName"] : "", $this->skinName, $this->skin]; $player->dataPacket($add); if ($this->namedtag["MenuName"] === "") { $remove = new PlayerListPacket(); $remove->type = 1; $remove->entries[] = [$uuid]; $player->dataPacket($remove); } } }
public function spawnTo(Player $player) { if (!isset($this->hasSpawned[$player->getLoaderId()]) && isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])) { $pk = new AddEntityPacket(); $pk->eid = $this->getID(); $pk->type = static::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = 0; $pk->speedY = 0; $pk->speedZ = 0; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk); $this->hasSpawned[$player->getLoaderId()] = $player; } }
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 despawnFrom(Player $player) { if (isset($this->hasSpawned[$player->getLoaderId()])) { $pk = new RemoveEntityPacket(); $pk->eid = $this->getId(); $player->dataPacket($pk); unset($this->hasSpawned[$player->getLoaderId()]); } }
public function despawnFrom(Player $player) { if (isset($this->hasSpawned[$player->getLoaderId()])) { if ($this instanceof Player) { $this->server->removePlayerListData($this->getUniqueId(), [$player]); } $pk = new RemovePlayerPacket(); $pk->eid = $this->getId(); $pk->clientId = $this->getUniqueId(); $player->dataPacket($pk); unset($this->hasSpawned[$player->getLoaderId()]); } }
/** * @param Player $player */ public function spawnTo(Player $player) { if (!isset($this->hasSpawned[$player->getLoaderId()]) and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])) { $this->hasSpawned[$player->getLoaderId()] = $player; } }
public function onActivate(Item $item, Player $player = null) { if (($this->getDamage() & 0x8) === 0x8) { //Top $down = $this->getSide(Vector3::SIDE_DOWN); 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->level->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->level->addSound(new DoorSound($this)); } return true; }
public function requestChunk($x, $z, Player $player) { $index = \PHP_INT_SIZE === 8 ? ($x & 0xffffffff) << 32 | $z & 0xffffffff : $x . ":" . $z; if (!isset($this->chunkSendQueue[$index])) { $this->chunkSendQueue[$index] = []; } $this->chunkSendQueue[$index][$player->getLoaderId()] = $player; }
public function requestChunk($x, $z, Player $player) { $index = ($x & 0xffffffff) << 32 | $z & 0xffffffff; if (!isset($this->chunkSendQueue[$index])) { $this->chunkSendQueue[$index] = []; } $this->chunkSendQueue[$index][$player->getLoaderId()] = $player; }
public function despawnFrom(Player $player) { if (isset($this->hasSpawned[$player->getLoaderId()])) { $pk = new RemovePlayerPacket(); $pk->eid = $this->getId(); $pk->clientID = $this->getId(); $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); unset($this->hasSpawned[$player->getLoaderId()]); } }
/** * * @param Player $player */ public function despawnFrom(Player $player) { if (isset($this->hasSpawned[$player->getLoaderId()])) { $pk = new RemovePlayerPacket(); $pk->eid = $this->getId(); $pk->clientId = $this->dummyReceiver->randomUUID; $player->dataPacket($pk); unset($this->hasSpawned[$player->getLoaderId()]); } }