Merge branch 'next-minor'

# Conflicts:
#	changelogs/3.12.md
#	resources/vanilla
#	src/VersionInfo.php
This commit is contained in:
Dylan K. Taylor
2020-06-03 13:11:30 +01:00
5 changed files with 148 additions and 64 deletions

View File

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