PocketMine-MP 5.42.1 git-443151900a14fe9dc682cbf786fa441be1294fab
Loading...
Searching...
No Matches
AttributeUpdateLayerSettings.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\VarInt;
21
26 public const ID = AttributeLayerSyncType::UPDATE_LAYER_SETTINGS;
27
28 public function __construct(
29 private string $name,
30 private int $dimension,
31 private AttributeLayerSettings $settings,
32 ){}
33
34 public function getTypeId() : int{
35 return self::ID;
36 }
37
38 public function getName() : string{ return $this->name; }
39
40 public function getDimension() : int{ return $this->dimension; }
41
42 public function getSettings() : AttributeLayerSettings{ return $this->settings; }
43
44 public static function read(ByteBufferReader $in) : self{
45 $name = CommonTypes::getString($in);
46 $dimension = VarInt::readUnsignedInt($in);
47 $settings = AttributeLayerSettings::read($in);
48
49 return new self(
50 $name,
51 $dimension,
52 $settings
53 );
54 }
55
56 public function write(ByteBufferWriter $out) : void{
57 CommonTypes::putString($out, $this->name);
58 VarInt::writeUnsignedInt($out, $this->dimension);
59 $this->settings->write($out);
60 }
61}