mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-14 22:01:59 +00:00
Added BlockBurnEvent
This commit is contained in:
parent
7db8845375
commit
af9b0b019d
@ -25,6 +25,7 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\entity\projectile\Arrow;
|
use pocketmine\entity\projectile\Arrow;
|
||||||
|
use pocketmine\event\block\BlockBurnEvent;
|
||||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
@ -152,6 +153,8 @@ class Fire extends Flowable{
|
|||||||
|
|
||||||
private function burnBlock(Block $block, int $chanceBound) : void{
|
private function burnBlock(Block $block, int $chanceBound) : void{
|
||||||
if(mt_rand(0, $chanceBound) < $block->getFlammability()){
|
if(mt_rand(0, $chanceBound) < $block->getFlammability()){
|
||||||
|
$this->level->getServer()->getPluginManager()->callEvent($ev = new BlockBurnEvent($block, $this));
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
$block->onIncinerate();
|
$block->onIncinerate();
|
||||||
|
|
||||||
if(mt_rand(0, $this->meta + 9) < 5){ //TODO: check rain
|
if(mt_rand(0, $this->meta + 9) < 5){ //TODO: check rain
|
||||||
@ -162,3 +165,4 @@ class Fire extends Flowable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
48
src/pocketmine/event/block/BlockBurnEvent.php
Normal file
48
src/pocketmine/event/block/BlockBurnEvent.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\event\block;
|
||||||
|
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\event\Cancellable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a block is burned away by fire.
|
||||||
|
*/
|
||||||
|
class BlockBurnEvent extends BlockEvent implements Cancellable{
|
||||||
|
/** @var Block */
|
||||||
|
private $causingBlock;
|
||||||
|
|
||||||
|
public function __construct(Block $block, Block $causingBlock){
|
||||||
|
parent::__construct($block);
|
||||||
|
$this->causingBlock = $causingBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block (usually Fire) which caused the target block to be burned away.
|
||||||
|
* @return Block
|
||||||
|
*/
|
||||||
|
public function getCausingBlock() : Block{
|
||||||
|
return $this->causingBlock;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user