PocketMine-MP 5.35.1 git-d241807752ab518f2ffc7e3b71f6a72f9cdf0c30
Loading...
Searching...
No Matches
AttributeModifier.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\entity;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
21
23
28 public function __construct(
29 private string $id,
30 private string $name,
31 private float $amount,
32 private int $operation,
33 private int $operand,
34 private bool $serializable //???
35 ){}
36
37 public function getId() : string{ return $this->id; }
38
39 public function getName() : string{ return $this->name; }
40
41 public function getAmount() : float{ return $this->amount; }
42
43 public function getOperation() : int{ return $this->operation; }
44
45 public function getOperand() : int{ return $this->operand; }
46
47 public function isSerializable() : bool{ return $this->serializable; }
48
49 public static function read(ByteBufferReader $in) : self{
50 $id = CommonTypes::getString($in);
51 $name = CommonTypes::getString($in);
52 $amount = LE::readFloat($in);
53 $operation = LE::readSignedInt($in);
54 $operand = LE::readSignedInt($in);
55 $serializable = CommonTypes::getBool($in);
56
57 return new self($id, $name, $amount, $operation, $operand, $serializable);
58 }
59
60 public function write(ByteBufferWriter $out) : void{
61 CommonTypes::putString($out, $this->id);
62 CommonTypes::putString($out, $this->name);
63 LE::writeFloat($out, $this->amount);
64 LE::writeSignedInt($out, $this->operation);
65 LE::writeSignedInt($out, $this->operand);
66 CommonTypes::putBool($out, $this->serializable);
67 }
68}
__construct(private string $id, private string $name, private float $amount, private int $operation, private int $operand, private bool $serializable)