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