PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
InventoryContentPacket.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\FullContainerName
;
19
use
pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper
;
20
use
function
count;
21
22
class
InventoryContentPacket
extends
DataPacket
implements
ClientboundPacket
{
23
public
const
NETWORK_ID = ProtocolInfo::INVENTORY_CONTENT_PACKET;
24
25
public
int
$windowId;
27
public
array $items = [];
28
public
FullContainerName
$containerName;
29
public
ItemStackWrapper
$storage;
30
35
public
static
function
create
(
int
$windowId, array $items,
FullContainerName
$containerName,
ItemStackWrapper
$storage) : self{
36
$result = new self;
37
$result->windowId = $windowId;
38
$result->items = $items;
39
$result->containerName = $containerName;
40
$result->storage = $storage;
41
return
$result;
42
}
43
44
protected
function
decodePayload
(
PacketSerializer
$in) : void{
45
$this->windowId = $in->getUnsignedVarInt();
46
$count = $in->
getUnsignedVarInt
();
47
for
($i = 0; $i < $count; ++$i){
48
$this->items[] = $in->getItemStackWrapper();
49
}
50
$this->containerName = FullContainerName::read($in);
51
$this->storage = $in->getItemStackWrapper();
52
}
53
54
protected
function
encodePayload
(
PacketSerializer
$out) : void{
55
$out->putUnsignedVarInt($this->windowId);
56
$out->
putUnsignedVarInt
(count($this->items));
57
foreach
($this->items as $item){
58
$out->putItemStackWrapper($item);
59
}
60
$this->containerName->write($out);
61
$out->putItemStackWrapper($this->storage);
62
}
63
64
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
65
return $handler->handleInventoryContent($this);
66
}
67
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\InventoryContentPacket
Definition
InventoryContentPacket.php:22
pocketmine\network\mcpe\protocol\InventoryContentPacket\create
static create(int $windowId, array $items, FullContainerName $containerName, ItemStackWrapper $storage)
Definition
InventoryContentPacket.php:35
pocketmine\network\mcpe\protocol\InventoryContentPacket\handle
handle(PacketHandlerInterface $handler)
Definition
InventoryContentPacket.php:64
pocketmine\network\mcpe\protocol\InventoryContentPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
InventoryContentPacket.php:44
pocketmine\network\mcpe\protocol\InventoryContentPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
InventoryContentPacket.php:54
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\inventory\FullContainerName
Definition
FullContainerName.php:19
pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper
Definition
ItemStackWrapper.php:17
pocketmine\utils\BinaryStream\getUnsignedVarInt
getUnsignedVarInt()
Definition
BinaryStream.php:307
pocketmine\utils\BinaryStream\putUnsignedVarInt
putUnsignedVarInt(int $v)
Definition
BinaryStream.php:314
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
InventoryContentPacket.php
Generated by
1.12.0