PocketMine-MP
5.21.3 git-fcef015f32c0b0709cfd4d6f1b3c32f484b25bde
Loading...
Searching...
No Matches
PositionTrackingDBServerBroadcastPacket.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\CacheableNbt
;
19
20
class
PositionTrackingDBServerBroadcastPacket
extends
DataPacket
implements
ClientboundPacket
{
21
public
const
NETWORK_ID = ProtocolInfo::POSITION_TRACKING_D_B_SERVER_BROADCAST_PACKET;
22
23
public
const
ACTION_UPDATE = 0;
24
public
const
ACTION_DESTROY = 1;
25
public
const
ACTION_NOT_FOUND = 2;
26
27
private
int
$action;
28
private
int
$trackingId;
30
private
CacheableNbt
$nbt;
31
36
public
static
function
create
(
int
$action,
int
$trackingId,
CacheableNbt
$nbt) : self{
37
$result = new self;
38
$result->action = $action;
39
$result->trackingId = $trackingId;
40
$result->nbt = $nbt;
41
return
$result;
42
}
43
44
public
function
getAction() : int{ return $this->action; }
45
46
public
function
getTrackingId() : int{ return $this->trackingId; }
47
49
public
function
getNbt
() :
CacheableNbt
{ return $this->nbt; }
50
51
protected
function
decodePayload
(
PacketSerializer
$in) : void{
52
$this->action = $in->getByte();
53
$this->trackingId = $in->
getVarInt
();
54
$this->nbt =
new
CacheableNbt
($in->getNbtCompoundRoot());
55
}
56
57
protected
function
encodePayload
(
PacketSerializer
$out) : void{
58
$out->putByte($this->action);
59
$out->
putVarInt
($this->trackingId);
60
$out->put($this->nbt->getEncodedNbt());
61
}
62
63
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
64
return $handler->handlePositionTrackingDBServerBroadcast($this);
65
}
66
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\PositionTrackingDBServerBroadcastPacket
Definition
PositionTrackingDBServerBroadcastPacket.php:20
pocketmine\network\mcpe\protocol\PositionTrackingDBServerBroadcastPacket\create
static create(int $action, int $trackingId, CacheableNbt $nbt)
Definition
PositionTrackingDBServerBroadcastPacket.php:36
pocketmine\network\mcpe\protocol\PositionTrackingDBServerBroadcastPacket\getNbt
getNbt()
Definition
PositionTrackingDBServerBroadcastPacket.php:49
pocketmine\network\mcpe\protocol\PositionTrackingDBServerBroadcastPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
PositionTrackingDBServerBroadcastPacket.php:57
pocketmine\network\mcpe\protocol\PositionTrackingDBServerBroadcastPacket\handle
handle(PacketHandlerInterface $handler)
Definition
PositionTrackingDBServerBroadcastPacket.php:63
pocketmine\network\mcpe\protocol\PositionTrackingDBServerBroadcastPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
PositionTrackingDBServerBroadcastPacket.php:51
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\CacheableNbt
Definition
CacheableNbt.php:24
pocketmine\utils\BinaryStream\putVarInt
putVarInt(int $v)
Definition
BinaryStream.php:331
pocketmine\utils\BinaryStream\getVarInt
getVarInt()
Definition
BinaryStream.php:324
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
PositionTrackingDBServerBroadcastPacket.php
Generated by
1.12.0