-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathGameTestRequestPacket.php
More file actions
103 lines (85 loc) · 3.21 KB
/
GameTestRequestPacket.php
File metadata and controls
103 lines (85 loc) · 3.21 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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 pmmp\encoding\VarInt;
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;
use pocketmine\network\mcpe\protocol\types\BlockPosition;
class GameTestRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::GAME_TEST_REQUEST_PACKET;
public const ROTATION_0 = 0;
public const ROTATION_90 = 1;
public const ROTATION_180 = 2;
public const ROTATION_270 = 3;
private int $maxTestsPerBatch;
private int $repeatCount;
private int $rotation;
private bool $stopOnFailure;
private BlockPosition $testPosition;
private int $testsPerRow;
private string $testName;
/**
* @generate-create-func
*/
public static function create(
int $maxTestsPerBatch,
int $repeatCount,
int $rotation,
bool $stopOnFailure,
BlockPosition $testPosition,
int $testsPerRow,
string $testName,
) : self{
$result = new self;
$result->maxTestsPerBatch = $maxTestsPerBatch;
$result->repeatCount = $repeatCount;
$result->rotation = $rotation;
$result->stopOnFailure = $stopOnFailure;
$result->testPosition = $testPosition;
$result->testsPerRow = $testsPerRow;
$result->testName = $testName;
return $result;
}
public function getMaxTestsPerBatch() : int{ return $this->maxTestsPerBatch; }
public function getRepeatCount() : int{ return $this->repeatCount; }
/**
* @see self::ROTATION_*
*/
public function getRotation() : int{ return $this->rotation; }
public function isStopOnFailure() : bool{ return $this->stopOnFailure; }
public function getTestPosition() : BlockPosition{ return $this->testPosition; }
public function getTestsPerRow() : int{ return $this->testsPerRow; }
public function getTestName() : string{ return $this->testName; }
protected function decodePayload(ByteBufferReader $in) : void{
$this->maxTestsPerBatch = VarInt::readSignedInt($in);
$this->repeatCount = VarInt::readSignedInt($in);
$this->rotation = Byte::readUnsigned($in);
$this->stopOnFailure = CommonTypes::getBool($in);
$this->testPosition = CommonTypes::getBlockPosition($in);
$this->testsPerRow = VarInt::readSignedInt($in);
$this->testName = CommonTypes::getString($in);
}
protected function encodePayload(ByteBufferWriter $out) : void{
VarInt::writeSignedInt($out, $this->maxTestsPerBatch);
VarInt::writeSignedInt($out, $this->repeatCount);
Byte::writeUnsigned($out, $this->rotation);
CommonTypes::putBool($out, $this->stopOnFailure);
CommonTypes::putBlockPosition($out, $this->testPosition);
VarInt::writeSignedInt($out, $this->testsPerRow);
CommonTypes::putString($out, $this->testName);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleGameTestRequest($this);
}
}