Added BlockBurnEvent

This commit is contained in:
Dylan K. Taylor
2018-03-20 09:44:49 +00:00
parent 7db8845375
commit af9b0b019d
2 changed files with 57 additions and 5 deletions

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\entity\projectile\Arrow;
use pocketmine\event\block\BlockBurnEvent;
use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
@ -152,12 +153,15 @@ class Fire extends Flowable{
private function burnBlock(Block $block, int $chanceBound) : void{
if(mt_rand(0, $chanceBound) < $block->getFlammability()){
$block->onIncinerate();
$this->level->getServer()->getPluginManager()->callEvent($ev = new BlockBurnEvent($block, $this));
if(!$ev->isCancelled()){
$block->onIncinerate();
if(mt_rand(0, $this->meta + 9) < 5){ //TODO: check rain
$this->level->setBlock($block, BlockFactory::get(Block::FIRE, min(15, $this->meta + (mt_rand(0, 4) >> 2))));
}else{
$this->level->setBlock($block, BlockFactory::get(Block::AIR));
if(mt_rand(0, $this->meta + 9) < 5){ //TODO: check rain
$this->level->setBlock($block, BlockFactory::get(Block::FIRE, min(15, $this->meta + (mt_rand(0, 4) >> 2))));
}else{
$this->level->setBlock($block, BlockFactory::get(Block::AIR));
}
}
}
}