text = $text; $this->title = $title; } public function getText() : string{ return $this->text; } public function setText(string $text) : void{ $this->text = $text; } public function getTitle() : string{ return $this->title; } public function setTitle(string $title) : void{ $this->title = $title; } public function isInvisible() : bool{ return $this->invisible; } public function setInvisible(bool $value = true) : void{ $this->invisible = $value; } public function encode(Vector3 $pos){ $p = []; if($this->entityId === null){ $this->entityId = EntityFactory::nextRuntimeId(); }else{ $pk0 = new RemoveEntityPacket(); $pk0->entityUniqueId = $this->entityId; $p[] = $pk0; } if(!$this->invisible){ $uuid = UUID::fromRandom(); $name = $this->title . ($this->text !== "" ? "\n" . $this->text : ""); $add = new PlayerListPacket(); $add->type = PlayerListPacket::TYPE_ADD; $add->entries = [PlayerListEntry::createAdditionEntry($uuid, $this->entityId, $name, new Skin("Standard_Custom", str_repeat("\x00", 8192)))]; $p[] = $add; $pk = new AddPlayerPacket(); $pk->uuid = $uuid; $pk->username = $name; $pk->entityRuntimeId = $this->entityId; $pk->position = $pos; //TODO: check offset $pk->item = ItemFactory::get(Item::AIR, 0, 0); $flags = ( 1 << Entity::DATA_FLAG_IMMOBILE ); $pk->metadata = [ Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, $flags], Entity::DATA_SCALE => [Entity::DATA_TYPE_FLOAT, 0.01] //zero causes problems on debug builds ]; $p[] = $pk; $remove = new PlayerListPacket(); $remove->type = PlayerListPacket::TYPE_REMOVE; $remove->entries = [PlayerListEntry::createRemovalEntry($uuid)]; $p[] = $remove; } return $p; } }