25 public const NETWORK_ID = ProtocolInfo::PLAYER_LOCATION_PACKET;
27 private PlayerLocationType $type;
28 private int $actorUniqueId;
34 private static function create(PlayerLocationType $type,
int $actorUniqueId, ?
Vector3 $position) :
self{
36 $result->type = $type;
37 $result->actorUniqueId = $actorUniqueId;
38 $result->position = $position;
42 public static function createCoordinates(
int $actorUniqueId,
Vector3 $position) :
self{
43 return self::create(PlayerLocationType::PLAYER_LOCATION_COORDINATES, $actorUniqueId, $position);
46 public static function createHide(
int $actorUniqueId) :
self{
47 return self::create(PlayerLocationType::PLAYER_LOCATION_HIDE, $actorUniqueId,
null);
50 public function getType() : PlayerLocationType{
return $this->type; }
52 public function getActorUniqueId() :
int{
return $this->actorUniqueId; }
54 public function getPosition() : ?
Vector3{
return $this->position; }
57 $this->type = PlayerLocationType::fromPacket(LE::readUnsignedInt($in));
58 $this->actorUniqueId = CommonTypes::getActorUniqueId($in);
60 if($this->type === PlayerLocationType::PLAYER_LOCATION_COORDINATES){
61 $this->position = CommonTypes::getVector3($in);
66 LE::writeUnsignedInt($out, $this->type->value);
67 CommonTypes::putActorUniqueId($out, $this->actorUniqueId);
69 if($this->type === PlayerLocationType::PLAYER_LOCATION_COORDINATES){
70 if($this->position ===
null){
71 throw new \LogicException(
"PlayerLocationPacket with type PLAYER_LOCATION_COORDINATES require a position to be provided");
73 CommonTypes::putVector3($out, $this->position);
78 return $handler->handlePlayerLocation($this);