PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
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
13
declare(strict_types=1);
14
15
namespace
pocketmine\network\mcpe\protocol;
16
17
use
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
;
18
use
pocketmine\network\mcpe\protocol\types\inventory\ContainerIds
;
19
20
class
PlayerHotbarPacket
extends
DataPacket
implements
ClientboundPacket
,
ServerboundPacket
{
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
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\PlayerHotbarPacket
Definition
PlayerHotbarPacket.php:20
pocketmine\network\mcpe\protocol\PlayerHotbarPacket\handle
handle(PacketHandlerInterface $handler)
Definition
PlayerHotbarPacket.php:50
pocketmine\network\mcpe\protocol\PlayerHotbarPacket\create
static create(int $selectedHotbarSlot, int $windowId, bool $selectHotbarSlot)
Definition
PlayerHotbarPacket.php:30
pocketmine\network\mcpe\protocol\PlayerHotbarPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
PlayerHotbarPacket.php:38
pocketmine\network\mcpe\protocol\PlayerHotbarPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
PlayerHotbarPacket.php:44
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\inventory\ContainerIds
Definition
ContainerIds.php:17
pocketmine\utils\BinaryStream\getBool
getBool()
Definition
BinaryStream.php:105
pocketmine\utils\BinaryStream\getByte
getByte()
Definition
BinaryStream.php:117
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
pocketmine\network\mcpe\protocol\ServerboundPacket
Definition
ServerboundPacket.php:17
vendor
pocketmine
bedrock-protocol
src
PlayerHotbarPacket.php
Generated by
1.12.0