PocketMine-MP 5.32.2 git-237b304ef9858756b018e44e8f298093f66f823b
Loading...
Searching...
No Matches
CopperBulb.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\block;
25
27use pocketmine\block\utils\CopperOxidation;
28use pocketmine\block\utils\CopperTrait;
30use pocketmine\block\utils\LightableTrait;
32use pocketmine\block\utils\PoweredByRedstoneTrait;
34
36 use CopperTrait;
37 use PoweredByRedstoneTrait;
38 use LightableTrait{
39 describeBlockOnlyState as encodeLitState;
40 }
41
42 protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
43 $this->encodeLitState($w);
44 $w->bool($this->powered);
45 }
46
48 public function togglePowered(bool $powered) : self{
49 if($powered === $this->powered){
50 return $this;
51 }
52 if ($powered) {
53 $this->setLit(!$this->lit);
54 }
55 $this->setPowered($powered);
56 return $this;
57 }
58
59 public function getLightLevel() : int{
60 if ($this->lit) {
61 return match($this->oxidation){
62 CopperOxidation::NONE => 15,
63 CopperOxidation::EXPOSED => 12,
64 CopperOxidation::WEATHERED => 8,
65 CopperOxidation::OXIDIZED => 4,
66 };
67 }
68
69 return 0;
70 }
71}
describeBlockOnlyState(RuntimeDataDescriber $w)
togglePowered(bool $powered)