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
This commit is contained in:
Dylan K. Taylor 2024-04-29 15:51:25 +01:00
parent be6754494f
commit d70a7d34a7
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -555,26 +555,33 @@ abstract class Living extends Entity{
return; return;
} }
$this->attackTime = $source->getAttackCooldown(); if($this->attackTime <= 0){
//this logic only applies if the entity was cold attacked
if($source instanceof EntityDamageByChildEntityEvent){ $this->attackTime = $source->getAttackCooldown();
$e = $source->getChild();
if($e !== null){ if($source instanceof EntityDamageByChildEntityEvent){
$motion = $e->getMotion(); $e = $source->getChild();
$this->knockBack($motion->x, $motion->z, $source->getKnockBack(), $source->getVerticalKnockBackLimit()); 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($this->isAlive()){
if($e !== null){ $this->doHitAnimation();
$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()){ if($this->isAlive()){
$this->applyPostDamageEffects($source); $this->applyPostDamageEffects($source);
$this->doHitAnimation();
} }
} }