25 public const NETWORK_ID = ProtocolInfo::CLIENT_MOVEMENT_PREDICTION_SYNC_PACKET;
27 public const FLAG_LENGTH = EntityMetadataFlags::NUMBER_OF_FLAGS;
33 private float $height;
35 private float $movementSpeed;
36 private float $underwaterMovementSpeed;
37 private float $lavaMovementSpeed;
38 private float $jumpStrength;
39 private float $health;
40 private float $hunger;
42 private int $actorUniqueId;
43 private bool $actorFlyingState;
48 private static function internalCreate(
54 float $underwaterMovementSpeed,
55 float $lavaMovementSpeed,
60 bool $actorFlyingState,
63 $result->flags = $flags;
64 $result->scale = $scale;
65 $result->width = $width;
66 $result->height = $height;
67 $result->movementSpeed = $movementSpeed;
68 $result->underwaterMovementSpeed = $underwaterMovementSpeed;
69 $result->lavaMovementSpeed = $lavaMovementSpeed;
70 $result->jumpStrength = $jumpStrength;
71 $result->health = $health;
72 $result->hunger = $hunger;
73 $result->actorUniqueId = $actorUniqueId;
74 $result->actorFlyingState = $actorFlyingState;
78 public static function create(
84 float $underwaterMovementSpeed,
85 float $lavaMovementSpeed,
90 bool $actorFlyingState,
92 if($flags->getLength() !== self::FLAG_LENGTH){
93 throw new \InvalidArgumentException(
"Input flags must be " . self::FLAG_LENGTH .
" bits long");
96 return self::internalCreate($flags, $scale, $width, $height, $movementSpeed, $underwaterMovementSpeed, $lavaMovementSpeed, $jumpStrength, $health, $hunger, $actorUniqueId, $actorFlyingState);
99 public function getFlags() :
BitSet{
return $this->flags; }
101 public function getScale() :
float{
return $this->scale; }
103 public function getWidth() :
float{
return $this->width; }
105 public function getHeight() :
float{
return $this->height; }
107 public function getMovementSpeed() :
float{
return $this->movementSpeed; }
109 public function getUnderwaterMovementSpeed() :
float{
return $this->underwaterMovementSpeed; }
111 public function getLavaMovementSpeed() :
float{
return $this->lavaMovementSpeed; }
113 public function getJumpStrength() :
float{
return $this->jumpStrength; }
115 public function getHealth() :
float{
return $this->health; }
117 public function getHunger() :
float{
return $this->hunger; }
119 public function getActorUniqueId() :
int{
return $this->actorUniqueId; }
121 public function getActorFlyingState() :
bool{
return $this->actorFlyingState; }
124 $this->flags =
BitSet::read($in, self::FLAG_LENGTH);
125 $this->scale = LE::readFloat($in);
126 $this->width = LE::readFloat($in);
127 $this->height = LE::readFloat($in);
128 $this->movementSpeed = LE::readFloat($in);
129 $this->underwaterMovementSpeed = LE::readFloat($in);
130 $this->lavaMovementSpeed = LE::readFloat($in);
131 $this->jumpStrength = LE::readFloat($in);
132 $this->health = LE::readFloat($in);
133 $this->hunger = LE::readFloat($in);
134 $this->actorUniqueId = CommonTypes::getActorUniqueId($in);
135 $this->actorFlyingState = CommonTypes::getBool($in);
139 $this->flags->write($out);
140 LE::writeFloat($out, $this->scale);
141 LE::writeFloat($out, $this->width);
142 LE::writeFloat($out, $this->height);
143 LE::writeFloat($out, $this->movementSpeed);
144 LE::writeFloat($out, $this->underwaterMovementSpeed);
145 LE::writeFloat($out, $this->lavaMovementSpeed);
146 LE::writeFloat($out, $this->jumpStrength);
147 LE::writeFloat($out, $this->health);
148 LE::writeFloat($out, $this->hunger);
149 CommonTypes::putActorUniqueId($out, $this->actorUniqueId);
150 CommonTypes::putBool($out, $this->actorFlyingState);
154 return $handler->handleClientMovementPredictionSync($this);