Fixed noDamageTicks not preventing damage when last damage cause is null

noDamageTicks should make the entity completely invulnerable while active.
This commit is contained in:
Dylan K. Taylor 2019-07-07 17:37:52 +01:00
parent 11fc16617a
commit c7a5b8b0b4

View File

@ -541,7 +541,9 @@ abstract class Living extends Entity implements Damageable{
}
public function attack(EntityDamageEvent $source) : void{
if($this->attackTime > 0 or $this->noDamageTicks > 0){
if($this->noDamageTicks > 0){
$source->setCancelled();
}elseif($this->attackTime > 0){
$lastCause = $this->getLastDamageCause();
if($lastCause !== null and $lastCause->getBaseDamage() >= $source->getBaseDamage()){
$source->setCancelled();