mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Use Event::hasHandlers() for a few more hot events
This commit is contained in:
parent
a5d8ef7a6c
commit
447f061566
@ -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();
|
||||
|
@ -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{
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user