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;
}
}
}

View File

@ -33,6 +33,7 @@ use pocketmine\block\BrownMushroom;
use pocketmine\block\Cactus;
use pocketmine\block\Carrot;
use pocketmine\block\Farmland;
use pocketmine\block\Fire;
use pocketmine\block\Grass;
use pocketmine\block\Ice;
use pocketmine\block\Leaves;
@ -248,7 +249,7 @@ class Level implements ChunkManager, Metadatable{
Block::CARROT_BLOCK => Carrot::class,
Block::POTATO_BLOCK => Potato::class,
Block::LEAVES2 => Leaves2::class,
Block::FIRE => Fire::class,
Block::BEETROOT_BLOCK => Beetroot::class,
];
@ -1467,7 +1468,7 @@ class Level implements ChunkManager, Metadatable{
* @param Player $player
* @param bool $createParticles
*
* @return boole
* @return bool
*/
public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, bool $createParticles = false) : bool{
$target = $this->getBlock($vector);