PocketMine-MP 5.32.2 git-237b304ef9858756b018e44e8f298093f66f823b
Loading...
Searching...
No Matches
RedstoneOre.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
28use pocketmine\block\utils\LightableTrait;
33use function mt_rand;
34
35class RedstoneOre extends Opaque implements Lightable{
36 use LightableTrait;
37
38 public function getLightLevel() : int{
39 return $this->lit ? 9 : 0;
40 }
41
42 public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
43 if(!$this->lit){
44 $this->lit = true;
45 $this->position->getWorld()->setBlock($this->position, $this); //no return here - this shouldn't prevent block placement
46 }
47 return false;
48 }
49
50 public function onNearbyBlockChange() : void{
51 if(!$this->lit){
52 $this->lit = true;
53 $this->position->getWorld()->setBlock($this->position, $this);
54 }
55 }
56
57 public function ticksRandomly() : bool{
58 return $this->lit;
59 }
60
61 public function onRandomTick() : void{
62 if($this->lit){
63 $this->lit = false;
64 $this->position->getWorld()->setBlock($this->position, $this);
65 }
66 }
67
68 public function getDropsForCompatibleTool(Item $item) : array{
69 return [
70 VanillaItems::REDSTONE_DUST()->setCount(FortuneDropHelper::discrete($item, 4, 5))
71 ];
72 }
73
74 public function isAffectedBySilkTouch() : bool{
75 return true;
76 }
77
78 protected function getXpDropAmount() : int{
79 return mt_rand(1, 5);
80 }
81}
getDropsForCompatibleTool(Item $item)
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])