PocketMine-MP
5.25.1 git-694aa17cc916a954b10fe12721c81b1dc73eecd5
Loading...
Searching...
No Matches
CreativeContentPacket.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\CreativeGroupEntry
;
19
use
pocketmine\network\mcpe\protocol\types\inventory\CreativeItemEntry
;
20
use
function
count;
21
22
class
CreativeContentPacket
extends
DataPacket
implements
ClientboundPacket
{
23
public
const
NETWORK_ID = ProtocolInfo::CREATIVE_CONTENT_PACKET;
24
25
public
const
CATEGORY_CONSTRUCTION = 1;
26
public
const
CATEGORY_NATURE = 2;
27
public
const
CATEGORY_EQUIPMENT = 3;
28
public
const
CATEGORY_ITEMS = 4;
29
31
private
array $groups;
33
private
array $items;
34
40
public
static
function
create
(array $groups, array $items) : self{
41
$result = new self;
42
$result->groups = $groups;
43
$result->items = $items;
44
return
$result;
45
}
46
48
public
function
getGroups
() : array{ return $this->groups; }
49
51
public
function
getItems
() : array{ return $this->items; }
52
53
protected
function
decodePayload
(
PacketSerializer
$in) : void{
54
$this->groups = [];
55
for
($i = 0, $len = $in->
getUnsignedVarInt
(); $i < $len; ++$i){
56
$this->groups[] = CreativeGroupEntry::read($in);
57
}
58
59
$this->items = [];
60
for
($i = 0, $len = $in->
getUnsignedVarInt
(); $i < $len; ++$i){
61
$this->items[] = CreativeItemEntry::read($in);
62
}
63
}
64
65
protected
function
encodePayload
(
PacketSerializer
$out) : void{
66
$out->putUnsignedVarInt(count($this->groups));
67
foreach
($this->groups as $entry){
68
$entry->write($out);
69
}
70
71
$out->
putUnsignedVarInt
(count($this->items));
72
foreach
($this->items as $entry){
73
$entry->write($out);
74
}
75
}
76
77
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
78
return $handler->handleCreativeContent($this);
79
}
80
}
pocketmine\network\mcpe\protocol\CreativeContentPacket
Definition
CreativeContentPacket.php:22
pocketmine\network\mcpe\protocol\CreativeContentPacket\handle
handle(PacketHandlerInterface $handler)
Definition
CreativeContentPacket.php:77
pocketmine\network\mcpe\protocol\CreativeContentPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
CreativeContentPacket.php:53
pocketmine\network\mcpe\protocol\CreativeContentPacket\create
static create(array $groups, array $items)
Definition
CreativeContentPacket.php:40
pocketmine\network\mcpe\protocol\CreativeContentPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
CreativeContentPacket.php:65
pocketmine\network\mcpe\protocol\CreativeContentPacket\getGroups
getGroups()
Definition
CreativeContentPacket.php:48
pocketmine\network\mcpe\protocol\CreativeContentPacket\getItems
getItems()
Definition
CreativeContentPacket.php:51
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\inventory\CreativeGroupEntry
Definition
CreativeGroupEntry.php:19
pocketmine\network\mcpe\protocol\types\inventory\CreativeItemEntry
Definition
CreativeItemEntry.php:19
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
CreativeContentPacket.php
Generated by
1.12.0