Water bottles extinguish fires when hitting a block

This commit is contained in:
Dylan K. Taylor 2018-03-09 12:03:21 +00:00
parent 2e9bf7e93b
commit a9957c3db3

View File

@ -23,9 +23,12 @@ declare(strict_types=1);
namespace pocketmine\entity\projectile;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\entity\EffectInstance;
use pocketmine\entity\Living;
use pocketmine\event\entity\ProjectileHitEntityEvent;
use pocketmine\event\entity\ProjectileHitBlockEvent;
use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\item\Potion;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
@ -109,6 +112,17 @@ class SplashPotion extends Throwable{
}else{
//TODO: lingering potions
}
}elseif($event instanceof ProjectileHitBlockEvent and $this->getPotionId() === Potion::WATER){
$blockIn = $event->getBlockHit()->getSide($event->getRayTraceResult()->getHitFace());
if($blockIn->getId() === Block::FIRE){
$this->level->setBlock($blockIn, BlockFactory::get(Block::AIR));
}
foreach($blockIn->getHorizontalSides() as $horizontalSide){
if($horizontalSide->getId() === Block::FIRE){
$this->level->setBlock($horizontalSide, BlockFactory::get(Block::AIR));
}
}
}
$this->flagForDespawn();