22 public const NETWORK_ID = ProtocolInfo::PLAYER_LOCATION_PACKET;
24 private PlayerLocationType $type;
25 private int $actorUniqueId;
31 private static function create(PlayerLocationType $type,
int $actorUniqueId, ?
Vector3 $position) :
self{
33 $result->type = $type;
34 $result->actorUniqueId = $actorUniqueId;
35 $result->position = $position;
39 public static function createCoordinates(
int $actorUniqueId,
Vector3 $position) :
self{
40 return self::create(PlayerLocationType::PLAYER_LOCATION_COORDINATES, $actorUniqueId, $position);
43 public static function createHide(
int $actorUniqueId) :
self{
44 return self::create(PlayerLocationType::PLAYER_LOCATION_HIDE, $actorUniqueId,
null);
47 public function getType() : PlayerLocationType{
return $this->type; }
49 public function getActorUniqueId() :
int{
return $this->actorUniqueId; }
51 public function getPosition() : ?
Vector3{
return $this->position; }
54 $this->type = PlayerLocationType::fromPacket($in->getLInt());
57 if($this->type === PlayerLocationType::PLAYER_LOCATION_COORDINATES){
63 $out->putLInt($this->type->value);
64 $out->putActorUniqueId($this->actorUniqueId);
66 if($this->type === PlayerLocationType::PLAYER_LOCATION_COORDINATES){
67 if($this->position ===
null){
68 throw new \LogicException(
"PlayerLocationPacket with type PLAYER_LOCATION_COORDINATES require a position to be provided");
75 return $handler->handlePlayerLocation($this);