24 public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_DELTA_PACKET;
26 public const FLAG_HAS_X = 0x01;
27 public const FLAG_HAS_Y = 0x02;
28 public const FLAG_HAS_Z = 0x04;
29 public const FLAG_HAS_PITCH = 0x08;
30 public const FLAG_HAS_YAW = 0x10;
31 public const FLAG_HAS_HEAD_YAW = 0x20;
32 public const FLAG_GROUND = 0x40;
33 public const FLAG_TELEPORT = 0x80;
34 public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x100;
36 public int $actorRuntimeId;
38 public float $xPos = 0;
39 public float $yPos = 0;
40 public float $zPos = 0;
41 public float $pitch = 0.0;
42 public float $yaw = 0.0;
43 public float $headYaw = 0.0;
46 private function maybeReadCoord(
int $flag, ByteBufferReader $in) :
float{
47 if(($this->flags & $flag) !== 0){
48 return LE::readFloat($in);
54 private function maybeReadRotation(
int $flag, ByteBufferReader $in) :
float{
55 if(($this->flags & $flag) !== 0){
56 return CommonTypes::getRotationByte($in);
62 $this->actorRuntimeId =
CommonTypes::getActorRuntimeId($in);
63 $this->flags = LE::readUnsignedShort($in);
64 $this->xPos = $this->maybeReadCoord(self::FLAG_HAS_X, $in);
65 $this->yPos = $this->maybeReadCoord(self::FLAG_HAS_Y, $in);
66 $this->zPos = $this->maybeReadCoord(self::FLAG_HAS_Z, $in);
67 $this->pitch = $this->maybeReadRotation(self::FLAG_HAS_PITCH, $in);
68 $this->yaw = $this->maybeReadRotation(self::FLAG_HAS_YAW, $in);
69 $this->headYaw = $this->maybeReadRotation(self::FLAG_HAS_HEAD_YAW, $in);
72 private function maybeWriteCoord(
int $flag,
float $val, ByteBufferWriter $out) : void{
73 if(($this->flags & $flag) !== 0){
74 LE::writeFloat($out, $val);
78 private function maybeWriteRotation(
int $flag,
float $val, ByteBufferWriter $out) : void{
79 if(($this->flags & $flag) !== 0){
80 CommonTypes::putRotationByte($out, $val);
85 CommonTypes::putActorRuntimeId($out, $this->actorRuntimeId);
86 LE::writeUnsignedShort($out, $this->flags);
87 $this->maybeWriteCoord(self::FLAG_HAS_X, $this->xPos, $out);
88 $this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yPos, $out);
89 $this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zPos, $out);
90 $this->maybeWriteRotation(self::FLAG_HAS_PITCH, $this->pitch, $out);
91 $this->maybeWriteRotation(self::FLAG_HAS_YAW, $this->yaw, $out);
92 $this->maybeWriteRotation(self::FLAG_HAS_HEAD_YAW, $this->headYaw, $out);
96 return $handler->handleMoveActorDelta($this);