PocketMine-MP 5.28.1 git-88cdc2eb67c40075559c3ef51418b418cd5488e9
Loading...
Searching...
No Matches
BiomeCappedSurfaceData.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
18use function count;
19
21
26 public function __construct(
27 private array $floorBlocks,
28 private array $ceilingBlocks,
29 private ?int $seaBlock,
30 private ?int $foundationBlock,
31 private ?int $beachBlock,
32 ){}
33
37 public function getFloorBlocks() : array{ return $this->floorBlocks; }
38
42 public function getCeilingBlocks() : array{ return $this->ceilingBlocks; }
43
44 public function getSeaBlock() : ?int{ return $this->seaBlock; }
45
46 public function getFoundationBlock() : ?int{ return $this->foundationBlock; }
47
48 public function getBeachBlock() : ?int{ return $this->beachBlock; }
49
50 public static function read(PacketSerializer $in) : self{
51 $floorBlocks = [];
52 for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
53 $floorBlocks[] = $in->getLInt();
54 }
55
56 $ceilingBlocks = [];
57 for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
58 $ceilingBlocks[] = $in->getLInt();
59 }
60
61 $seaBlock = $in->readOptional($in->getLInt(...));
62 $foundationBlock = $in->readOptional($in->getLInt(...));
63 $beachBlock = $in->readOptional($in->getLInt(...));
64
65 return new self(
66 $floorBlocks,
67 $ceilingBlocks,
68 $seaBlock,
69 $foundationBlock,
70 $beachBlock
71 );
72 }
73
74 public function write(PacketSerializer $out) : void{
75 $out->putUnsignedVarInt(count($this->floorBlocks));
76 foreach($this->floorBlocks as $block){
77 $out->putLInt($block);
78 }
79
80 $out->putUnsignedVarInt(count($this->ceilingBlocks));
81 foreach($this->ceilingBlocks as $block){
82 $out->putLInt($block);
83 }
84
85 $out->writeOptional($this->seaBlock, $out->putLInt(...));
86 $out->writeOptional($this->foundationBlock, $out->putLInt(...));
87 $out->writeOptional($this->beachBlock, $out->putLInt(...));
88 }
89}
__construct(private array $floorBlocks, private array $ceilingBlocks, private ?int $seaBlock, private ?int $foundationBlock, private ?int $beachBlock,)