use pocketmine\network\mcpe\handler\PacketHandler; use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds; class PlayerHotbarPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ public const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET; /** @var int */ public $selectedHotbarSlot; /** @var int */ public $windowId = ContainerIds::INVENTORY; /** @var bool */ public $selectHotbarSlot = true; public static function create(int $slot, int $windowId, bool $selectSlot = true) : self{ $result = new self; $result->selectedHotbarSlot = $slot; $result->windowId = $windowId; $result->selectHotbarSlot = $selectSlot; return $result; } protected function decodePayload() : void{ $this->selectedHotbarSlot = $this->getUnsignedVarInt(); $this->windowId = $this->getByte(); $this->selectHotbarSlot = $this->getBool(); } protected function encodePayload() : void{ $this->putUnsignedVarInt($this->selectedHotbarSlot); $this->putByte($this->windowId); $this->putBool($this->selectHotbarSlot); } public function handle(PacketHandler $handler) : bool{ return $handler->handlePlayerHotbar($this); } }