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) : array{ $p = []; if($this->entityId === null){ $this->entityId = Entity::nextRuntimeId(); }else{ $p[] = RemoveActorPacket::create($this->entityId); } if(!$this->invisible){ $name = $this->title . ($this->text !== "" ? "\n" . $this->text : ""); $actorFlags = ( 1 << EntityMetadataFlags::IMMOBILE ); $actorMetadata = [ EntityMetadataProperties::FLAGS => new LongMetadataProperty($actorFlags), EntityMetadataProperties::SCALE => new FloatMetadataProperty(0.01), //zero causes problems on debug builds EntityMetadataProperties::BOUNDING_BOX_WIDTH => new FloatMetadataProperty(0.0), EntityMetadataProperties::BOUNDING_BOX_HEIGHT => new FloatMetadataProperty(0.0), EntityMetadataProperties::NAMETAG => new StringMetadataProperty($name), EntityMetadataProperties::VARIANT => new IntMetadataProperty(RuntimeBlockMapping::getInstance()->toRuntimeId(VanillaBlocks::AIR()->getFullId())), EntityMetadataProperties::ALWAYS_SHOW_NAMETAG => new ByteMetadataProperty(1), ]; $p[] = AddActorPacket::create( $this->entityId, //TODO: actor unique ID $this->entityId, EntityIds::FALLING_BLOCK, $pos, //TODO: check offset (0.49?) null, 0, 0, 0, 0, [], $actorMetadata, new PropertySyncData([], []), [] ); } return $p; } }