PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
AgentActionEventPacket.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 pmmp\encoding\LE;
20
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
21
use
pocketmine\network\mcpe\protocol\types\AgentActionType
;
22
26
class
AgentActionEventPacket
extends
DataPacket
implements
ClientboundPacket
{
27
public
const
NETWORK_ID = ProtocolInfo::AGENT_ACTION_EVENT_PACKET;
28
29
private
string
$requestId;
31
private
int
$action;
32
private
string
$responseJson;
33
37
public
static
function
create
(
string
$requestId,
int
$action,
string
$responseJson) : self{
38
$result = new self;
39
$result->requestId = $requestId;
40
$result->action = $action;
41
$result->responseJson = $responseJson;
42
return
$result;
43
}
44
45
public
function
getRequestId() : string{ return $this->requestId; }
46
48
public
function
getAction
() : int{ return $this->action; }
49
50
public
function
getResponseJson() : string{ return $this->responseJson; }
51
52
protected
function
decodePayload
(ByteBufferReader $in) : void{
53
$this->requestId =
CommonTypes
::getString($in);
54
$this->action = LE::readUnsignedInt($in);
55
$this->responseJson = CommonTypes::getString($in);
56
}
57
58
protected
function
encodePayload
(ByteBufferWriter $out) : void{
59
CommonTypes
::putString($out, $this->requestId);
60
LE::writeUnsignedInt($out, $this->action);
61
CommonTypes::putString($out, $this->responseJson);
62
}
63
64
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
65
return $handler->handleAgentActionEvent($this);
66
}
67
}
pocketmine\network\mcpe\protocol\AgentActionEventPacket
Definition
AgentActionEventPacket.php:26
pocketmine\network\mcpe\protocol\AgentActionEventPacket\create
static create(string $requestId, int $action, string $responseJson)
Definition
AgentActionEventPacket.php:37
pocketmine\network\mcpe\protocol\AgentActionEventPacket\handle
handle(PacketHandlerInterface $handler)
Definition
AgentActionEventPacket.php:64
pocketmine\network\mcpe\protocol\AgentActionEventPacket\getAction
getAction()
Definition
AgentActionEventPacket.php:48
pocketmine\network\mcpe\protocol\AgentActionEventPacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
AgentActionEventPacket.php:52
pocketmine\network\mcpe\protocol\AgentActionEventPacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
AgentActionEventPacket.php:58
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\types\AgentActionType
Definition
AgentActionType.php:17
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
AgentActionEventPacket.php
Generated by
1.12.0