22 public const NETWORK_ID = ProtocolInfo::CLIENT_MOVEMENT_PREDICTION_SYNC_PACKET;
24 public const FLAG_LENGTH = EntityMetadataFlags::NUMBER_OF_FLAGS;
30 private float $height;
32 private float $movementSpeed;
33 private float $underwaterMovementSpeed;
34 private float $lavaMovementSpeed;
35 private float $jumpStrength;
36 private float $health;
37 private float $hunger;
39 private int $actorUniqueId;
40 private bool $actorFlyingState;
45 private static function internalCreate(
51 float $underwaterMovementSpeed,
52 float $lavaMovementSpeed,
57 bool $actorFlyingState,
60 $result->flags = $flags;
61 $result->scale = $scale;
62 $result->width = $width;
63 $result->height = $height;
64 $result->movementSpeed = $movementSpeed;
65 $result->underwaterMovementSpeed = $underwaterMovementSpeed;
66 $result->lavaMovementSpeed = $lavaMovementSpeed;
67 $result->jumpStrength = $jumpStrength;
68 $result->health = $health;
69 $result->hunger = $hunger;
70 $result->actorUniqueId = $actorUniqueId;
71 $result->actorFlyingState = $actorFlyingState;
75 public static function create(
81 float $underwaterMovementSpeed,
82 float $lavaMovementSpeed,
87 bool $actorFlyingState,
89 if($flags->getLength() !== self::FLAG_LENGTH){
90 throw new \InvalidArgumentException(
"Input flags must be " . self::FLAG_LENGTH .
" bits long");
93 return self::internalCreate($flags, $scale, $width, $height, $movementSpeed, $underwaterMovementSpeed, $lavaMovementSpeed, $jumpStrength, $health, $hunger, $actorUniqueId, $actorFlyingState);
96 public function getFlags() :
BitSet{
return $this->flags; }
98 public function getScale() :
float{
return $this->scale; }
100 public function getWidth() :
float{
return $this->width; }
102 public function getHeight() :
float{
return $this->height; }
104 public function getMovementSpeed() :
float{
return $this->movementSpeed; }
106 public function getUnderwaterMovementSpeed() :
float{
return $this->underwaterMovementSpeed; }
108 public function getLavaMovementSpeed() :
float{
return $this->lavaMovementSpeed; }
110 public function getJumpStrength() :
float{
return $this->jumpStrength; }
112 public function getHealth() :
float{
return $this->health; }
114 public function getHunger() :
float{
return $this->hunger; }
116 public function getActorUniqueId() :
int{
return $this->actorUniqueId; }
118 public function getActorFlyingState() :
bool{
return $this->actorFlyingState; }
121 $this->flags =
BitSet::read($in, self::FLAG_LENGTH);
126 $this->underwaterMovementSpeed = $in->
getLFloat();
127 $this->lavaMovementSpeed = $in->
getLFloat();
132 $this->actorFlyingState = $in->
getBool();
136 $this->flags->write($out);
137 $out->putLFloat($this->scale);
138 $out->putLFloat($this->width);
139 $out->putLFloat($this->height);
140 $out->putLFloat($this->movementSpeed);
141 $out->putLFloat($this->underwaterMovementSpeed);
142 $out->putLFloat($this->lavaMovementSpeed);
143 $out->putLFloat($this->jumpStrength);
144 $out->putLFloat($this->health);
145 $out->putLFloat($this->hunger);
146 $out->putActorUniqueId($this->actorUniqueId);
147 $out->putBool($this->actorFlyingState);
151 return $handler->handleClientMovementPredictionSync($this);