From 10e34be8816586abde69525016322abb98c87e4a Mon Sep 17 00:00:00 2001 From: Tobias Grether Date: Fri, 1 Mar 2024 22:42:39 +0100 Subject: [PATCH] feat: implement movement prediction type --- src/CorrectPlayerMovePredictionPacket.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CorrectPlayerMovePredictionPacket.php b/src/CorrectPlayerMovePredictionPacket.php index 66b3b114..4f2de83e 100644 --- a/src/CorrectPlayerMovePredictionPacket.php +++ b/src/CorrectPlayerMovePredictionPacket.php @@ -20,20 +20,25 @@ class CorrectPlayerMovePredictionPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::CORRECT_PLAYER_MOVE_PREDICTION_PACKET; + public const PREDICTION_TYPE_VEHICLE = 0; + public const PREDICTION_TYPE_PLAYER = 1; + private Vector3 $position; private Vector3 $delta; private bool $onGround; private int $tick; + private int $predictionType; /** * @generate-create-func */ - public static function create(Vector3 $position, Vector3 $delta, bool $onGround, int $tick) : self{ + public static function create(Vector3 $position, Vector3 $delta, bool $onGround, int $tick, int $predictionType) : self{ $result = new self; $result->position = $position; $result->delta = $delta; $result->onGround = $onGround; $result->tick = $tick; + $result->predictionType = $predictionType; return $result; } @@ -45,11 +50,14 @@ public function isOnGround() : bool{ return $this->onGround; } public function getTick() : int{ return $this->tick; } + public function getPredictionType() : int{ return $this->predictionType; } + protected function decodePayload(PacketSerializer $in) : void{ $this->position = $in->getVector3(); $this->delta = $in->getVector3(); $this->onGround = $in->getBool(); $this->tick = $in->getUnsignedVarLong(); + $this->predictionType = $in->getByte(); } protected function encodePayload(PacketSerializer $out) : void{ @@ -57,6 +65,7 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putVector3($this->delta); $out->putBool($this->onGround); $out->putUnsignedVarLong($this->tick); + $out->putByte($this->predictionType); } public function handle(PacketHandlerInterface $handler) : bool{