From 8c5a81cf5c821e58b0a9bec662bc13555aa3b4af Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 31 May 2020 20:04:12 +0100 Subject: [PATCH] Living: improved projectile knockback this isn't pretty, but it works. I have a nicer idea how to do this on PM4, but it's going to involve BC breaks (as usual). closes #3382 --- src/pocketmine/entity/Living.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index c6c9b7be6..fdafc66e7 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -548,12 +548,14 @@ abstract class Living extends Entity implements Damageable{ $this->attackTime = $source->getAttackCooldown(); - if($source instanceof EntityDamageByEntityEvent){ - $e = $source->getDamager(); - if($source instanceof EntityDamageByChildEntityEvent){ - $e = $source->getChild(); + if($source instanceof EntityDamageByChildEntityEvent){ + $e = $source->getChild(); + if($e !== null){ + $motion = $e->getMotion(); + $this->knockBack($e, $source->getBaseDamage(), $motion->x, $motion->z, $source->getKnockBack()); } - + }elseif($source instanceof EntityDamageByEntityEvent){ + $e = $source->getDamager(); if($e !== null){ $deltaX = $this->x - $e->x; $deltaZ = $this->z - $e->z;