diff --git a/src/block/Fire.php b/src/block/Fire.php index a39ef6b9c..11378b82b 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -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(); diff --git a/src/block/Leaves.php b/src/block/Leaves.php index 235190454..b1839dca6 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -116,10 +116,15 @@ class Leaves extends Transparent{ public function onRandomTick() : void{ if(!$this->noDecay && $this->checkDecay){ - $ev = new LeavesDecayEvent($this); - $ev->call(); + $cancelled = false; + if(LeavesDecayEvent::hasHandlers()){ + $ev = new LeavesDecayEvent($this); + $ev->call(); + $cancelled = $ev->isCancelled(); + } + $world = $this->position->getWorld(); - if($ev->isCancelled() || $this->findLog($this->position)){ + if($cancelled || $this->findLog($this->position)){ $this->checkDecay = false; $world->setBlock($this->position, $this, false); }else{ diff --git a/src/world/World.php b/src/world/World.php index 934ff6690..3ff5632cb 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -972,14 +972,17 @@ class World implements ChunkManager{ $block = $replacement; } - $ev = new BlockUpdateEvent($block); - $ev->call(); - if(!$ev->isCancelled()){ - foreach($this->getNearbyEntities(AxisAlignedBB::one()->offset($x, $y, $z)) as $entity){ - $entity->onNearbyBlockChange(); + if(BlockUpdateEvent::hasHandlers()){ + $ev = new BlockUpdateEvent($block); + $ev->call(); + if($ev->isCancelled()){ + continue; } - $block->onNearbyBlockChange(); } + foreach($this->getNearbyEntities(AxisAlignedBB::one()->offset($x, $y, $z)) as $entity){ + $entity->onNearbyBlockChange(); + } + $block->onNearbyBlockChange(); } $this->timings->scheduledBlockUpdates->stopTiming();