PocketMine-MP 5.42.1 git-443151900a14fe9dc682cbf786fa441be1294fab
Loading...
Searching...
No Matches
AttributeValueBool.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;
20
25 public const ID = AttributeValueType::BOOL;
26
27 public const OPERATION_OVERRIDE = "override";
28 public const OPERATION_ALPHA_BLEND = "alpha_blend";
29 public const OPERATION_AND = "and";
30 public const OPERATION_NAND = "nand";
31 public const OPERATION_OR = "or";
32 public const OPERATION_NOR = "nor";
33 public const OPERATION_XOR = "xor";
34 public const OPERATION_XNOR = "xnor";
35
36 public function __construct(
37 private bool $value,
38 private string $operation,
39 ){}
40
41 public function getTypeId() : int{
42 return self::ID;
43 }
44
45 public function getValue() : bool{ return $this->value; }
46
47 public function getOperation() : string{ return $this->operation; }
48
49 public static function read(ByteBufferReader $in) : self{
50 $value = CommonTypes::getBool($in);
51 $operation = CommonTypes::getString($in);
52
53 return new self(
54 $value,
55 $operation
56 );
57 }
58
59 public function write(ByteBufferWriter $out) : void{
60 CommonTypes::putBool($out, $this->value);
61 CommonTypes::putString($out, $this->operation);
62 }
63}