PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Fire.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 
31 
32 class Fire extends Flowable{
33 
34  protected $id = self::FIRE;
35 
36  public function __construct($meta = 0){
37  $this->meta = $meta;
38  }
39 
40  public function hasEntityCollision(){
41  return true;
42  }
43 
44  public function getName(){
45  return "Fire Block";
46  }
47 
48  public function getLightLevel(){
49  return 15;
50  }
51 
52  public function isBreakable(Item $item){
53  return false;
54  }
55 
56  public function canBeReplaced(){
57  return true;
58  }
59 
60  public function onEntityCollide(Entity $entity){
61  $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
62  $entity->attack($ev->getFinalDamage(), $ev);
63 
64  $ev = new EntityCombustByBlockEvent($this, $entity, 8);
65  Server::getInstance()->getPluginManager()->callEvent($ev);
66  if(!$ev->isCancelled()){
67  $entity->setOnFire($ev->getDuration());
68  }
69  }
70 
71  public function getDrops(Item $item){
72  return [];
73  }
74 
75  public function onUpdate($type){
76  if($type === Level::BLOCK_UPDATE_NORMAL){
77  for($s = 0; $s <= 5; ++$s){
78  $side = $this->getSide($s);
79  if($side->getId() !== self::AIR and !($side instanceof Liquid)){
80  return false;
81  }
82  }
83  $this->getLevel()->setBlock($this, new Air(), true);
84 
85  return Level::BLOCK_UPDATE_NORMAL;
86  }elseif($type === Level::BLOCK_UPDATE_RANDOM){
87  if($this->getSide(0)->getId() !== self::NETHERRACK){
88  $this->getLevel()->setBlock($this, new Air(), true);
89 
90  return Level::BLOCK_UPDATE_NORMAL;
91  }
92  }
93 
94  return false;
95  }
96 
97 }
attack($damage, $source=EntityDamageEvent::CAUSE_MAGIC)
static getInstance()
Definition: Server.php:1444
getSide($side, $step=1)
Definition: Block.php:1028