PocketMine-MP 5.43.2 git-a137a986d01d9af23452b2e741699a770c7ae112
Loading...
Searching...
No Matches
BiomeSurfaceBuilderData.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;
20
22
23 public function __construct(
24 private ?BiomeSurfaceMaterialData $surfaceMaterial,
25 private bool $defaultOverworldSurface,
26 private bool $swampSurface,
27 private bool $frozenOceanSurface,
28 private bool $theEndSurface,
29 private ?BiomeMesaSurfaceData $mesaSurface,
30 private ?BiomeCappedSurfaceData $cappedSurface,
31 private ?BiomeNoiseGradientSurfaceData $noiseGradientSurface,
32 ){}
33
34 public function getSurfaceMaterial() : ?BiomeSurfaceMaterialData{ return $this->surfaceMaterial; }
35
36 public function hasDefaultOverworldSurface() : bool{ return $this->defaultOverworldSurface; }
37
38 public function hasSwampSurface() : bool{ return $this->swampSurface; }
39
40 public function hasFrozenOceanSurface() : bool{ return $this->frozenOceanSurface; }
41
42 public function hasTheEndSurface() : bool{ return $this->theEndSurface; }
43
44 public function getMesaSurface() : ?BiomeMesaSurfaceData{ return $this->mesaSurface; }
45
46 public function getCappedSurface() : ?BiomeCappedSurfaceData{ return $this->cappedSurface; }
47
48 public function getNoiseGradientSurface() : ?BiomeNoiseGradientSurfaceData{ return $this->noiseGradientSurface; }
49
50 public static function read(ByteBufferReader $in) : self{
51 $surfaceMaterial = CommonTypes::readOptional($in, fn() => BiomeSurfaceMaterialData::read($in));
52 $defaultOverworldSurface = CommonTypes::getBool($in);
53 $swampSurface = CommonTypes::getBool($in);
54 $frozenOceanSurface = CommonTypes::getBool($in);
55 $theEndSurface = CommonTypes::getBool($in);
56 $mesaSurface = CommonTypes::readOptional($in, fn() => BiomeMesaSurfaceData::read($in));
57 $cappedSurface = CommonTypes::readOptional($in, fn() => BiomeCappedSurfaceData::read($in));
58 $noiseGradientSurface = CommonTypes::readOptional($in, fn() => BiomeNoiseGradientSurfaceData::read($in));
59
60 return new self(
61 $surfaceMaterial,
62 $defaultOverworldSurface,
63 $swampSurface,
64 $frozenOceanSurface,
65 $theEndSurface,
66 $mesaSurface,
67 $cappedSurface,
68 $noiseGradientSurface
69 );
70 }
71
72 public function write(ByteBufferWriter $out) : void{
73 CommonTypes::writeOptional($out, $this->surfaceMaterial, fn(ByteBufferWriter $out, BiomeSurfaceMaterialData $v) => $v->write($out));
74 CommonTypes::putBool($out, $this->defaultOverworldSurface);
75 CommonTypes::putBool($out, $this->swampSurface);
76 CommonTypes::putBool($out, $this->frozenOceanSurface);
77 CommonTypes::putBool($out, $this->theEndSurface);
78 CommonTypes::writeOptional($out, $this->mesaSurface, fn(ByteBufferWriter $out, BiomeMesaSurfaceData $v) => $v->write($out));
79 CommonTypes::writeOptional($out, $this->cappedSurface, fn(ByteBufferWriter $out, BiomeCappedSurfaceData $v) => $v->write($out));
80 CommonTypes::writeOptional($out, $this->noiseGradientSurface, fn(ByteBufferWriter $out, BiomeNoiseGradientSurfaceData $v) => $v->write($out));
81 }
82}