mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
Living: stop mutating Vector3
This commit is contained in:
parent
f1048aeaa3
commit
1f0ea0c2c7
@ -503,20 +503,18 @@ abstract class Living extends Entity{
|
|||||||
if(mt_rand() / mt_getrandmax() > $this->knockbackResistanceAttr->getValue()){
|
if(mt_rand() / mt_getrandmax() > $this->knockbackResistanceAttr->getValue()){
|
||||||
$f = 1 / $f;
|
$f = 1 / $f;
|
||||||
|
|
||||||
$motion = clone $this->motion;
|
$motionX = $this->motion->x / 2;
|
||||||
|
$motionY = $this->motion->y / 2;
|
||||||
|
$motionZ = $this->motion->z / 2;
|
||||||
|
$motionX += $x * $f * $base;
|
||||||
|
$motionY += $base;
|
||||||
|
$motionZ += $z * $f * $base;
|
||||||
|
|
||||||
$motion->x /= 2;
|
if($motionY > $base){
|
||||||
$motion->y /= 2;
|
$motionY = $base;
|
||||||
$motion->z /= 2;
|
|
||||||
$motion->x += $x * $f * $base;
|
|
||||||
$motion->y += $base;
|
|
||||||
$motion->z += $z * $f * $base;
|
|
||||||
|
|
||||||
if($motion->y > $base){
|
|
||||||
$motion->y = $base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setMotion($motion);
|
$this->setMotion(new Vector3($motionX, $motionY, $motionZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user