PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
TrimDataPacket.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\TrimMaterial
;
19
use
pocketmine\network\mcpe\protocol\types\TrimPattern
;
20
use
function
count;
21
22
class
TrimDataPacket
extends
DataPacket
implements
ClientboundPacket
{
23
public
const
NETWORK_ID = ProtocolInfo::TRIM_DATA_PACKET;
24
29
private
array $trimPatterns;
34
private
array $trimMaterials;
35
43
public
static
function
create
(array $trimPatterns, array $trimMaterials) : self{
44
$result = new self;
45
$result->trimPatterns = $trimPatterns;
46
$result->trimMaterials = $trimMaterials;
47
return
$result;
48
}
49
54
public
function
getTrimPatterns
() : array{ return $this->trimPatterns; }
55
60
public
function
getTrimMaterials
() : array{ return $this->trimMaterials; }
61
62
protected
function
decodePayload
(
PacketSerializer
$in) : void{
63
$this->trimPatterns = [];
64
for
($i = 0, $count = $in->
getUnsignedVarInt
(); $i < $count; ++$i){
65
$this->trimPatterns[] = TrimPattern::read($in);
66
}
67
$this->trimMaterials = [];
68
for
($i = 0, $count = $in->
getUnsignedVarInt
(); $i < $count; ++$i){
69
$this->trimMaterials[] = TrimMaterial::read($in);
70
}
71
}
72
73
protected
function
encodePayload
(
PacketSerializer
$out) : void{
74
$out->putUnsignedVarInt(count($this->trimPatterns));
75
foreach
($this->trimPatterns as $trimPattern){
76
$trimPattern->write($out);
77
}
78
$out->
putUnsignedVarInt
(count($this->trimMaterials));
79
foreach
($this->trimMaterials as $trimMaterial){
80
$trimMaterial->write($out);
81
}
82
}
83
84
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
85
return $handler->handleTrimData($this);
86
}
87
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\TrimDataPacket
Definition
TrimDataPacket.php:22
pocketmine\network\mcpe\protocol\TrimDataPacket\getTrimPatterns
getTrimPatterns()
Definition
TrimDataPacket.php:54
pocketmine\network\mcpe\protocol\TrimDataPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
TrimDataPacket.php:73
pocketmine\network\mcpe\protocol\TrimDataPacket\create
static create(array $trimPatterns, array $trimMaterials)
Definition
TrimDataPacket.php:43
pocketmine\network\mcpe\protocol\TrimDataPacket\handle
handle(PacketHandlerInterface $handler)
Definition
TrimDataPacket.php:84
pocketmine\network\mcpe\protocol\TrimDataPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
TrimDataPacket.php:62
pocketmine\network\mcpe\protocol\TrimDataPacket\getTrimMaterials
getTrimMaterials()
Definition
TrimDataPacket.php:60
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\TrimMaterial
Definition
TrimMaterial.php:19
pocketmine\network\mcpe\protocol\types\TrimPattern
Definition
TrimPattern.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
TrimDataPacket.php
Generated by
1.12.0