PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
MobArmorEquipmentPacket.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;
21
23 public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
24
25 public int $actorRuntimeId;
26
27 //this intentionally doesn't use an array because we don't want any implicit dependencies on internal order
28 public ItemStackWrapper $head;
29 public ItemStackWrapper $chest;
30 public ItemStackWrapper $legs;
31 public ItemStackWrapper $feet;
32 public ItemStackWrapper $body;
33
37 public static function create(int $actorRuntimeId, ItemStackWrapper $head, ItemStackWrapper $chest, ItemStackWrapper $legs, ItemStackWrapper $feet, ItemStackWrapper $body) : self{
38 $result = new self;
39 $result->actorRuntimeId = $actorRuntimeId;
40 $result->head = $head;
41 $result->chest = $chest;
42 $result->legs = $legs;
43 $result->feet = $feet;
44 $result->body = $body;
45 return $result;
46 }
47
48 protected function decodePayload(ByteBufferReader $in) : void{
49 $this->actorRuntimeId = CommonTypes::getActorRuntimeId($in);
50 $this->head = CommonTypes::getItemStackWrapper($in);
51 $this->chest = CommonTypes::getItemStackWrapper($in);
52 $this->legs = CommonTypes::getItemStackWrapper($in);
53 $this->feet = CommonTypes::getItemStackWrapper($in);
54 $this->body = CommonTypes::getItemStackWrapper($in);
55 }
56
57 protected function encodePayload(ByteBufferWriter $out) : void{
58 CommonTypes::putActorRuntimeId($out, $this->actorRuntimeId);
59 CommonTypes::putItemStackWrapper($out, $this->head);
60 CommonTypes::putItemStackWrapper($out, $this->chest);
61 CommonTypes::putItemStackWrapper($out, $this->legs);
62 CommonTypes::putItemStackWrapper($out, $this->feet);
63 CommonTypes::putItemStackWrapper($out, $this->body);
64 }
65
66 public function handle(PacketHandlerInterface $handler) : bool{
67 return $handler->handleMobArmorEquipment($this);
68 }
69}
static create(int $actorRuntimeId, ItemStackWrapper $head, ItemStackWrapper $chest, ItemStackWrapper $legs, ItemStackWrapper $feet, ItemStackWrapper $body)