PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
UpdateBlockPacket.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\BlockPosition
;
22
23
class
UpdateBlockPacket
extends
DataPacket
implements
ClientboundPacket
{
24
public
const
NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_PACKET;
25
26
public
const
FLAG_NONE = 0b0000;
27
public
const
FLAG_NEIGHBORS = 0b0001;
28
public
const
FLAG_NETWORK = 0b0010;
29
public
const
FLAG_NOGRAPHIC = 0b0100;
30
public
const
FLAG_PRIORITY = 0b1000;
31
32
public
const
DATA_LAYER_NORMAL = 0;
33
public
const
DATA_LAYER_LIQUID = 1;
34
35
public
BlockPosition
$blockPosition;
36
public
int
$blockRuntimeId;
42
public
int
$flags = self::FLAG_NETWORK;
43
public
int
$dataLayerId = self::DATA_LAYER_NORMAL;
44
48
public
static
function
create
(
BlockPosition
$blockPosition,
int
$blockRuntimeId,
int
$flags,
int
$dataLayerId) : self{
49
$result = new self;
50
$result->blockPosition = $blockPosition;
51
$result->blockRuntimeId = $blockRuntimeId;
52
$result->flags = $flags;
53
$result->dataLayerId = $dataLayerId;
54
return
$result;
55
}
56
57
protected
function
decodePayload
(ByteBufferReader $in) : void{
58
$this->blockPosition =
CommonTypes
::getBlockPosition($in);
59
$this->blockRuntimeId = VarInt::readUnsignedInt($in);
60
$this->flags = VarInt::readUnsignedInt($in);
61
$this->dataLayerId = VarInt::readUnsignedInt($in);
62
}
63
64
protected
function
encodePayload
(ByteBufferWriter $out) : void{
65
CommonTypes
::putBlockPosition($out, $this->blockPosition);
66
VarInt::writeUnsignedInt($out, $this->blockRuntimeId);
67
VarInt::writeUnsignedInt($out, $this->flags);
68
VarInt::writeUnsignedInt($out, $this->dataLayerId);
69
}
70
71
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
72
return $handler->handleUpdateBlock($this);
73
}
74
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\UpdateBlockPacket
Definition
UpdateBlockPacket.php:23
pocketmine\network\mcpe\protocol\UpdateBlockPacket\create
static create(BlockPosition $blockPosition, int $blockRuntimeId, int $flags, int $dataLayerId)
Definition
UpdateBlockPacket.php:48
pocketmine\network\mcpe\protocol\UpdateBlockPacket\handle
handle(PacketHandlerInterface $handler)
Definition
UpdateBlockPacket.php:71
pocketmine\network\mcpe\protocol\UpdateBlockPacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
UpdateBlockPacket.php:64
pocketmine\network\mcpe\protocol\UpdateBlockPacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
UpdateBlockPacket.php:57
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\types\BlockPosition
Definition
BlockPosition.php:19
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
UpdateBlockPacket.php
Generated by
1.12.0