PocketMine-MP
5.39.3 git-21ae710729750cd637333d673bbbbbc598fc659e
Loading...
Searching...
No Matches
ClientboundDebugRendererPacket.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 pmmp\encoding\ByteBufferReader;
18
use pmmp\encoding\ByteBufferWriter;
19
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
20
use
pocketmine\network\mcpe\protocol\types\DebugMarkerData
;
21
22
class
ClientboundDebugRendererPacket
extends
DataPacket
implements
ClientboundPacket
{
23
public
const
NETWORK_ID = ProtocolInfo::CLIENTBOUND_DEBUG_RENDERER_PACKET;
24
25
public
const
TYPE_CLEAR =
"cleardebugmarkers"
;
26
public
const
TYPE_ADD_CUBE =
"adddebugmarkercube"
;
27
28
private
string
$type;
29
private
?
DebugMarkerData
$data =
null
;
30
31
private
static
function
base(
string
$type) :
self
{
32
$result =
new
self
;
33
$result->type = $type;
34
return
$result;
35
}
36
37
public
static
function
clear() :
self
{
return
self::base(self::TYPE_CLEAR); }
38
39
public
static
function
addCube(
DebugMarkerData
$data) :
self
{
40
$result = self::base(self::TYPE_ADD_CUBE);
41
$result->data = $data;
42
return
$result;
43
}
44
45
public
function
getType() :
string
{
return
$this->type; }
46
47
public
function
getData() : ?
DebugMarkerData
{
return
$this->data; }
48
49
protected
function
decodePayload
(ByteBufferReader $in) : void{
50
$this->type =
CommonTypes
::getString($in);
51
$this->data = CommonTypes::readOptional($in, DebugMarkerData::read(...));
52
}
53
54
protected
function
encodePayload
(ByteBufferWriter $out) : void{
55
CommonTypes
::putString($out, $this->type);
56
CommonTypes::writeOptional($out, $this->data, fn(ByteBufferWriter $out,
DebugMarkerData
$data) => $data->write($out));
57
}
58
59
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
60
return $handler->handleClientboundDebugRenderer($this);
61
}
62
}
pocketmine\network\mcpe\protocol\ClientboundDebugRendererPacket
Definition
ClientboundDebugRendererPacket.php:22
pocketmine\network\mcpe\protocol\ClientboundDebugRendererPacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
ClientboundDebugRendererPacket.php:49
pocketmine\network\mcpe\protocol\ClientboundDebugRendererPacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
ClientboundDebugRendererPacket.php:54
pocketmine\network\mcpe\protocol\ClientboundDebugRendererPacket\handle
handle(PacketHandlerInterface $handler)
Definition
ClientboundDebugRendererPacket.php:59
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\types\DebugMarkerData
Definition
DebugMarkerData.php:24
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
ClientboundDebugRendererPacket.php
Generated by
1.12.0