mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 10:31:51 +00:00
Entity: use match in checkObstruction()
This commit is contained in:
parent
b3298d7c77
commit
83805a3406
@ -868,45 +868,23 @@ abstract class Entity{
|
|||||||
$direction = Facing::SOUTH;
|
$direction = Facing::SOUTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($direction === -1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$force = lcg_value() * 0.2 + 0.1;
|
$force = lcg_value() * 0.2 + 0.1;
|
||||||
|
|
||||||
if($direction === Facing::WEST){
|
$this->motion = match($direction){
|
||||||
$this->motion = $this->motion->withComponents(-$force, null, null);
|
Facing::WEST => $this->motion->withComponents(-$force, null, null),
|
||||||
|
Facing::EAST => $this->motion->withComponents($force, null, null),
|
||||||
|
Facing::DOWN => $this->motion->withComponents(null, -$force, null),
|
||||||
|
Facing::UP => $this->motion->withComponents(null, $force, null),
|
||||||
|
Facing::NORTH => $this->motion->withComponents(null, null, -$force),
|
||||||
|
Facing::SOUTH => $this->motion->withComponents(null, null, $force),
|
||||||
|
};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($direction === Facing::EAST){
|
|
||||||
$this->motion = $this->motion->withComponents($force, null, null);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($direction === Facing::DOWN){
|
|
||||||
$this->motion = $this->motion->withComponents(null, -$force, null);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($direction === Facing::UP){
|
|
||||||
$this->motion = $this->motion->withComponents(null, $force, null);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($direction === Facing::NORTH){
|
|
||||||
$this->motion = $this->motion->withComponents(null, null, -$force);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($direction === Facing::SOUTH){
|
|
||||||
$this->motion = $this->motion->withComponents(null, null, $force);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user