21 public const NETWORK_ID = ProtocolInfo::CLIENT_MOVEMENT_PREDICTION_SYNC_PACKET;
23 public const FLAG_LENGTH = 123;
29 private float $height;
31 private float $movementSpeed;
32 private float $underwaterMovementSpeed;
33 private float $lavaMovementSpeed;
34 private float $jumpStrength;
35 private float $health;
36 private float $hunger;
38 private int $actorUniqueId;
39 private bool $actorFlyingState;
44 private static function internalCreate(
50 float $underwaterMovementSpeed,
51 float $lavaMovementSpeed,
56 bool $actorFlyingState,
59 $result->flags = $flags;
60 $result->scale = $scale;
61 $result->width = $width;
62 $result->height = $height;
63 $result->movementSpeed = $movementSpeed;
64 $result->underwaterMovementSpeed = $underwaterMovementSpeed;
65 $result->lavaMovementSpeed = $lavaMovementSpeed;
66 $result->jumpStrength = $jumpStrength;
67 $result->health = $health;
68 $result->hunger = $hunger;
69 $result->actorUniqueId = $actorUniqueId;
70 $result->actorFlyingState = $actorFlyingState;
74 public static function create(
80 float $underwaterMovementSpeed,
81 float $lavaMovementSpeed,
86 bool $actorFlyingState,
88 if($flags->getLength() !== self::FLAG_LENGTH){
89 throw new \InvalidArgumentException(
"Input flags must be " . self::FLAG_LENGTH .
" bits long");
92 return self::internalCreate($flags, $scale, $width, $height, $movementSpeed, $underwaterMovementSpeed, $lavaMovementSpeed, $jumpStrength, $health, $hunger, $actorUniqueId, $actorFlyingState);
95 public function getFlags() :
BitSet{
return $this->flags; }
97 public function getScale() :
float{
return $this->scale; }
99 public function getWidth() :
float{
return $this->width; }
101 public function getHeight() :
float{
return $this->height; }
103 public function getMovementSpeed() :
float{
return $this->movementSpeed; }
105 public function getUnderwaterMovementSpeed() :
float{
return $this->underwaterMovementSpeed; }
107 public function getLavaMovementSpeed() :
float{
return $this->lavaMovementSpeed; }
109 public function getJumpStrength() :
float{
return $this->jumpStrength; }
111 public function getHealth() :
float{
return $this->health; }
113 public function getHunger() :
float{
return $this->hunger; }
115 public function getActorUniqueId() :
int{
return $this->actorUniqueId; }
117 public function getActorFlyingState() :
bool{
return $this->actorFlyingState; }
120 $this->flags =
BitSet::read($in, self::FLAG_LENGTH);
125 $this->underwaterMovementSpeed = $in->
getLFloat();
126 $this->lavaMovementSpeed = $in->
getLFloat();
131 $this->actorFlyingState = $in->
getBool();
135 $this->flags->write($out);
136 $out->putLFloat($this->scale);
137 $out->putLFloat($this->width);
138 $out->putLFloat($this->height);
139 $out->putLFloat($this->movementSpeed);
140 $out->putLFloat($this->underwaterMovementSpeed);
141 $out->putLFloat($this->lavaMovementSpeed);
142 $out->putLFloat($this->jumpStrength);
143 $out->putLFloat($this->health);
144 $out->putLFloat($this->hunger);
145 $out->putActorUniqueId($this->actorUniqueId);
146 $out->putBool($this->actorFlyingState);
150 return $handler->handleClientMovementPredictionSync($this);