PocketMine-MP
5.37.4 git-dbb3eefc44d5dddb20f540594fbda61467f50873
Loading...
Searching...
No Matches
UpdatePlayerGameTypePacket.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\VarInt;
20
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
21
use
pocketmine\network\mcpe\protocol\types\GameMode
;
22
23
class
UpdatePlayerGameTypePacket
extends
DataPacket
implements
ClientboundPacket
{
24
public
const
NETWORK_ID = ProtocolInfo::UPDATE_PLAYER_GAME_TYPE_PACKET;
25
27
private
int
$gameMode;
28
private
int
$playerActorUniqueId;
29
private
int
$tick;
30
34
public
static
function
create
(
int
$gameMode,
int
$playerActorUniqueId,
int
$tick) : self{
35
$result = new self;
36
$result->gameMode = $gameMode;
37
$result->playerActorUniqueId = $playerActorUniqueId;
38
$result->tick = $tick;
39
return
$result;
40
}
41
42
public
function
getGameMode() : int{ return $this->gameMode; }
43
44
public
function
getPlayerActorUniqueId() : int{ return $this->playerActorUniqueId; }
45
46
public
function
getTick() : int{ return $this->tick; }
47
48
protected
function
decodePayload
(ByteBufferReader $in) : void{
49
$this->gameMode = VarInt::readSignedInt($in);
50
$this->playerActorUniqueId = CommonTypes::getActorUniqueId($in);
51
$this->tick = VarInt::readUnsignedLong($in);
52
}
53
54
protected
function
encodePayload
(ByteBufferWriter $out) : void{
55
VarInt::writeSignedInt($out, $this->gameMode);
56
CommonTypes::putActorUniqueId($out, $this->playerActorUniqueId);
57
VarInt::writeUnsignedLong($out, $this->tick);
58
}
59
60
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
61
return $handler->handleUpdatePlayerGameType($this);
62
}
63
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\UpdatePlayerGameTypePacket
Definition
UpdatePlayerGameTypePacket.php:23
pocketmine\network\mcpe\protocol\UpdatePlayerGameTypePacket\create
static create(int $gameMode, int $playerActorUniqueId, int $tick)
Definition
UpdatePlayerGameTypePacket.php:34
pocketmine\network\mcpe\protocol\UpdatePlayerGameTypePacket\handle
handle(PacketHandlerInterface $handler)
Definition
UpdatePlayerGameTypePacket.php:60
pocketmine\network\mcpe\protocol\UpdatePlayerGameTypePacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
UpdatePlayerGameTypePacket.php:54
pocketmine\network\mcpe\protocol\UpdatePlayerGameTypePacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
UpdatePlayerGameTypePacket.php:48
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\types\GameMode
Definition
vendor/pocketmine/bedrock-protocol/src/types/GameMode.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
UpdatePlayerGameTypePacket.php
Generated by
1.12.0