PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
AnimateEntityPacket.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
18use function count;
19
21 public const NETWORK_ID = ProtocolInfo::ANIMATE_ENTITY_PACKET;
22
23 private string $animation;
24 private string $nextState;
25 private string $stopExpression;
26 private int $stopExpressionVersion;
27 private string $controller;
28 private float $blendOutTime;
33 private array $actorRuntimeIds;
34
40 public static function create(
41 string $animation,
42 string $nextState,
43 string $stopExpression,
44 int $stopExpressionVersion,
45 string $controller,
46 float $blendOutTime,
47 array $actorRuntimeIds,
48 ) : self{
49 $result = new self;
50 $result->animation = $animation;
51 $result->nextState = $nextState;
52 $result->stopExpression = $stopExpression;
53 $result->stopExpressionVersion = $stopExpressionVersion;
54 $result->controller = $controller;
55 $result->blendOutTime = $blendOutTime;
56 $result->actorRuntimeIds = $actorRuntimeIds;
57 return $result;
58 }
59
60 public function getAnimation() : string{ return $this->animation; }
61
62 public function getNextState() : string{ return $this->nextState; }
63
64 public function getStopExpression() : string{ return $this->stopExpression; }
65
66 public function getStopExpressionVersion() : int{ return $this->stopExpressionVersion; }
67
68 public function getController() : string{ return $this->controller; }
69
70 public function getBlendOutTime() : float{ return $this->blendOutTime; }
71
76 public function getActorRuntimeIds() : array{ return $this->actorRuntimeIds; }
77
78 protected function decodePayload(PacketSerializer $in) : void{
79 $this->animation = $in->getString();
80 $this->nextState = $in->getString();
81 $this->stopExpression = $in->getString();
82 $this->stopExpressionVersion = $in->getLInt();
83 $this->controller = $in->getString();
84 $this->blendOutTime = $in->getLFloat();
85 $this->actorRuntimeIds = [];
86 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
87 $this->actorRuntimeIds[] = $in->getActorRuntimeId();
88 }
89 }
90
91 protected function encodePayload(PacketSerializer $out) : void{
92 $out->putString($this->animation);
93 $out->putString($this->nextState);
94 $out->putString($this->stopExpression);
95 $out->putLInt($this->stopExpressionVersion);
96 $out->putString($this->controller);
97 $out->putLFloat($this->blendOutTime);
98 $out->putUnsignedVarInt(count($this->actorRuntimeIds));
99 foreach($this->actorRuntimeIds as $id){
100 $out->putActorRuntimeId($id);
101 }
102 }
103
104 public function handle(PacketHandlerInterface $handler) : bool{
105 return $handler->handleAnimateEntity($this);
106 }
107}
static create(string $animation, string $nextState, string $stopExpression, int $stopExpressionVersion, string $controller, float $blendOutTime, array $actorRuntimeIds,)