Skip to content

Commit

Permalink
chore: rename from rotation to vehicleRotation
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGrether committed Aug 13, 2024
1 parent 048ed0c commit d98bf4d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/CorrectPlayerMovePredictionPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ class CorrectPlayerMovePredictionPacket extends DataPacket implements Clientboun
private bool $onGround;
private int $tick;
private int $predictionType;
private ?Vector2 $rotation;
private ?Vector2 $vehicleRotation;

/**
* @generate-create-func
*/
public static function create(Vector3 $position, Vector3 $delta, bool $onGround, int $tick, int $predictionType, ?Vector2 $rotation) : self{
public static function create(Vector3 $position, Vector3 $delta, bool $onGround, int $tick, int $predictionType, ?Vector2 $vehicleRotation) : self{
$result = new self;
$result->position = $position;
$result->delta = $delta;
$result->onGround = $onGround;
$result->tick = $tick;
$result->predictionType = $predictionType;

if($predictionType === self::PREDICTION_TYPE_VEHICLE && $rotation == null) {
throw new \InvalidArgumentException("CorrectPlayerMovePredictionPackets with type VEHICLE require a rotation to be provided");
if($predictionType === self::PREDICTION_TYPE_VEHICLE && $vehicleRotation == null) {
throw new \InvalidArgumentException("CorrectPlayerMovePredictionPackets with type VEHICLE require a vehicleRotation to be provided");
}

return $result;
Expand All @@ -59,14 +59,14 @@ public function getTick() : int{ return $this->tick; }

public function getPredictionType() : int{ return $this->predictionType; }

public function getRotation() : ?Vector2{ return $this->rotation; }
public function getVehicleRotation() : ?Vector2{ return $this->vehicleRotation; }

protected function decodePayload(PacketSerializer $in) : void{
$this->predictionType = $in->getByte();
$this->position = $in->getVector3();
$this->delta = $in->getVector3();
if($this->predictionType === self::PREDICTION_TYPE_VEHICLE) {
$this->rotation = new Vector2($in->getFloat(), $in->getFloat());
$this->vehicleRotation = new Vector2($in->getFloat(), $in->getFloat());
}
$this->onGround = $in->getBool();
$this->tick = $in->getUnsignedVarLong();
Expand All @@ -77,8 +77,8 @@ protected function encodePayload(PacketSerializer $out) : void{
$out->putVector3($this->position);
$out->putVector3($this->delta);
if($this->predictionType === self::PREDICTION_TYPE_VEHICLE) {
$out->putFloat($this->rotation->getX());
$out->putFloat($this->rotation->getY());
$out->putFloat($this->vehicleRotation->getX());

Check failure on line 80 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2)

Cannot call method getX() on pocketmine\math\Vector2|null.

Check failure on line 80 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3)

Cannot call method getX() on pocketmine\math\Vector2|null.

Check failure on line 80 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2)

Cannot call method getX() on pocketmine\math\Vector2|null.

Check failure on line 80 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3)

Cannot call method getX() on pocketmine\math\Vector2|null.
$out->putFloat($this->vehicleRotation->getY());

Check failure on line 81 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2)

Cannot call method getY() on pocketmine\math\Vector2|null.

Check failure on line 81 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3)

Cannot call method getY() on pocketmine\math\Vector2|null.

Check failure on line 81 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2)

Cannot call method getY() on pocketmine\math\Vector2|null.

Check failure on line 81 in src/CorrectPlayerMovePredictionPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3)

Cannot call method getY() on pocketmine\math\Vector2|null.
}
$out->putBool($this->onGround);
$out->putUnsignedVarLong($this->tick);
Expand Down

0 comments on commit d98bf4d

Please sign in to comment.