PocketMine-MP 5.44.3 git-327e8a1690982f1ac3634944d705ebad5d91f4ad
Loading...
Searching...
No Matches
PrimitiveShapeCylinderPayload.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\types\shape;
16
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\LE;
23use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait;
24
26 use GetTypeIdFromConstTrait;
27
28 public const ID = PrimitiveShapeType::PAYLOAD_TYPE_CYLINDER;
29
30 public function __construct(
31 private Vector2 $radiusX,
32 private Vector2 $radiusZ,
33 private float $height,
34 private int $segments,
35 ){}
36
37 public function getRadiusX() : Vector2{ return $this->radiusX; }
38
39 public function getRadiusZ() : Vector2{ return $this->radiusZ; }
40
41 public function getHeight() : float{ return $this->height; }
42
43 public function getSegments() : int{ return $this->segments; }
44
45 public static function read(ByteBufferReader $in) : self{
46 $radiusX = CommonTypes::getVector2($in);
47 $radiusZ = CommonTypes::getVector2($in);
48 $height = LE::readFloat($in);
49 $segments = Byte::readUnsigned($in);
50
51 return new self($radiusX, $radiusZ, $height, $segments);
52 }
53
54 public function write(ByteBufferWriter $out) : void{
55 CommonTypes::putVector2($out, $this->radiusX);
56 CommonTypes::putVector2($out, $this->radiusZ);
57 LE::writeFloat($out, $this->height);
58 Byte::writeUnsigned($out, $this->segments);
59 }
60}