diff --git a/src/entity/Living.php b/src/entity/Living.php index 593c8f05a..b812884df 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -391,7 +391,7 @@ abstract class Living extends Entity{ $this->setAbsorption(max(0, $this->getAbsorption() + $source->getModifier(EntityDamageEvent::MODIFIER_ABSORPTION))); $this->damageArmor($source->getBaseDamage()); - if($source instanceof EntityDamageByEntityEvent){ + if($source instanceof EntityDamageByEntityEvent and ($attacker = $source->getDamager()) !== null){ $damage = 0; foreach($this->armorInventory->getContents() as $k => $item){ if($item instanceof Armor and ($thornsLevel = $item->getEnchantmentLevel(Enchantment::THORNS())) > 0){ @@ -407,7 +407,7 @@ abstract class Living extends Entity{ } if($damage > 0){ - $source->getDamager()->attack(new EntityDamageByEntityEvent($this, $source->getDamager(), EntityDamageEvent::CAUSE_MAGIC, $damage)); + $attacker->attack(new EntityDamageByEntityEvent($this, $attacker, EntityDamageEvent::CAUSE_MAGIC, $damage)); } } } diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index f25a71493..a89b8e955 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -135,16 +135,6 @@ parameters: count: 3 path: ../../../src/entity/Living.php - - - message: "#^Cannot call method attack\\(\\) on pocketmine\\\\entity\\\\Entity\\|null\\.$#" - count: 1 - path: ../../../src/entity/Living.php - - - - message: "#^Parameter \\#2 \\$entity of class pocketmine\\\\event\\\\entity\\\\EntityDamageByEntityEvent constructor expects pocketmine\\\\entity\\\\Entity, pocketmine\\\\entity\\\\Entity\\|null given\\.$#" - count: 1 - path: ../../../src/entity/Living.php - - message: "#^Cannot call method getEffectLevel\\(\\) on pocketmine\\\\entity\\\\effect\\\\EffectInstance\\|null\\.$#" count: 2