diff --git a/src/CorrectPlayerMovePredictionPacket.php b/src/CorrectPlayerMovePredictionPacket.php index 0fd2f787..aa6c42e8 100644 --- a/src/CorrectPlayerMovePredictionPacket.php +++ b/src/CorrectPlayerMovePredictionPacket.php @@ -59,7 +59,7 @@ public function getTick() : int{ return $this->tick; } public function getPredictionType() : int{ return $this->predictionType; } - public function getVehicleRotation() : ?Vector2{ return $this->vehicleRotation; } + public function getVehicleRotation() : ?Vector2{ return $this->vehicleRotation; } protected function decodePayload(PacketSerializer $in) : void{ $this->predictionType = $in->getByte(); @@ -76,7 +76,11 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putByte($this->predictionType); $out->putVector3($this->position); $out->putVector3($this->delta); - if($this->predictionType === self::PREDICTION_TYPE_VEHICLE && $this->vehicleRotation != null) { + if($this->predictionType === self::PREDICTION_TYPE_VEHICLE) { + if($this->vehicleRotation == null) { // this should never be the case + throw new \InvalidArgumentException("CorrectPlayerMovePredictionPackets with type VEHICLE require a vehicleRotation to be provided"); + } + $out->putFloat($this->vehicleRotation->getX()); $out->putFloat($this->vehicleRotation->getY()); }