-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathBlockPickRequestPacket.php
More file actions
56 lines (46 loc) · 1.77 KB
/
BlockPickRequestPacket.php
File metadata and controls
56 lines (46 loc) · 1.77 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
<?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 BlockPickRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
public BlockPosition $blockPosition;
public bool $addUserData = false;
public int $hotbarSlot;
/**
* @generate-create-func
*/
public static function create(BlockPosition $blockPosition, bool $addUserData, int $hotbarSlot) : self{
$result = new self;
$result->blockPosition = $blockPosition;
$result->addUserData = $addUserData;
$result->hotbarSlot = $hotbarSlot;
return $result;
}
protected function decodePayload(ByteBufferReader $in) : void{
$this->blockPosition = CommonTypes::getBlockPosition($in);
$this->addUserData = CommonTypes::getBool($in);
$this->hotbarSlot = Byte::readUnsigned($in);
}
protected function encodePayload(ByteBufferWriter $out) : void{
CommonTypes::putBlockPosition($out, $this->blockPosition);
CommonTypes::putBool($out, $this->addUserData);
Byte::writeUnsigned($out, $this->hotbarSlot);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBlockPickRequest($this);
}
}