Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cop.php
- public function spawnTo(Player $p) {
- $uuid = $this->getUniqueId();
- $pk = new AddPlayerPacket();
- $pk->eid = $this->getId();
- $pk->uuid = $uuid;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->speedX = 0;
- $pk->speedY = 0;
- $pk->speedZ = 0;
- $pk->yaw = 0;
- $pk->pitch = 0;
- $this->setNameTag($this->namedtag->displayname);
- $this->setNameTagAlwaysVisible(true);
- $this->setNameTagVisible(true);
- $pk->metadata = $this->dataProperties;
- $pk->metadata[self::DATA_NAMETAG] = [self::DATA_TYPE_STRING];
- $p->dataPacket($pk);
- $player->server->removePlayerListData($uuid, [$p]);
- Server::getInstance()->removePlayerListData($this->getUniqueId(), [$p]);
- $this->saveNBT();
- parent::spawnTo($p);
- }
- // Utils.php
- public static function addCop($player, $name = null) : CompoundTag {
- $nbt = new CompoundTag;
- $name = TF::DARK_RED . TF::BOLD . 'SECURITY ' . TF::RESET . TF::AQUA . ($name ?? CopData::randomName());
- $nbt->Pos = new ListTag("Pos", [
- new DoubleTag("", $player->x),
- new DoubleTag("", $player->y),
- new DoubleTag("", $player->z)
- ]);
- $nbt->Rotation = new ListTag("Rotation", [
- new FloatTag("", $player->yaw),
- new FloatTag("", $player->pitch)
- ]);
- $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data", $player->getSkinData()), "Name" => new StringTag("Name", $player->getSkinId())]);
- $nbt->Health = new ShortTag("Health", 20);
- $nbt->Invulnerable = new ByteTag("Invulnerable", 1);
- $nbt->CustomName = new StringTag("CustomName", $name);
- $nbt->displayname = $name;
- $level = $player->getLevel();
- $entity = Entity::createEntity("Cop", $level, $nbt);
- $entity->spawnToAll();
- $entity->saveNBT();
- PrisonCore::$npcs["Cop"][] = $nbt;
- return $nbt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement