Add EntityExtinguishEvent (#6671)

This commit is contained in:
zSALLAZAR
2025-04-18 11:19:46 +02:00
committed by GitHub
parent a74168953c
commit 028815490e
5 changed files with 66 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ use pocketmine\block\Water;
use pocketmine\entity\animation\Animation;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDespawnEvent;
use pocketmine\event\entity\EntityExtinguishEvent;
use pocketmine\event\entity\EntityMotionEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\EntitySpawnEvent;
@@ -709,7 +710,10 @@ abstract class Entity{
}
}
public function extinguish() : void{
public function extinguish(int $cause = EntityExtinguishEvent::CAUSE_CUSTOM) : void{
$ev = new EntityExtinguishEvent($this, $cause);
$ev->call();
$this->fireTicks = 0;
$this->networkPropertiesDirty = true;
}
@@ -720,7 +724,7 @@ abstract class Entity{
protected function doOnFireTick(int $tickDiff = 1) : bool{
if($this->isFireProof() && $this->isOnFire()){
$this->extinguish();
$this->extinguish(EntityExtinguishEvent::CAUSE_FIRE_PROOF);
return false;
}
@@ -731,7 +735,7 @@ abstract class Entity{
}
if(!$this->isOnFire()){
$this->extinguish();
$this->extinguish(EntityExtinguishEvent::CAUSE_TICKING);
}else{
return true;
}