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;
41 private float $frictionModifier;
42 private float $bounciness;
43 private float $airDragModifier;
45 private int $actorUniqueId;
46 private bool $actorFlyingState;
51 private static function internalCreate(
57 float $underwaterMovementSpeed,
58 float $lavaMovementSpeed,
62 float $frictionModifier,
64 float $airDragModifier,
66 bool $actorFlyingState,
69 $result->flags = $flags;
70 $result->scale = $scale;
71 $result->width = $width;
72 $result->height = $height;
73 $result->movementSpeed = $movementSpeed;
74 $result->underwaterMovementSpeed = $underwaterMovementSpeed;
75 $result->lavaMovementSpeed = $lavaMovementSpeed;
76 $result->jumpStrength = $jumpStrength;
77 $result->health = $health;
78 $result->hunger = $hunger;
79 $result->frictionModifier = $frictionModifier;
80 $result->bounciness = $bounciness;
81 $result->airDragModifier = $airDragModifier;
82 $result->actorUniqueId = $actorUniqueId;
83 $result->actorFlyingState = $actorFlyingState;
87 public static function create(
93 float $underwaterMovementSpeed,
94 float $lavaMovementSpeed,
98 float $frictionModifier,
100 float $airDragModifier,
102 bool $actorFlyingState,
104 if($flags->getLength() !== self::FLAG_LENGTH){
105 throw new \InvalidArgumentException(
"Input flags must be " . self::FLAG_LENGTH .
" bits long");
108 return self::internalCreate($flags, $scale, $width, $height, $movementSpeed, $underwaterMovementSpeed, $lavaMovementSpeed, $jumpStrength, $health, $hunger, $frictionModifier, $bounciness, $airDragModifier, $actorUniqueId, $actorFlyingState);
111 public function getFlags() :
BitSet{
return $this->flags; }
113 public function getScale() :
float{
return $this->scale; }
115 public function getWidth() :
float{
return $this->width; }
117 public function getHeight() :
float{
return $this->height; }
119 public function getMovementSpeed() :
float{
return $this->movementSpeed; }
121 public function getUnderwaterMovementSpeed() :
float{
return $this->underwaterMovementSpeed; }
123 public function getLavaMovementSpeed() :
float{
return $this->lavaMovementSpeed; }
125 public function getJumpStrength() :
float{
return $this->jumpStrength; }
127 public function getHealth() :
float{
return $this->health; }
129 public function getHunger() :
float{
return $this->hunger; }
131 public function getFrictionModifier() :
float{
return $this->frictionModifier; }
133 public function getBounciness() :
float{
return $this->bounciness; }
135 public function getAirDragModifier() :
float{
return $this->airDragModifier; }
137 public function getActorUniqueId() :
int{
return $this->actorUniqueId; }
139 public function getActorFlyingState() :
bool{
return $this->actorFlyingState; }
142 $this->flags =
BitSet::read($in, self::FLAG_LENGTH);
143 $this->scale = LE::readFloat($in);
144 $this->width = LE::readFloat($in);
145 $this->height = LE::readFloat($in);
146 $this->movementSpeed = LE::readFloat($in);
147 $this->underwaterMovementSpeed = LE::readFloat($in);
148 $this->lavaMovementSpeed = LE::readFloat($in);
149 $this->jumpStrength = LE::readFloat($in);
150 $this->health = LE::readFloat($in);
151 $this->hunger = LE::readFloat($in);
152 $this->frictionModifier = LE::readFloat($in);
153 $this->bounciness = LE::readFloat($in);
154 $this->airDragModifier = LE::readFloat($in);
155 $this->actorUniqueId = CommonTypes::getActorUniqueId($in);
156 $this->actorFlyingState = CommonTypes::getBool($in);
160 $this->flags->write($out);
161 LE::writeFloat($out, $this->scale);
162 LE::writeFloat($out, $this->width);
163 LE::writeFloat($out, $this->height);
164 LE::writeFloat($out, $this->movementSpeed);
165 LE::writeFloat($out, $this->underwaterMovementSpeed);
166 LE::writeFloat($out, $this->lavaMovementSpeed);
167 LE::writeFloat($out, $this->jumpStrength);
168 LE::writeFloat($out, $this->health);
169 LE::writeFloat($out, $this->hunger);
170 LE::writeFloat($out, $this->frictionModifier);
171 LE::writeFloat($out, $this->bounciness);
172 LE::writeFloat($out, $this->airDragModifier);
173 CommonTypes::putActorUniqueId($out, $this->actorUniqueId);
174 CommonTypes::putBool($out, $this->actorFlyingState);
178 return $handler->handleClientMovementPredictionSync($this);