From d70a7d34a7f70b9d7325d168fa43ba30382ba640 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 29 Apr 2024 15:51:25 +0100 Subject: [PATCH] Living: don't knockback or do hurt FX when attacked during cooldown players were switching from a weaker tool to a stronger one to get double knockback in PvP. while it's intended that we don't cancel the second attack during hit cooldown if the damage is higher (the first damage is subtracted to prevent doubling up), we don't want them to get double knockback. this behaviour now matches vanilla to the best of my observations. Come at me PvP community... I know some people are going to hate this change --- src/entity/Living.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/entity/Living.php b/src/entity/Living.php index e7d669fda..b0d14957c 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -555,26 +555,33 @@ abstract class Living extends Entity{ return; } - $this->attackTime = $source->getAttackCooldown(); + if($this->attackTime <= 0){ + //this logic only applies if the entity was cold attacked - if($source instanceof EntityDamageByChildEntityEvent){ - $e = $source->getChild(); - if($e !== null){ - $motion = $e->getMotion(); - $this->knockBack($motion->x, $motion->z, $source->getKnockBack(), $source->getVerticalKnockBackLimit()); + $this->attackTime = $source->getAttackCooldown(); + + if($source instanceof EntityDamageByChildEntityEvent){ + $e = $source->getChild(); + if($e !== null){ + $motion = $e->getMotion(); + $this->knockBack($motion->x, $motion->z, $source->getKnockBack(), $source->getVerticalKnockBackLimit()); + } + }elseif($source instanceof EntityDamageByEntityEvent){ + $e = $source->getDamager(); + if($e !== null){ + $deltaX = $this->location->x - $e->location->x; + $deltaZ = $this->location->z - $e->location->z; + $this->knockBack($deltaX, $deltaZ, $source->getKnockBack(), $source->getVerticalKnockBackLimit()); + } } - }elseif($source instanceof EntityDamageByEntityEvent){ - $e = $source->getDamager(); - if($e !== null){ - $deltaX = $this->location->x - $e->location->x; - $deltaZ = $this->location->z - $e->location->z; - $this->knockBack($deltaX, $deltaZ, $source->getKnockBack(), $source->getVerticalKnockBackLimit()); + + if($this->isAlive()){ + $this->doHitAnimation(); } } if($this->isAlive()){ $this->applyPostDamageEffects($source); - $this->doHitAnimation(); } }