PocketMine-MP
5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
SubChunkRequestPacket.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\SubChunkPosition
;
19
use
pocketmine\network\mcpe\protocol\types\SubChunkPositionOffset
;
20
use
function
count;
21
22
class
SubChunkRequestPacket
extends
DataPacket
implements
ServerboundPacket
{
23
public
const
NETWORK_ID = ProtocolInfo::SUB_CHUNK_REQUEST_PACKET;
24
25
private
int
$dimension;
26
private
SubChunkPosition
$basePosition;
31
private
array $entries;
32
38
public
static
function
create
(
int
$dimension,
SubChunkPosition
$basePosition, array $entries) : self{
39
$result = new self;
40
$result->dimension = $dimension;
41
$result->basePosition = $basePosition;
42
$result->entries = $entries;
43
return
$result;
44
}
45
46
public
function
getDimension() : int{ return $this->dimension; }
47
48
public
function
getBasePosition() : SubChunkPosition{ return $this->basePosition; }
49
54
public
function
getEntries
() : array{ return $this->entries; }
55
56
protected
function
decodePayload
(
PacketSerializer
$in) : void{
57
$this->dimension = $in->getVarInt();
58
$this->basePosition = SubChunkPosition::read($in);
59
60
$this->entries = [];
61
for
($i = 0, $count = $in->
getLInt
(); $i < $count; $i++){
62
$this->entries[] = SubChunkPositionOffset::read($in);
63
}
64
}
65
66
protected
function
encodePayload
(
PacketSerializer
$out) : void{
67
$out->putVarInt($this->dimension);
68
$this->basePosition->write($out);
69
70
$out->putLInt(count($this->entries));
71
foreach
($this->entries as $entry){
72
$entry->write($out);
73
}
74
}
75
76
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
77
return $handler->handleSubChunkRequest($this);
78
}
79
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\SubChunkRequestPacket
Definition
SubChunkRequestPacket.php:22
pocketmine\network\mcpe\protocol\SubChunkRequestPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
SubChunkRequestPacket.php:56
pocketmine\network\mcpe\protocol\SubChunkRequestPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
SubChunkRequestPacket.php:66
pocketmine\network\mcpe\protocol\SubChunkRequestPacket\getEntries
getEntries()
Definition
SubChunkRequestPacket.php:54
pocketmine\network\mcpe\protocol\SubChunkRequestPacket\handle
handle(PacketHandlerInterface $handler)
Definition
SubChunkRequestPacket.php:76
pocketmine\network\mcpe\protocol\SubChunkRequestPacket\create
static create(int $dimension, SubChunkPosition $basePosition, array $entries)
Definition
SubChunkRequestPacket.php:38
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\SubChunkPosition
Definition
SubChunkPosition.php:19
pocketmine\network\mcpe\protocol\types\SubChunkPositionOffset
Definition
SubChunkPositionOffset.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
SubChunkRequestPacket.php
Generated by
1.12.0