Living: stop mutating Vector3

This commit is contained in:
Dylan K. Taylor 2020-06-27 21:51:42 +01:00
parent f1048aeaa3
commit 1f0ea0c2c7

View File

@ -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));
} }
} }