PocketMine-MP 5.41.1 git-fcc6fb5566a921cb669160c90f56fb68f5b29123
Loading...
Searching...
No Matches
GraphicsOverrideParameterPacket.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;
16
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\LE;
21use pmmp\encoding\VarInt;
24use pocketmine\network\mcpe\protocol\types\GraphicsOverrideParameterType;
26use function count;
27
29 public const NETWORK_ID = ProtocolInfo::GRAPHICS_OVERRIDE_PARAMETER_PACKET;
30
32 private array $values = [];
33 private float $unknownFloat;
34 private Vector3 $unknownVector3;
35 private string $biomeIdentifier;
36 private GraphicsOverrideParameterType $parameterType;
37 private bool $reset;
38
43 public static function create(array $values, float $unknownFloat, Vector3 $unknownVector3, string $biomeIdentifier, GraphicsOverrideParameterType $parameterType, bool $reset) : self{
44 $result = new self;
45 $result->values = $values;
46 $result->unknownFloat = $unknownFloat;
47 $result->unknownVector3 = $unknownVector3;
48 $result->biomeIdentifier = $biomeIdentifier;
49 $result->parameterType = $parameterType;
50 $result->reset = $reset;
51 return $result;
52 }
53
57 public function getValues() : array{ return $this->values; }
58
59 public function getUnknownFloat() : float{ return $this->unknownFloat; }
60
61 public function getUnknownVector3() : Vector3{ return $this->unknownVector3; }
62
63 public function getBiomeIdentifier() : string{ return $this->biomeIdentifier; }
64
65 public function getParameterType() : GraphicsOverrideParameterType{ return $this->parameterType; }
66
67 public function isReset() : bool{ return $this->reset; }
68
69 protected function decodePayload(ByteBufferReader $in) : void{
70 $count = VarInt::readUnsignedInt($in);
71 for($i = 0; $i < $count; ++$i){
72 $this->values[] = ParameterKeyframeValue::read($in);
73 }
74 $this->unknownFloat = LE::readFloat($in);
75 $this->unknownVector3 = CommonTypes::getVector3($in);
76 $this->biomeIdentifier = CommonTypes::getString($in);
77 $this->parameterType = GraphicsOverrideParameterType::fromPacket(Byte::readUnsigned($in));
78 $this->reset = CommonTypes::getBool($in);
79 }
80
81 protected function encodePayload(ByteBufferWriter $out) : void{
82 VarInt::writeUnsignedInt($out, count($this->values));
83 foreach($this->values as $value){
84 $value->write($out);
85 }
86 LE::writeFloat($out, $this->unknownFloat);
87 CommonTypes::putVector3($out, $this->unknownVector3);
88 CommonTypes::putString($out, $this->biomeIdentifier);
89 Byte::writeUnsigned($out, $this->parameterType->value);
90 CommonTypes::putBool($out, $this->reset);
91 }
92
93 public function handle(PacketHandlerInterface $handler) : bool{
94 return $handler->handleGraphicsOverrideParameter($this);
95 }
96}
static create(array $values, float $unknownFloat, Vector3 $unknownVector3, string $biomeIdentifier, GraphicsOverrideParameterType $parameterType, bool $reset)