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