mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Living: check if damager is null before trying to use it
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user