PocketMine-MP 5.28.1 git-88cdc2eb67c40075559c3ef51418b418cd5488e9
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
18
19final class BiomeElementData{
20
21 public function __construct(
22 private float $noiseFrequencyScale,
23 private float $noiseLowerBound,
24 private float $noiseUpperBound,
25 private int $heightMinType,
26 private int $heightMin,
27 private int $heightMaxType,
28 private int $heightMax,
29 private BiomeSurfaceMaterialData $surfaceMaterial,
30 ){}
31
32 public function getNoiseFrequencyScale() : float{ return $this->noiseFrequencyScale; }
33
34 public function getNoiseLowerBound() : float{ return $this->noiseLowerBound; }
35
36 public function getNoiseUpperBound() : float{ return $this->noiseUpperBound; }
37
38 public function getHeightMinType() : int{ return $this->heightMinType; }
39
40 public function getHeightMin() : int{ return $this->heightMin; }
41
42 public function getHeightMaxType() : int{ return $this->heightMaxType; }
43
44 public function getHeightMax() : int{ return $this->heightMax; }
45
46 public function getSurfaceMaterial() : BiomeSurfaceMaterialData{ return $this->surfaceMaterial; }
47
48 public static function read(PacketSerializer $in) : self{
49 $noiseFrequencyScale = $in->getLFloat();
50 $noiseLowerBound = $in->getLFloat();
51 $noiseUpperBound = $in->getLFloat();
52 $heightMinType = $in->getVarInt();
53 $heightMin = $in->getLShort();
54 $heightMaxType = $in->getVarInt();
55 $heightMax = $in->getLShort();
56 $surfaceMaterial = BiomeSurfaceMaterialData::read($in);
57
58 return new self(
59 $noiseFrequencyScale,
60 $noiseLowerBound,
61 $noiseUpperBound,
62 $heightMinType,
63 $heightMin,
64 $heightMaxType,
65 $heightMax,
66 $surfaceMaterial
67 );
68 }
69
70 public function write(PacketSerializer $out) : void{
71 $out->putLFloat($this->noiseFrequencyScale);
72 $out->putLFloat($this->noiseLowerBound);
73 $out->putLFloat($this->noiseUpperBound);
74 $out->putVarInt($this->heightMinType);
75 $out->putLShort($this->heightMin);
76 $out->putVarInt($this->heightMaxType);
77 $out->putLShort($this->heightMax);
78 $this->surfaceMaterial->write($out);
79 }
80}