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
22declare(strict_types=1);
23
24namespace pocketmine\block;
25
27use pocketmine\block\utils\PillarRotationTrait;
29use pocketmine\block\utils\WoodTypeTrait;
37
38class 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}
describeBlockItemState(RuntimeDataDescriber $w)
Definition Wood.php:44
setStripped(bool $stripped)
Definition Wood.php:51
onInteract(Item $item, Facing $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
Definition Wood.php:68