PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
PlayerFogPacket.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
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
18use function count;
19
21 public const NETWORK_ID = ProtocolInfo::PLAYER_FOG_PACKET;
22
27 private array $fogLayers;
28
34 public static function create(array $fogLayers) : self{
35 $result = new self;
36 $result->fogLayers = $fogLayers;
37 return $result;
38 }
39
44 public function getFogLayers() : array{ return $this->fogLayers; }
45
46 protected function decodePayload(PacketSerializer $in) : void{
47 $this->fogLayers = [];
48 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
49 $this->fogLayers[] = $in->getString();
50 }
51 }
52
53 protected function encodePayload(PacketSerializer $out) : void{
54 $out->putUnsignedVarInt(count($this->fogLayers));
55 foreach($this->fogLayers as $fogLayer){
56 $out->putString($fogLayer);
57 }
58 }
59
60 public function handle(PacketHandlerInterface $handler) : bool{
61 return $handler->handlePlayerFog($this);
62 }
63}