PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
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 namespace pocketmine\block;
23 
26 
27 class Wood extends Solid{
28  const OAK = 0;
29  const SPRUCE = 1;
30  const BIRCH = 2;
31  const JUNGLE = 3;
32  //const ACACIA = 4;
33  //const DARK_OAK = 5;
34 
35  protected $id = self::WOOD;
36 
37  public function __construct($meta = 0){
38  $this->meta = $meta;
39  }
40 
41  public function getHardness(){
42  return 10;
43  }
44 
45  public function getName(){
46  static $names = [
47  self::OAK => "Oak Wood",
48  self::SPRUCE => "Spruce Wood",
49  self::BIRCH => "Birch Wood",
50  self::JUNGLE => "Jungle Wood",
51  ];
52  return $names[$this->meta & 0x03];
53  }
54 
55  public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
56  $faces = [
57  0 => 0,
58  1 => 0,
59  2 => 0b1000,
60  3 => 0b1000,
61  4 => 0b0100,
62  5 => 0b0100,
63  ];
64 
65  $this->meta = ($this->meta & 0x03) | $faces[$face];
66  $this->getLevel()->setBlock($block, $this, true, true);
67 
68  return true;
69  }
70 
71  public function getDrops(Item $item){
72  return [
73  [$this->id, $this->meta & 0x03, 1],
74  ];
75  }
76 }