PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
BurningFurnace.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 
33 
34 class BurningFurnace extends Solid{
35 
36  protected $id = self::BURNING_FURNACE;
37 
38  public function __construct($meta = 0){
39  $this->meta = $meta;
40  }
41 
42  public function getName(){
43  return "Burning Furnace";
44  }
45 
46  public function canBeActivated(){
47  return true;
48  }
49 
50  public function getHardness(){
51  return 17.5;
52  }
53 
54  public function getLightLevel(){
55  return 13;
56  }
57 
58  public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
59  $faces = [
60  0 => 4,
61  1 => 2,
62  2 => 5,
63  3 => 3,
64  ];
65  $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
66  $this->getLevel()->setBlock($block, $this, true, true);
67  $nbt = new Compound(false, [
68  new Enum("Items", []),
69  new String("id", Tile::FURNACE),
70  new Int("x", $this->x),
71  new Int("y", $this->y),
72  new Int("z", $this->z)
73  ]);
74  $nbt->Items->setTagType(NBT::TAG_Compound);
75  Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
76 
77  return true;
78  }
79 
80  public function onBreak(Item $item){
81  $this->getLevel()->setBlock($this, new Air(), true, true);
82 
83  return true;
84  }
85 
86  public function onActivate(Item $item, Player $player = null){
87  if($player instanceof Player){
88  $t = $this->getLevel()->getTile($this);
89  $furnace = false;
90  if($t instanceof Furnace){
91  $furnace = $t;
92  }else{
93  $nbt = new Compound(false, [
94  new Enum("Items", []),
95  new String("id", Tile::FURNACE),
96  new Int("x", $this->x),
97  new Int("y", $this->y),
98  new Int("z", $this->z)
99  ]);
100  $nbt->Items->setTagType(NBT::TAG_Compound);
101  $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
102  }
103 
104  if(($player->getGamemode() & 0x01) === 0x01){
105  return true;
106  }
107 
108  $player->addWindow($furnace->getInventory());
109  }
110 
111  return true;
112  }
113 
114  public function getBreakTime(Item $item){
115  switch($item->isPickaxe()){
116  case 5:
117  return 0.7;
118  case 4:
119  return 0.9;
120  case 3:
121  return 1.35;
122  case 2:
123  return 0.45;
124  case 1:
125  return 2.65;
126  default:
127  return 17.5;
128  }
129  }
130 
131  public function getDrops(Item $item){
132  $drops = [];
133  if($item->isPickaxe() >= 1){
134  $drops[] = [Item::FURNACE, 0, 1];
135  }
136 
137  return $drops;
138  }
139 }
static createTile($type, FullChunk $chunk, Compound $nbt,...$args)
Definition: Tile.php:74