mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Merge branch 'next-minor'
# Conflicts: # changelogs/3.12.md # resources/vanilla # src/VersionInfo.php
This commit is contained in:
@ -27,6 +27,7 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use function array_sum;
|
||||
use function max;
|
||||
|
||||
/**
|
||||
* Called when an entity takes damage.
|
||||
@ -147,7 +148,7 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
|
||||
}
|
||||
|
||||
public function getFinalDamage() : float{
|
||||
return $this->baseDamage + array_sum($this->modifiers);
|
||||
return max(0, $this->baseDamage + array_sum($this->modifiers));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,8 +186,4 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
|
||||
public function setAttackCooldown(int $attackCooldown) : void{
|
||||
$this->attackCooldown = $attackCooldown;
|
||||
}
|
||||
|
||||
public function isCancelled() : bool{
|
||||
return parent::isCancelled() or $this->getFinalDamage() <= 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user