Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. // Cop.php
  2. public function spawnTo(Player $p) {
  3.         $uuid = $this->getUniqueId();
  4.         $pk = new AddPlayerPacket();
  5.         $pk->eid = $this->getId();
  6.         $pk->uuid = $uuid;
  7.         $pk->x = $this->x;
  8.         $pk->y = $this->y;
  9.         $pk->z = $this->z;
  10.         $pk->speedX = 0;
  11.         $pk->speedY = 0;
  12.         $pk->speedZ = 0;
  13.         $pk->yaw = 0;
  14.         $pk->pitch = 0;
  15.         $this->setNameTag($this->namedtag->displayname);
  16.         $this->setNameTagAlwaysVisible(true);
  17.         $this->setNameTagVisible(true);
  18.         $pk->metadata = $this->dataProperties;
  19.         $pk->metadata[self::DATA_NAMETAG] = [self::DATA_TYPE_STRING];
  20.         $p->dataPacket($pk);
  21.         $player->server->removePlayerListData($uuid, [$p]);
  22.         Server::getInstance()->removePlayerListData($this->getUniqueId(), [$p]);
  23.         $this->saveNBT();
  24.         parent::spawnTo($p);
  25.     }
  26.  
  27. // Utils.php
  28.  
  29. public static function addCop($player, $name = null) : CompoundTag {
  30.         $nbt = new CompoundTag;
  31.         $name = TF::DARK_RED . TF::BOLD . 'SECURITY ' . TF::RESET . TF::AQUA . ($name ?? CopData::randomName());
  32.         $nbt->Pos = new ListTag("Pos", [
  33.             new DoubleTag("", $player->x),
  34.             new DoubleTag("", $player->y),
  35.             new DoubleTag("", $player->z)
  36.         ]);
  37.         $nbt->Rotation = new ListTag("Rotation", [
  38.             new FloatTag("", $player->yaw),
  39.             new FloatTag("", $player->pitch)
  40.         ]);
  41.         $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data", $player->getSkinData()), "Name" => new StringTag("Name", $player->getSkinId())]);
  42.         $nbt->Health = new ShortTag("Health", 20);
  43.         $nbt->Invulnerable = new ByteTag("Invulnerable", 1);
  44.         $nbt->CustomName = new StringTag("CustomName", $name);
  45.         $nbt->displayname = $name;
  46.         $level = $player->getLevel();
  47.         $entity = Entity::createEntity("Cop", $level, $nbt);
  48.         $entity->spawnToAll();
  49.         $entity->saveNBT();
  50.         PrisonCore::$npcs["Cop"][] = $nbt;
  51.         return $nbt;
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement