PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
PlayerHotbarPacket.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
19
21 public const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET;
22
23 public int $selectedHotbarSlot;
24 public int $windowId = ContainerIds::INVENTORY;
25 public bool $selectHotbarSlot = true;
26
30 public static function create(int $selectedHotbarSlot, int $windowId, bool $selectHotbarSlot) : self{
31 $result = new self;
32 $result->selectedHotbarSlot = $selectedHotbarSlot;
33 $result->windowId = $windowId;
34 $result->selectHotbarSlot = $selectHotbarSlot;
35 return $result;
36 }
37
38 protected function decodePayload(PacketSerializer $in) : void{
39 $this->selectedHotbarSlot = $in->getUnsignedVarInt();
40 $this->windowId = $in->getByte();
41 $this->selectHotbarSlot = $in->getBool();
42 }
43
44 protected function encodePayload(PacketSerializer $out) : void{
45 $out->putUnsignedVarInt($this->selectedHotbarSlot);
46 $out->putByte($this->windowId);
47 $out->putBool($this->selectHotbarSlot);
48 }
49
50 public function handle(PacketHandlerInterface $handler) : bool{
51 return $handler->handlePlayerHotbar($this);
52 }
53}
static create(int $selectedHotbarSlot, int $windowId, bool $selectHotbarSlot)