PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
SpawnSettings.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;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
20use pmmp\encoding\VarInt;
22
23final class SpawnSettings{
24 public const BIOME_TYPE_DEFAULT = 0;
25 public const BIOME_TYPE_USER_DEFINED = 1;
26
27 public function __construct(
28 private int $biomeType,
29 private string $biomeName,
30 private int $dimension
31 ){}
32
33 public function getBiomeType() : int{
34 return $this->biomeType;
35 }
36
37 public function getBiomeName() : string{
38 return $this->biomeName;
39 }
40
44 public function getDimension() : int{
45 return $this->dimension;
46 }
47
48 public static function read(ByteBufferReader $in) : self{
49 $biomeType = LE::readUnsignedShort($in);
50 $biomeName = CommonTypes::getString($in);
51 $dimension = VarInt::readSignedInt($in);
52
53 return new self($biomeType, $biomeName, $dimension);
54 }
55
56 public function write(ByteBufferWriter $out) : void{
57 LE::writeUnsignedShort($out, $this->biomeType);
58 CommonTypes::putString($out, $this->biomeName);
59 VarInt::writeSignedInt($out, $this->dimension);
60 }
61}