PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
BiomeCoordinateData.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\biome\chunkgen;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
20use pmmp\encoding\VarInt;
21
23
24 public function __construct(
25 private int $minValueType,
26 private int $minValue,
27 private int $maxValueType,
28 private int $maxValue,
29 private int $gridOffset,
30 private int $gridStepSize,
31 private int $distribution
32 ){}
33
34 public function getMinValueType() : int{ return $this->minValueType; }
35
36 public function getMinValue() : int{ return $this->minValue; }
37
38 public function getMaxValueType() : int{ return $this->maxValueType; }
39
40 public function getMaxValue() : int{ return $this->maxValue; }
41
42 public function getGridOffset() : int{ return $this->gridOffset; }
43
44 public function getGridStepSize() : int{ return $this->gridStepSize; }
45
46 public function getDistribution() : int{ return $this->distribution; }
47
48 public static function read(ByteBufferReader $in) : self{
49 $minValueType = VarInt::readSignedInt($in);
50 $minValue = LE::readSignedShort($in);
51 $maxValueType = VarInt::readSignedInt($in);
52 $maxValue = LE::readSignedShort($in);
53 $gridOffset = LE::readUnsignedInt($in);
54 $gridStepSize = LE::readUnsignedInt($in);
55 $distribution = VarInt::readSignedInt($in);
56
57 return new self(
58 $minValueType,
59 $minValue,
60 $maxValueType,
61 $maxValue,
62 $gridOffset,
63 $gridStepSize,
64 $distribution
65 );
66 }
67
68 public function write(ByteBufferWriter $out) : void{
69 VarInt::writeSignedInt($out, $this->minValueType);
70 LE::writeSignedShort($out, $this->minValue);
71 VarInt::writeSignedInt($out, $this->maxValueType);
72 LE::writeSignedShort($out, $this->maxValue);
73 LE::writeUnsignedInt($out, $this->gridOffset);
74 LE::writeUnsignedInt($out, $this->gridStepSize);
75 VarInt::writeSignedInt($out, $this->distribution);
76 }
77}