use pocketmine\network\mcpe\handler\PacketHandler; use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty; use pocketmine\network\mcpe\serializer\NetworkBinaryStream; class SetActorDataPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ //TODO: check why this is serverbound public const NETWORK_ID = ProtocolInfo::SET_ACTOR_DATA_PACKET; /** @var int */ public $entityRuntimeId; /** * @var MetadataProperty[] * @phpstan-var array */ public $metadata; /** * @param MetadataProperty[] $metadata * @phpstan-param array $metadata */ public static function create(int $entityRuntimeId, array $metadata) : self{ $result = new self; $result->entityRuntimeId = $entityRuntimeId; $result->metadata = $metadata; return $result; } protected function decodePayload(NetworkBinaryStream $in) : void{ $this->entityRuntimeId = $in->getEntityRuntimeId(); $this->metadata = $in->getEntityMetadata(); } protected function encodePayload(NetworkBinaryStream $out) : void{ $out->putEntityRuntimeId($this->entityRuntimeId); $out->putEntityMetadata($this->metadata); } public function handle(PacketHandler $handler) : bool{ return $handler->handleSetActorData($this); } }