PocketMine-MP 5.21.2 git-09bf203267aca9b83a09640e17bfac0fc7b58ff8
Loading...
Searching...
No Matches
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
20
22 public const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET;
23
24 public int $windowId;
25 public int $inventorySlot;
26 public FullContainerName $containerName;
27 public ItemStackWrapper $storage;
28 public ItemStackWrapper $item;
29
33 public static function create(int $windowId, int $inventorySlot, FullContainerName $containerName, ItemStackWrapper $storage, ItemStackWrapper $item) : self{
34 $result = new self;
35 $result->windowId = $windowId;
36 $result->inventorySlot = $inventorySlot;
37 $result->containerName = $containerName;
38 $result->storage = $storage;
39 $result->item = $item;
40 return $result;
41 }
42
43 protected function decodePayload(PacketSerializer $in) : void{
44 $this->windowId = $in->getUnsignedVarInt();
45 $this->inventorySlot = $in->getUnsignedVarInt();
46 $this->containerName = FullContainerName::read($in);
47 $this->storage = $in->getItemStackWrapper();
48 $this->item = $in->getItemStackWrapper();
49 }
50
51 protected function encodePayload(PacketSerializer $out) : void{
52 $out->putUnsignedVarInt($this->windowId);
53 $out->putUnsignedVarInt($this->inventorySlot);
54 $this->containerName->write($out);
55 $out->putItemStackWrapper($this->storage);
56 $out->putItemStackWrapper($this->item);
57 }
58
59 public function handle(PacketHandlerInterface $handler) : bool{
60 return $handler->handleInventorySlot($this);
61 }
62}
static create(int $windowId, int $inventorySlot, FullContainerName $containerName, ItemStackWrapper $storage, ItemStackWrapper $item)