Remove some more Vector3 mutations

This commit is contained in:
Dylan K. Taylor 2020-06-27 20:58:02 +01:00
parent c040248dbd
commit ff00595a48
4 changed files with 5 additions and 14 deletions

View File

@ -1270,11 +1270,8 @@ abstract class Entity{
}
if($vector->lengthSquared() > 0){
$vector = $vector->normalize();
$d = 0.014;
$this->motion->x += $vector->x * $d;
$this->motion->y += $vector->y * $d;
$this->motion->z += $vector->z * $d;
$this->motion = $this->motion->addVector($vector->normalize()->multiply($d));
}
}
@ -1392,9 +1389,7 @@ abstract class Entity{
* Adds the given values to the entity's motion vector.
*/
public function addMotion(float $x, float $y, float $z) : void{
$this->motion->x += $x;
$this->motion->y += $y;
$this->motion->z += $z;
$this->motion = $this->motion->add($x, $y, $z);
}
public function isOnGround() : bool{

View File

@ -195,11 +195,7 @@ class ExperienceOrb extends Entity{
$distance = $vector->lengthSquared();
if($distance < 1){
$diff = $vector->normalize()->multiply(0.2 * (1 - sqrt($distance)) ** 2);
$this->motion->x += $diff->x;
$this->motion->y += $diff->y;
$this->motion->z += $diff->z;
$this->motion = $this->motion->addVector($vector->normalize()->multiply(0.2 * (1 - sqrt($distance)) ** 2));
}
if($currentTarget->getXpManager()->canPickupXp() and $this->boundingBox->intersectsWith($currentTarget->getBoundingBox())){

View File

@ -247,7 +247,7 @@ abstract class Projectile extends Entity{
}
$this->isCollided = $this->onGround = true;
$this->motion->x = $this->motion->y = $this->motion->z = 0;
$this->motion = new Vector3(0, 0, 0);
}else{
$this->isCollided = $this->onGround = false;
$this->blockHit = null;

View File

@ -1340,7 +1340,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
if($this->spawned){
$this->processMostRecentMovements();
$this->motion->x = $this->motion->y = $this->motion->z = 0; //TODO: HACK! (Fixes player knockback being messed up)
$this->motion = new Vector3(0, 0, 0); //TODO: HACK! (Fixes player knockback being messed up)
if($this->onGround){
$this->inAirTicks = 0;
}else{