PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
InventorySlotPacket.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::INVENTORY_SLOT_PACKET;
22
23 public int $windowId;
24 public int $inventorySlot;
25 public ItemStackWrapper $item;
26
30 public static function create(int $windowId, int $inventorySlot, ItemStackWrapper $item) : self{
31 $result = new self;
32 $result->windowId = $windowId;
33 $result->inventorySlot = $inventorySlot;
34 $result->item = $item;
35 return $result;
36 }
37
38 protected function decodePayload(PacketSerializer $in) : void{
39 $this->windowId = $in->getUnsignedVarInt();
40 $this->inventorySlot = $in->getUnsignedVarInt();
41 $this->item = $in->getItemStackWrapper();
42 }
43
44 protected function encodePayload(PacketSerializer $out) : void{
45 $out->putUnsignedVarInt($this->windowId);
46 $out->putUnsignedVarInt($this->inventorySlot);
47 $out->putItemStackWrapper($this->item);
48 }
49
50 public function handle(PacketHandlerInterface $handler) : bool{
51 return $handler->handleInventorySlot($this);
52 }
53}
static create(int $windowId, int $inventorySlot, ItemStackWrapper $item)