PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
SetPlayerInventoryOptionsPacket.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
18use pocketmine\network\mcpe\protocol\types\inventory\InventoryLayout;
19use pocketmine\network\mcpe\protocol\types\inventory\InventoryLeftTab;
20use pocketmine\network\mcpe\protocol\types\inventory\InventoryRightTab;
21
23 public const NETWORK_ID = ProtocolInfo::SET_PLAYER_INVENTORY_OPTIONS_PACKET;
24
25 private InventoryLeftTab $leftTab;
26 private InventoryRightTab $rightTab;
27 private bool $filtering;
28 private InventoryLayout $inventoryLayout;
29 private InventoryLayout $craftingLayout;
30
34 public static function create(InventoryLeftTab $leftTab, InventoryRightTab $rightTab, bool $filtering, InventoryLayout $inventoryLayout, InventoryLayout $craftingLayout) : self{
35 $result = new self;
36 $result->leftTab = $leftTab;
37 $result->rightTab = $rightTab;
38 $result->filtering = $filtering;
39 $result->inventoryLayout = $inventoryLayout;
40 $result->craftingLayout = $craftingLayout;
41 return $result;
42 }
43
44 public function getLeftTab() : InventoryLeftTab{ return $this->leftTab; }
45
46 public function getRightTab() : InventoryRightTab{ return $this->rightTab; }
47
48 public function isFiltering() : bool{ return $this->filtering; }
49
50 public function getInventoryLayout() : InventoryLayout{ return $this->inventoryLayout; }
51
52 public function getCraftingLayout() : InventoryLayout{ return $this->craftingLayout; }
53
54 protected function decodePayload(PacketSerializer $in) : void{
55 $this->leftTab = InventoryLeftTab::fromPacket($in->getVarInt());
56 $this->rightTab = InventoryRightTab::fromPacket($in->getVarInt());
57 $this->filtering = $in->getBool();
58 $this->inventoryLayout = InventoryLayout::fromPacket($in->getVarInt());
59 $this->craftingLayout = InventoryLayout::fromPacket($in->getVarInt());
60 }
61
62 protected function encodePayload(PacketSerializer $out) : void{
63 $out->putVarInt($this->leftTab->value);
64 $out->putVarInt($this->rightTab->value);
65 $out->putBool($this->filtering);
66 $out->putVarInt($this->inventoryLayout->value);
67 $out->putVarInt($this->craftingLayout->value);
68 }
69
70 public function handle(PacketHandlerInterface $handler) : bool{
71 return $handler->handleSetPlayerInventoryOptions($this);
72 }
73}
static create(InventoryLeftTab $leftTab, InventoryRightTab $rightTab, bool $filtering, InventoryLayout $inventoryLayout, InventoryLayout $craftingLayout)