mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
Entity: avoid direct Vector3 mutations in tryChangeMovement()
This commit is contained in:
parent
9dda99f844
commit
25566c2f1a
@ -775,24 +775,25 @@ abstract class Entity{
|
||||
protected function tryChangeMovement() : void{
|
||||
$friction = 1 - $this->drag;
|
||||
|
||||
$mY = $this->motion->y;
|
||||
|
||||
if($this->applyDragBeforeGravity()){
|
||||
$this->motion->y *= $friction;
|
||||
$mY *= $friction;
|
||||
}
|
||||
|
||||
if($this->gravityEnabled){
|
||||
$this->motion->y -= $this->gravity;
|
||||
$mY -= $this->gravity;
|
||||
}
|
||||
|
||||
if(!$this->applyDragBeforeGravity()){
|
||||
$this->motion->y *= $friction;
|
||||
$mY *= $friction;
|
||||
}
|
||||
|
||||
if($this->onGround){
|
||||
$friction *= $this->getWorld()->getBlockAt((int) floor($this->location->x), (int) floor($this->location->y - 1), (int) floor($this->location->z))->getFrictionFactor();
|
||||
}
|
||||
|
||||
$this->motion->x *= $friction;
|
||||
$this->motion->z *= $friction;
|
||||
$this->motion = new Vector3($this->motion->x * $friction, $mY, $this->motion->z * $friction);
|
||||
}
|
||||
|
||||
protected function checkObstruction(float $x, float $y, float $z) : bool{
|
||||
|
Loading…
x
Reference in New Issue
Block a user