PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
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
26use pocketmine\block\utils\PillarRotationTrait;
27use pocketmine\block\utils\WoodTypeTrait;
34
35class Wood extends Opaque{
36 use PillarRotationTrait;
37 use WoodTypeTrait;
38
39 private bool $stripped = false;
40
41 public function describeBlockItemState(RuntimeDataDescriber $w) : void{
42 $w->bool($this->stripped);
43 }
44
45 public function isStripped() : bool{ return $this->stripped; }
46
48 public function setStripped(bool $stripped) : self{
49 $this->stripped = $stripped;
50 return $this;
51 }
52
53 public function getFuelTime() : int{
54 return $this->woodType->isFlammable() ? 300 : 0;
55 }
56
57 public function getFlameEncouragement() : int{
58 return $this->woodType->isFlammable() ? 5 : 0;
59 }
60
61 public function getFlammability() : int{
62 return $this->woodType->isFlammable() ? 5 : 0;
63 }
64
65 public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
66 if(!$this->stripped && $item instanceof Axe){
67 $item->applyDamage(1);
68 $this->stripped = true;
69 $this->position->getWorld()->setBlock($this->position, $this);
70 $this->position->getWorld()->addSound($this->position, new ItemUseOnBlockSound($this));
71 return true;
72 }
73 return false;
74 }
75}
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
Definition Wood.php:65
describeBlockItemState(RuntimeDataDescriber $w)
Definition Wood.php:41
setStripped(bool $stripped)
Definition Wood.php:48