-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathLabTablePacket.php
More file actions
60 lines (49 loc) · 1.87 KB
/
LabTablePacket.php
File metadata and controls
60 lines (49 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pmmp\encoding\Byte;
use pmmp\encoding\ByteBufferReader;
use pmmp\encoding\ByteBufferWriter;
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;
use pocketmine\network\mcpe\protocol\types\BlockPosition;
class LabTablePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET;
public const TYPE_START_COMBINE = 0;
public const TYPE_START_REACTION = 1;
public const TYPE_RESET = 2;
public int $actionType;
public BlockPosition $blockPosition;
public int $reactionType;
/**
* @generate-create-func
*/
public static function create(int $actionType, BlockPosition $blockPosition, int $reactionType) : self{
$result = new self;
$result->actionType = $actionType;
$result->blockPosition = $blockPosition;
$result->reactionType = $reactionType;
return $result;
}
protected function decodePayload(ByteBufferReader $in) : void{
$this->actionType = Byte::readUnsigned($in);
$this->blockPosition = CommonTypes::getBlockPosition($in);
$this->reactionType = Byte::readUnsigned($in);
}
protected function encodePayload(ByteBufferWriter $out) : void{
Byte::writeUnsigned($out, $this->actionType);
CommonTypes::putBlockPosition($out, $this->blockPosition);
Byte::writeUnsigned($out, $this->reactionType);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLabTable($this);
}
}