mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/14544397106
This commit is contained in:
commit
baee0110c7
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
|
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||||
use pocketmine\world\sound\BucketEmptyWaterSound;
|
use pocketmine\world\sound\BucketEmptyWaterSound;
|
||||||
use pocketmine\world\sound\BucketFillWaterSound;
|
use pocketmine\world\sound\BucketFillWaterSound;
|
||||||
use pocketmine\world\sound\Sound;
|
use pocketmine\world\sound\Sound;
|
||||||
@ -53,7 +54,7 @@ class Water extends Liquid{
|
|||||||
public function onEntityInside(Entity $entity) : bool{
|
public function onEntityInside(Entity $entity) : bool{
|
||||||
$entity->resetFallDistance();
|
$entity->resetFallDistance();
|
||||||
if($entity->isOnFire()){
|
if($entity->isOnFire()){
|
||||||
$entity->extinguish();
|
$entity->extinguish(EntityExtinguishEvent::CAUSE_WATER);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ use pocketmine\block\tile\Cauldron as TileCauldron;
|
|||||||
use pocketmine\block\utils\DyeColor;
|
use pocketmine\block\utils\DyeColor;
|
||||||
use pocketmine\color\Color;
|
use pocketmine\color\Color;
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
|
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||||
use pocketmine\item\Armor;
|
use pocketmine\item\Armor;
|
||||||
use pocketmine\item\Banner;
|
use pocketmine\item\Banner;
|
||||||
use pocketmine\item\Dye;
|
use pocketmine\item\Dye;
|
||||||
@ -183,7 +184,7 @@ final class WaterCauldron extends FillableCauldron{
|
|||||||
|
|
||||||
public function onEntityInside(Entity $entity) : bool{
|
public function onEntityInside(Entity $entity) : bool{
|
||||||
if($entity->isOnFire()){
|
if($entity->isOnFire()){
|
||||||
$entity->extinguish();
|
$entity->extinguish(EntityExtinguishEvent::CAUSE_WATER_CAULDRON);
|
||||||
//TODO: particles
|
//TODO: particles
|
||||||
|
|
||||||
$this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::ENTITY_EXTINGUISH_USE_AMOUNT));
|
$this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::ENTITY_EXTINGUISH_USE_AMOUNT));
|
||||||
|
@ -31,6 +31,7 @@ use pocketmine\block\Water;
|
|||||||
use pocketmine\entity\animation\Animation;
|
use pocketmine\entity\animation\Animation;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\event\entity\EntityDespawnEvent;
|
use pocketmine\event\entity\EntityDespawnEvent;
|
||||||
|
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||||
use pocketmine\event\entity\EntityMotionEvent;
|
use pocketmine\event\entity\EntityMotionEvent;
|
||||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||||
use pocketmine\event\entity\EntitySpawnEvent;
|
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->fireTicks = 0;
|
||||||
$this->networkPropertiesDirty = true;
|
$this->networkPropertiesDirty = true;
|
||||||
}
|
}
|
||||||
@ -720,7 +724,7 @@ abstract class Entity{
|
|||||||
|
|
||||||
protected function doOnFireTick(int $tickDiff = 1) : bool{
|
protected function doOnFireTick(int $tickDiff = 1) : bool{
|
||||||
if($this->isFireProof() && $this->isOnFire()){
|
if($this->isFireProof() && $this->isOnFire()){
|
||||||
$this->extinguish();
|
$this->extinguish(EntityExtinguishEvent::CAUSE_FIRE_PROOF);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,7 +735,7 @@ abstract class Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->isOnFire()){
|
if(!$this->isOnFire()){
|
||||||
$this->extinguish();
|
$this->extinguish(EntityExtinguishEvent::CAUSE_TICKING);
|
||||||
}else{
|
}else{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
53
src/event/entity/EntityExtinguishEvent.php
Normal file
53
src/event/entity/EntityExtinguishEvent.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@ use pocketmine\entity\projectile\Arrow;
|
|||||||
use pocketmine\entity\Skin;
|
use pocketmine\entity\Skin;
|
||||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
|
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||||
use pocketmine\event\inventory\InventoryCloseEvent;
|
use pocketmine\event\inventory\InventoryCloseEvent;
|
||||||
use pocketmine\event\inventory\InventoryOpenEvent;
|
use pocketmine\event\inventory\InventoryOpenEvent;
|
||||||
use pocketmine\event\player\PlayerBedEnterEvent;
|
use pocketmine\event\player\PlayerBedEnterEvent;
|
||||||
@ -2551,7 +2552,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
$this->setSneaking(false);
|
$this->setSneaking(false);
|
||||||
$this->setFlying(false);
|
$this->setFlying(false);
|
||||||
|
|
||||||
$this->extinguish();
|
$this->extinguish(EntityExtinguishEvent::CAUSE_RESPAWN);
|
||||||
$this->setAirSupplyTicks($this->getMaxAirSupplyTicks());
|
$this->setAirSupplyTicks($this->getMaxAirSupplyTicks());
|
||||||
$this->deadTicks = 0;
|
$this->deadTicks = 0;
|
||||||
$this->noDamageTicks = 60;
|
$this->noDamageTicks = 60;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user