PocketMine-MP
5.33.2 git-1133d49c924b4358c79d44eeb97dcbf56cb4d1eb
Loading...
Searching...
No Matches
Wood.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\PillarRotation
;
27
use pocketmine\block\utils\PillarRotationTrait;
28
use
pocketmine\block\utils\WoodMaterial
;
29
use pocketmine\block\utils\WoodTypeTrait;
30
use
pocketmine\data\runtime\RuntimeDataDescriber
;
31
use
pocketmine\item\Axe
;
32
use
pocketmine\item\Item
;
33
use
pocketmine\math\Facing
;
34
use
pocketmine\math\Vector3
;
35
use
pocketmine\player\Player
;
36
use
pocketmine\world\sound\ItemUseOnBlockSound
;
37
38
class
Wood
extends
Opaque
implements
PillarRotation
,
WoodMaterial
{
39
use PillarRotationTrait;
40
use WoodTypeTrait;
41
42
private
bool
$stripped =
false
;
43
44
public
function
describeBlockItemState
(
RuntimeDataDescriber
$w) : void{
45
$w->bool($this->stripped);
46
}
47
48
public
function
isStripped() : bool{ return $this->stripped; }
49
51
public
function
setStripped
(
bool
$stripped) : self{
52
$this->stripped = $stripped;
53
return
$this;
54
}
55
56
public
function
getFuelTime
() : int{
57
return $this->woodType->isFlammable() ? 300 : 0;
58
}
59
60
public
function
getFlameEncouragement
() : int{
61
return $this->woodType->isFlammable() ? 5 : 0;
62
}
63
64
public
function
getFlammability
() : int{
65
return $this->woodType->isFlammable() ? 5 : 0;
66
}
67
68
public
function
onInteract
(
Item
$item,
Facing
$face,
Vector3
$clickVector, ?
Player
$player =
null
, array &$returnedItems = []) : bool{
69
if(!$this->stripped && $item instanceof
Axe
){
70
$item->applyDamage(1);
71
$this->stripped =
true
;
72
$this->position->getWorld()->setBlock($this->position, $this);
73
$this->position->getWorld()->addSound($this->position,
new
ItemUseOnBlockSound
($this));
74
return
true
;
75
}
76
return
false
;
77
}
78
}
pocketmine\block\Opaque
Definition
Opaque.php:30
pocketmine\block\Wood
Definition
Wood.php:38
pocketmine\block\Wood\getFuelTime
getFuelTime()
Definition
Wood.php:56
pocketmine\block\Wood\describeBlockItemState
describeBlockItemState(RuntimeDataDescriber $w)
Definition
Wood.php:44
pocketmine\block\Wood\getFlameEncouragement
getFlameEncouragement()
Definition
Wood.php:60
pocketmine\block\Wood\setStripped
setStripped(bool $stripped)
Definition
Wood.php:51
pocketmine\block\Wood\getFlammability
getFlammability()
Definition
Wood.php:64
pocketmine\block\Wood\onInteract
onInteract(Item $item, Facing $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
Definition
Wood.php:68
pocketmine\item\Axe
Definition
Axe.php:30
pocketmine\item\Item
Definition
Item.php:62
pocketmine\math\Vector3
Definition
Vector3.php:37
pocketmine\player\Player
Definition
Player.php:173
pocketmine\world\sound\ItemUseOnBlockSound
Definition
ItemUseOnBlockSound.php:32
pocketmine\block\utils\PillarRotation
Definition
PillarRotation.php:28
pocketmine\block\utils\WoodMaterial
Definition
WoodMaterial.php:26
pocketmine\data\runtime\RuntimeDataDescriber
Definition
RuntimeDataDescriber.php:38
pocketmine\block
Definition
ActivatorRail.php:24
pocketmine\math\Facing
Facing
Definition
Facing.php:28
src
block
Wood.php
Generated by
1.12.0