mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Living: added knockback resistance attribute checks
This commit is contained in:
parent
509e8c5f6d
commit
595f1f58da
@ -564,23 +564,24 @@ abstract class Living extends Entity implements Damageable{
|
||||
if($f <= 0){
|
||||
return;
|
||||
}
|
||||
if(mt_rand() / mt_getrandmax() > $this->getAttributeMap()->getAttribute(Attribute::KNOCKBACK_RESISTANCE)->getValue()){
|
||||
$f = 1 / $f;
|
||||
|
||||
$f = 1 / $f;
|
||||
$motion = new Vector3($this->motionX, $this->motionY, $this->motionZ);
|
||||
|
||||
$motion = new Vector3($this->motionX, $this->motionY, $this->motionZ);
|
||||
$motion->x /= 2;
|
||||
$motion->y /= 2;
|
||||
$motion->z /= 2;
|
||||
$motion->x += $x * $f * $base;
|
||||
$motion->y += $base;
|
||||
$motion->z += $z * $f * $base;
|
||||
|
||||
$motion->x /= 2;
|
||||
$motion->y /= 2;
|
||||
$motion->z /= 2;
|
||||
$motion->x += $x * $f * $base;
|
||||
$motion->y += $base;
|
||||
$motion->z += $z * $f * $base;
|
||||
if($motion->y > $base){
|
||||
$motion->y = $base;
|
||||
}
|
||||
|
||||
if($motion->y > $base){
|
||||
$motion->y = $base;
|
||||
$this->setMotion($motion);
|
||||
}
|
||||
|
||||
$this->setMotion($motion);
|
||||
}
|
||||
|
||||
public function kill() : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user