mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 13:35:29 +00:00
Entity: avoid direct mutation of Vector3 in checkObstruction(), use withComponents() instead
this ugly code can be simplified quite a lot further, but that's a job for later.
This commit is contained in:
parent
25566c2f1a
commit
1d8e7abdd4
@ -853,37 +853,37 @@ abstract class Entity{
|
||||
$force = lcg_value() * 0.2 + 0.1;
|
||||
|
||||
if($direction === Facing::WEST){
|
||||
$this->motion->x = -$force;
|
||||
$this->motion = $this->motion->withComponents(-$force, null, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === Facing::EAST){
|
||||
$this->motion->x = $force;
|
||||
$this->motion = $this->motion->withComponents($force, null, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === Facing::DOWN){
|
||||
$this->motion->y = -$force;
|
||||
$this->motion = $this->motion->withComponents(null, -$force, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === Facing::UP){
|
||||
$this->motion->y = $force;
|
||||
$this->motion = $this->motion->withComponents(null, $force, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === Facing::NORTH){
|
||||
$this->motion->z = -$force;
|
||||
$this->motion = $this->motion->withComponents(null, null, -$force);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === Facing::SOUTH){
|
||||
$this->motion->z = $force;
|
||||
$this->motion = $this->motion->withComponents(null, null, $force);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user