PocketMine-MP
5.21.2 git-09bf203267aca9b83a09640e17bfac0fc7b58ff8
Loading...
Searching...
No Matches
MapInfoRequestPacket.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\MapImage
;
19
use
pocketmine\network\mcpe\protocol\types\MapInfoRequestPacketClientPixel
;
20
use
function
count;
21
22
class
MapInfoRequestPacket
extends
DataPacket
implements
ServerboundPacket
{
23
public
const
NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET;
24
25
public
int
$mapId;
27
public
array $clientPixels = [];
28
33
public
static
function
create
(
int
$mapId, array $clientPixels) : self{
34
$result = new self;
35
$result->mapId = $mapId;
36
$result->clientPixels = $clientPixels;
37
return
$result;
38
}
39
40
protected
function
decodePayload
(
PacketSerializer
$in) : void{
41
$this->mapId = $in->getActorUniqueId();
42
43
$this->clientPixels = [];
44
$count = $in->
getLInt
();
45
if
($count > MapImage::MAX_HEIGHT * MapImage::MAX_WIDTH){
46
throw
new
PacketDecodeException
(
"Too many pixels"
);
47
}
48
for
($i = 0; $i < $count; $i++){
49
$this->clientPixels[] = MapInfoRequestPacketClientPixel::read($in);
50
}
51
}
52
53
protected
function
encodePayload
(
PacketSerializer
$out) : void{
54
$out->putActorUniqueId($this->mapId);
55
56
$out->putLInt(count($this->clientPixels));
57
foreach
($this->clientPixels as $pixel){
58
$pixel->write($out);
59
}
60
}
61
62
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
63
return $handler->handleMapInfoRequest($this);
64
}
65
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\MapInfoRequestPacket
Definition
MapInfoRequestPacket.php:22
pocketmine\network\mcpe\protocol\MapInfoRequestPacket\create
static create(int $mapId, array $clientPixels)
Definition
MapInfoRequestPacket.php:33
pocketmine\network\mcpe\protocol\MapInfoRequestPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
MapInfoRequestPacket.php:40
pocketmine\network\mcpe\protocol\MapInfoRequestPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
MapInfoRequestPacket.php:53
pocketmine\network\mcpe\protocol\MapInfoRequestPacket\handle
handle(PacketHandlerInterface $handler)
Definition
MapInfoRequestPacket.php:62
pocketmine\network\mcpe\protocol\PacketDecodeException
Definition
PacketDecodeException.php:17
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\MapImage
Definition
MapImage.php:24
pocketmine\network\mcpe\protocol\types\MapInfoRequestPacketClientPixel
Definition
MapInfoRequestPacketClientPixel.php:21
pocketmine\utils\BinaryStream\getLInt
getLInt()
Definition
BinaryStream.php:205
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
pocketmine\network\mcpe\protocol\ServerboundPacket
Definition
ServerboundPacket.php:17
vendor
pocketmine
bedrock-protocol
src
MapInfoRequestPacket.php
Generated by
1.12.0