Skip to content

Commit

Permalink
feat: implement movement prediction type
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGrether authored Mar 1, 2024
1 parent 6e73f21 commit 10e34be
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/CorrectPlayerMovePredictionPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -45,18 +50,22 @@ 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{
$out->putVector3($this->position);
$out->putVector3($this->delta);
$out->putBool($this->onGround);
$out->putUnsignedVarLong($this->tick);
$out->putByte($this->predictionType);
}

public function handle(PacketHandlerInterface $handler) : bool{
Expand Down

0 comments on commit 10e34be

Please sign in to comment.