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
22
declare(strict_types=1);
23
24
namespace
pocketmine\block
;
25
26
use
pocketmine\block\utils\FortuneDropHelper
;
27
use
pocketmine\block\utils\Lightable
;
28
use pocketmine\block\utils\LightableTrait;
29
use
pocketmine\item\Item
;
30
use
pocketmine\item\VanillaItems
;
31
use
pocketmine\math\Vector3
;
32
use
pocketmine\player\Player
;
33
use
function
mt_rand;
34
35
class
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
}
pocketmine\block\Opaque
Definition
Opaque.php:30
pocketmine\block\RedstoneOre
Definition
RedstoneOre.php:35
pocketmine\block\RedstoneOre\getDropsForCompatibleTool
getDropsForCompatibleTool(Item $item)
Definition
RedstoneOre.php:68
pocketmine\block\RedstoneOre\getXpDropAmount
getXpDropAmount()
Definition
RedstoneOre.php:78
pocketmine\block\RedstoneOre\onInteract
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
Definition
RedstoneOre.php:42
pocketmine\block\RedstoneOre\isAffectedBySilkTouch
isAffectedBySilkTouch()
Definition
RedstoneOre.php:74
pocketmine\block\RedstoneOre\onNearbyBlockChange
onNearbyBlockChange()
Definition
RedstoneOre.php:50
pocketmine\block\RedstoneOre\ticksRandomly
ticksRandomly()
Definition
RedstoneOre.php:57
pocketmine\block\RedstoneOre\getLightLevel
getLightLevel()
Definition
RedstoneOre.php:38
pocketmine\block\RedstoneOre\onRandomTick
onRandomTick()
Definition
RedstoneOre.php:61
pocketmine\block\utils\FortuneDropHelper
Definition
FortuneDropHelper.php:33
pocketmine\item\Item
Definition
Item.php:60
pocketmine\item\VanillaItems
Definition
VanillaItems.php:346
pocketmine\math\Vector3
Definition
Vector3.php:36
pocketmine\player\Player
Definition
Player.php:173
pocketmine\block\utils\Lightable
Definition
Lightable.php:26
pocketmine\block
Definition
ActivatorRail.php:24
src
block
RedstoneOre.php
Generated by
1.12.0