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
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
21
class
InventorySlotPacket
extends
DataPacket
implements
ClientboundPacket
{
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
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\InventorySlotPacket
Definition
InventorySlotPacket.php:21
pocketmine\network\mcpe\protocol\InventorySlotPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
InventorySlotPacket.php:43
pocketmine\network\mcpe\protocol\InventorySlotPacket\create
static create(int $windowId, int $inventorySlot, FullContainerName $containerName, ItemStackWrapper $storage, ItemStackWrapper $item)
Definition
InventorySlotPacket.php:33
pocketmine\network\mcpe\protocol\InventorySlotPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
InventorySlotPacket.php:51
pocketmine\network\mcpe\protocol\InventorySlotPacket\handle
handle(PacketHandlerInterface $handler)
Definition
InventorySlotPacket.php:59
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
InventorySlotPacket.php
Generated by
1.12.0