Merge 'minor-next' into 'major-next'

Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/14544397106
This commit is contained in:
pmmp-admin-bot[bot] 2025-04-19 01:36:21 +00:00
commit baee0110c7
5 changed files with 66 additions and 6 deletions

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityExtinguishEvent;
use pocketmine\world\sound\BucketEmptyWaterSound;
use pocketmine\world\sound\BucketFillWaterSound;
use pocketmine\world\sound\Sound;
@ -53,7 +54,7 @@ class Water extends Liquid{
public function onEntityInside(Entity $entity) : bool{
$entity->resetFallDistance();
if($entity->isOnFire()){
$entity->extinguish();
$entity->extinguish(EntityExtinguishEvent::CAUSE_WATER);
}
return true;
}

View File

@ -27,6 +27,7 @@ use pocketmine\block\tile\Cauldron as TileCauldron;
use pocketmine\block\utils\DyeColor;
use pocketmine\color\Color;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityExtinguishEvent;
use pocketmine\item\Armor;
use pocketmine\item\Banner;
use pocketmine\item\Dye;
@ -183,7 +184,7 @@ final class WaterCauldron extends FillableCauldron{
public function onEntityInside(Entity $entity) : bool{
if($entity->isOnFire()){
$entity->extinguish();
$entity->extinguish(EntityExtinguishEvent::CAUSE_WATER_CAULDRON);
//TODO: particles
$this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::ENTITY_EXTINGUISH_USE_AMOUNT));

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;
}

View File

@ -0,0 +1,53 @@
<?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\entity;
use pocketmine\entity\Entity;
/**
* Called when an entity on fire gets extinguished.
*
* @phpstan-extends EntityEvent<Entity>
*/
class EntityExtinguishEvent extends EntityEvent{
public const CAUSE_CUSTOM = 0;
public const CAUSE_WATER = 1;
public const CAUSE_WATER_CAULDRON = 2;
public const CAUSE_RESPAWN = 3;
public const CAUSE_FIRE_PROOF = 4;
public const CAUSE_TICKING = 5;
public const CAUSE_RAIN = 6;
public const CAUSE_POWDER_SNOW = 7;
public function __construct(
Entity $entity,
private int $cause
){
$this->entity = $entity;
}
public function getCause() : int{
return $this->cause;
}
}

View File

@ -46,6 +46,7 @@ use pocketmine\entity\projectile\Arrow;
use pocketmine\entity\Skin;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityExtinguishEvent;
use pocketmine\event\inventory\InventoryCloseEvent;
use pocketmine\event\inventory\InventoryOpenEvent;
use pocketmine\event\player\PlayerBedEnterEvent;
@ -2551,7 +2552,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->setSneaking(false);
$this->setFlying(false);
$this->extinguish();
$this->extinguish(EntityExtinguishEvent::CAUSE_RESPAWN);
$this->setAirSupplyTicks($this->getMaxAirSupplyTicks());
$this->deadTicks = 0;
$this->noDamageTicks = 60;