Use Event::hasHandlers() for a few more hot events

This commit is contained in:
Dylan K. Taylor
2023-08-09 15:45:15 +01:00
parent a5d8ef7a6c
commit 447f061566
3 changed files with 24 additions and 12 deletions

View File

@ -145,9 +145,13 @@ class Fire extends BaseFire{
private function burnBlock(Block $block, int $chanceBound) : void{
if(mt_rand(0, $chanceBound) < $block->getFlammability()){
$ev = new BlockBurnEvent($block, $this);
$ev->call();
if(!$ev->isCancelled()){
$cancelled = false;
if(BlockBurnEvent::hasHandlers()){
$ev = new BlockBurnEvent($block, $this);
$ev->call();
$cancelled = $ev->isCancelled();
}
if(!$cancelled){
$block->onIncinerate();
$world = $this->position->getWorld();