PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
BiomeElementData.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
22final class BiomeElementData{
23
24 public function __construct(
25 private float $noiseFrequencyScale,
26 private float $noiseLowerBound,
27 private float $noiseUpperBound,
28 private int $heightMinType,
29 private int $heightMin,
30 private int $heightMaxType,
31 private int $heightMax,
32 private BiomeSurfaceMaterialData $surfaceMaterial,
33 ){}
34
35 public function getNoiseFrequencyScale() : float{ return $this->noiseFrequencyScale; }
36
37 public function getNoiseLowerBound() : float{ return $this->noiseLowerBound; }
38
39 public function getNoiseUpperBound() : float{ return $this->noiseUpperBound; }
40
41 public function getHeightMinType() : int{ return $this->heightMinType; }
42
43 public function getHeightMin() : int{ return $this->heightMin; }
44
45 public function getHeightMaxType() : int{ return $this->heightMaxType; }
46
47 public function getHeightMax() : int{ return $this->heightMax; }
48
49 public function getSurfaceMaterial() : BiomeSurfaceMaterialData{ return $this->surfaceMaterial; }
50
51 public static function read(ByteBufferReader $in) : self{
52 $noiseFrequencyScale = LE::readFloat($in);
53 $noiseLowerBound = LE::readFloat($in);
54 $noiseUpperBound = LE::readFloat($in);
55 $heightMinType = VarInt::readSignedInt($in);
56 $heightMin = LE::readSignedShort($in);
57 $heightMaxType = VarInt::readSignedInt($in);
58 $heightMax = LE::readSignedShort($in);
59 $surfaceMaterial = BiomeSurfaceMaterialData::read($in);
60
61 return new self(
62 $noiseFrequencyScale,
63 $noiseLowerBound,
64 $noiseUpperBound,
65 $heightMinType,
66 $heightMin,
67 $heightMaxType,
68 $heightMax,
69 $surfaceMaterial
70 );
71 }
72
73 public function write(ByteBufferWriter $out) : void{
74 LE::writeFloat($out, $this->noiseFrequencyScale);
75 LE::writeFloat($out, $this->noiseLowerBound);
76 LE::writeFloat($out, $this->noiseUpperBound);
77 VarInt::writeSignedInt($out, $this->heightMinType);
78 LE::writeSignedShort($out, $this->heightMin);
79 VarInt::writeSignedInt($out, $this->heightMaxType);
80 LE::writeSignedShort($out, $this->heightMax);
81 $this->surfaceMaterial->write($out);
82 }
83}