PocketMine-MP
5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
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\LightableTrait;
28
use
pocketmine\item\Item
;
29
use
pocketmine\item\VanillaItems
;
30
use
pocketmine\math\Vector3
;
31
use
pocketmine\player\Player
;
32
use
function
mt_rand;
33
34
class
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
}
pocketmine\block\Opaque
Definition
Opaque.php:30
pocketmine\block\RedstoneOre
Definition
RedstoneOre.php:34
pocketmine\block\RedstoneOre\getDropsForCompatibleTool
getDropsForCompatibleTool(Item $item)
Definition
RedstoneOre.php:67
pocketmine\block\RedstoneOre\getXpDropAmount
getXpDropAmount()
Definition
RedstoneOre.php:77
pocketmine\block\RedstoneOre\onInteract
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
Definition
RedstoneOre.php:41
pocketmine\block\RedstoneOre\isAffectedBySilkTouch
isAffectedBySilkTouch()
Definition
RedstoneOre.php:73
pocketmine\block\RedstoneOre\onNearbyBlockChange
onNearbyBlockChange()
Definition
RedstoneOre.php:49
pocketmine\block\RedstoneOre\ticksRandomly
ticksRandomly()
Definition
RedstoneOre.php:56
pocketmine\block\RedstoneOre\getLightLevel
getLightLevel()
Definition
RedstoneOre.php:37
pocketmine\block\RedstoneOre\onRandomTick
onRandomTick()
Definition
RedstoneOre.php:60
pocketmine\block\utils\FortuneDropHelper
Definition
FortuneDropHelper.php:33
pocketmine\item\Item
Definition
Item.php:60
pocketmine\item\VanillaItems
Definition
VanillaItems.php:340
pocketmine\math\Vector3
Definition
Vector3.php:36
pocketmine\player\Player
Definition
Player.php:170
pocketmine\block
Definition
ActivatorRail.php:24
src
block
RedstoneOre.php
Generated by
1.12.0