PocketMine-MP 5.30.2 git-98f04176111e5ecab5e8814ffc69d992bfb64939
Loading...
Searching...
No Matches
ServerScriptDebugDrawerPacket.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
19use function count;
20
22 public const NETWORK_ID = ProtocolInfo::SERVER_SCRIPT_DEBUG_DRAWER_PACKET;
23
28 private array $shapes;
29
35 public static function create(array $shapes) : self{
36 $result = new self;
37 $result->shapes = $shapes;
38 return $result;
39 }
40
45 public function getShapes() : array{ return $this->shapes; }
46
47 protected function decodePayload(PacketSerializer $in) : void{
48 $this->shapes = [];
49 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
50 $this->shapes[] = PacketShapeData::read($in);
51 }
52 }
53
54 protected function encodePayload(PacketSerializer $out) : void{
55 $out->putUnsignedVarInt(count($this->shapes));
56 foreach($this->shapes as $shape){
57 $shape->write($out);
58 }
59 }
60
61 public function handle(PacketHandlerInterface $handler) : bool{
62 return $handler->handleServerScriptDebugDrawer($this);
63 }
64}