Fixed #3692; fixed "arrows should not catch fire in fire blocks"

This commit is contained in:
PEMapModder
2016-03-10 17:45:06 +08:00
parent 8a0c2b7c4a
commit 0b06a4f703
2 changed files with 16 additions and 4 deletions

View File

@ -21,6 +21,7 @@
namespace pocketmine\block;
use pocketmine\entity\Arrow;
use pocketmine\entity\Effect;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent;
@ -65,6 +66,9 @@ class Fire extends Flowable{
}
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
if($entity instanceof Arrow){
$ev->setCancelled();
}
Server::getInstance()->getPluginManager()->callEvent($ev);
if(!$ev->isCancelled()){
$entity->setOnFire($ev->getDuration());
@ -88,9 +92,16 @@ class Fire extends Flowable{
return Level::BLOCK_UPDATE_NORMAL;
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getId() !== self::NETHERRACK){
$this->getLevel()->setBlock($this, new Air(), true);
if(mt_rand(0, 2) === 0){
if($this->meta === 0x0F){
$this->level->setBlock($this, new Air());
}else{
$this->meta++;
$this->level->setBlock($this, $this);
}
return Level::BLOCK_UPDATE_NORMAL;
return Level::BLOCK_UPDATE_NORMAL;
}
}
}