PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
GameTestRequestPacket.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
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
19
21 public const NETWORK_ID = ProtocolInfo::GAME_TEST_REQUEST_PACKET;
22
23 public const ROTATION_0 = 0;
24 public const ROTATION_90 = 1;
25 public const ROTATION_180 = 2;
26 public const ROTATION_270 = 3;
27
28 private int $maxTestsPerBatch;
29 private int $repeatCount;
30 private int $rotation;
31 private bool $stopOnFailure;
32 private BlockPosition $testPosition;
33 private int $testsPerRow;
34 private string $testName;
35
39 public static function create(
40 int $maxTestsPerBatch,
41 int $repeatCount,
42 int $rotation,
43 bool $stopOnFailure,
44 BlockPosition $testPosition,
45 int $testsPerRow,
46 string $testName,
47 ) : self{
48 $result = new self;
49 $result->maxTestsPerBatch = $maxTestsPerBatch;
50 $result->repeatCount = $repeatCount;
51 $result->rotation = $rotation;
52 $result->stopOnFailure = $stopOnFailure;
53 $result->testPosition = $testPosition;
54 $result->testsPerRow = $testsPerRow;
55 $result->testName = $testName;
56 return $result;
57 }
58
59 public function getMaxTestsPerBatch() : int{ return $this->maxTestsPerBatch; }
60
61 public function getRepeatCount() : int{ return $this->repeatCount; }
62
66 public function getRotation() : int{ return $this->rotation; }
67
68 public function isStopOnFailure() : bool{ return $this->stopOnFailure; }
69
70 public function getTestPosition() : BlockPosition{ return $this->testPosition; }
71
72 public function getTestsPerRow() : int{ return $this->testsPerRow; }
73
74 public function getTestName() : string{ return $this->testName; }
75
76 protected function decodePayload(PacketSerializer $in) : void{
77 $this->maxTestsPerBatch = $in->getVarInt();
78 $this->repeatCount = $in->getVarInt();
79 $this->rotation = $in->getByte();
80 $this->stopOnFailure = $in->getBool();
81 $this->testPosition = $in->getSignedBlockPosition();
82 $this->testsPerRow = $in->getVarInt();
83 $this->testName = $in->getString();
84 }
85
86 protected function encodePayload(PacketSerializer $out) : void{
87 $out->putVarInt($this->maxTestsPerBatch);
88 $out->putVarInt($this->repeatCount);
89 $out->putByte($this->rotation);
90 $out->putBool($this->stopOnFailure);
91 $out->putSignedBlockPosition($this->testPosition);
92 $out->putVarInt($this->testsPerRow);
93 $out->putString($this->testName);
94 }
95
96 public function handle(PacketHandlerInterface $handler) : bool{
97 return $handler->handleGameTestRequest($this);
98 }
99}
static create(int $maxTestsPerBatch, int $repeatCount, int $rotation, bool $stopOnFailure, BlockPosition $testPosition, int $testsPerRow, string $testName,)