PocketMine-MP 5.18.1 git-9381fc4172e5dce4cada1cb356050c8a2ab57b94
MotionPredictionHintsPacket.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
19
21 public const NETWORK_ID = ProtocolInfo::MOTION_PREDICTION_HINTS_PACKET;
22
23 private int $actorRuntimeId;
24 private Vector3 $motion;
25 private bool $onGround;
26
30 public static function create(int $actorRuntimeId, Vector3 $motion, bool $onGround) : self{
31 $result = new self;
32 $result->actorRuntimeId = $actorRuntimeId;
33 $result->motion = $motion;
34 $result->onGround = $onGround;
35 return $result;
36 }
37
38 public function getActorRuntimeId() : int{ return $this->actorRuntimeId; }
39
40 public function getMotion() : Vector3{ return $this->motion; }
41
42 public function isOnGround() : bool{ return $this->onGround; }
43
44 protected function decodePayload(PacketSerializer $in) : void{
45 $this->actorRuntimeId = $in->getActorRuntimeId();
46 $this->motion = $in->getVector3();
47 $this->onGround = $in->getBool();
48 }
49
50 protected function encodePayload(PacketSerializer $out) : void{
51 $out->putActorRuntimeId($this->actorRuntimeId);
52 $out->putVector3($this->motion);
53 $out->putBool($this->onGround);
54 }
55
56 public function handle(PacketHandlerInterface $handler) : bool{
57 return $handler->handleMotionPredictionHints($this);
58 }
59}
static create(int $actorRuntimeId, Vector3 $motion, bool $onGround)