PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
PlayerSkinPacket.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
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
21use Ramsey\Uuid\UuidInterface;
22
24 public const NETWORK_ID = ProtocolInfo::PLAYER_SKIN_PACKET;
25
26 public UuidInterface $uuid;
27 public string $oldSkinName = "";
28 public string $newSkinName = "";
29 public SkinData $skin;
30
34 public static function create(UuidInterface $uuid, string $oldSkinName, string $newSkinName, SkinData $skin) : self{
35 $result = new self;
36 $result->uuid = $uuid;
37 $result->oldSkinName = $oldSkinName;
38 $result->newSkinName = $newSkinName;
39 $result->skin = $skin;
40 return $result;
41 }
42
43 protected function decodePayload(ByteBufferReader $in) : void{
44 $this->uuid = CommonTypes::getUUID($in);
45 $this->skin = CommonTypes::getSkin($in);
46 $this->newSkinName = CommonTypes::getString($in);
47 $this->oldSkinName = CommonTypes::getString($in);
48 $this->skin->setVerified(CommonTypes::getBool($in));
49 }
50
51 protected function encodePayload(ByteBufferWriter $out) : void{
52 CommonTypes::putUUID($out, $this->uuid);
53 CommonTypes::putSkin($out, $this->skin);
54 CommonTypes::putString($out, $this->newSkinName);
55 CommonTypes::putString($out, $this->oldSkinName);
56 CommonTypes::putBool($out, $this->skin->isVerified());
57 }
58
59 public function handle(PacketHandlerInterface $handler) : bool{
60 return $handler->handlePlayerSkin($this);
61 }
62}
static create(UuidInterface $uuid, string $oldSkinName, string $newSkinName, SkinData $skin)