PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
BiomeScatterParamData.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 $coordinates,
30 private int $evalOrder,
31 private int $chancePercentType,
32 private int $chancePercent,
33 private int $chanceNumerator,
34 private int $chanceDenominator,
35 private int $iterationsType,
36 private int $iterations,
37 ){}
38
42 public function getCoordinates() : array{ return $this->coordinates; }
43
44 public function getEvalOrder() : int{ return $this->evalOrder; }
45
46 public function getChancePercentType() : int{ return $this->chancePercentType; }
47
48 public function getChancePercent() : int{ return $this->chancePercent; }
49
50 public function getChanceNumerator() : int{ return $this->chanceNumerator; }
51
52 public function getChanceDenominator() : int{ return $this->chanceDenominator; }
53
54 public function getIterationsType() : int{ return $this->iterationsType; }
55
56 public function getIterations() : int{ return $this->iterations; }
57
58 public static function read(ByteBufferReader $in) : self{
59 $coordinates = [];
60 for($i = 0, $count = VarInt::readUnsignedInt($in); $i < $count; ++$i){
61 $coordinates[] = BiomeCoordinateData::read($in);
62 }
63 $evalOrder = VarInt::readSignedInt($in);
64 $chancePercentType = VarInt::readSignedInt($in);
65 $chancePercent = LE::readSignedShort($in);
66 $chanceNumerator = LE::readSignedInt($in);
67 $chanceDenominator = LE::readSignedInt($in);
68 $iterationsType = VarInt::readSignedInt($in);
69 $iterations = LE::readSignedShort($in);
70
71 return new self(
72 $coordinates,
73 $evalOrder,
74 $chancePercentType,
75 $chancePercent,
76 $chanceNumerator,
77 $chanceDenominator,
78 $iterationsType,
79 $iterations
80 );
81 }
82
83 public function write(ByteBufferWriter $out) : void{
84 VarInt::writeUnsignedInt($out, count($this->coordinates));
85 foreach($this->coordinates as $coordinate){
86 $coordinate->write($out);
87 }
88 VarInt::writeSignedInt($out, $this->evalOrder);
89 VarInt::writeSignedInt($out, $this->chancePercentType);
90 LE::writeSignedShort($out, $this->chancePercent);
91 LE::writeSignedInt($out, $this->chanceNumerator);
92 LE::writeSignedInt($out, $this->chanceDenominator);
93 VarInt::writeSignedInt($out, $this->iterationsType);
94 LE::writeSignedShort($out, $this->iterations);
95 }
96}
__construct(private array $coordinates, private int $evalOrder, private int $chancePercentType, private int $chancePercent, private int $chanceNumerator, private int $chanceDenominator, private int $iterationsType, private int $iterations,)