PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
BiomeConditionalTransformationData.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;
21use function count;
22
24
28 public function __construct(
29 private array $weightedBiomes,
30 private int $conditionJSON,
31 private int $minPassingNeighbors,
32 ){}
33
37 public function getWeightedBiomes() : array{ return $this->weightedBiomes; }
38
39 public function getConditionJSON() : int{ return $this->conditionJSON; }
40
41 public function getMinPassingNeighbors() : int{ return $this->minPassingNeighbors; }
42
43 public static function read(ByteBufferReader $in) : self{
44 $weightedBiomes = [];
45 for($i = 0, $count = VarInt::readUnsignedInt($in); $i < $count; ++$i){
46 $weightedBiomes[] = BiomeWeightedData::read($in);
47 }
48
49 $conditionJSON = LE::readSignedShort($in);
50 $minPassingNeighbors = LE::readUnsignedInt($in);
51
52 return new self(
53 $weightedBiomes,
54 $conditionJSON,
55 $minPassingNeighbors,
56 );
57 }
58
59 public function write(ByteBufferWriter $out) : void{
60 VarInt::writeUnsignedInt($out, count($this->weightedBiomes));
61 foreach($this->weightedBiomes as $biome){
62 $biome->write($out);
63 }
64
65 LE::writeSignedShort($out, $this->conditionJSON);
66 LE::writeUnsignedInt($out, $this->minPassingNeighbors);
67 }
68}
__construct(private array $weightedBiomes, private int $conditionJSON, private int $minPassingNeighbors,)