mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 21:05:12 +00:00
getSide() Vector3 method
This commit is contained in:
parent
cac2a3a6e5
commit
f79c6cf2e9
@ -117,6 +117,25 @@ class Vector3{
|
||||
return new Vector3(abs($this->x), abs($this->y), abs($this->z));
|
||||
}
|
||||
|
||||
public function getSide($side){
|
||||
switch((int) $side){
|
||||
case 0:
|
||||
return new Vector3($this->x, $this->y - 1, $this->z);
|
||||
case 1:
|
||||
return new Vector3($this->x, $this->y + 1, $this->z);
|
||||
case 2:
|
||||
return new Vector3($this->x, $this->y, $this->z - 1);
|
||||
case 3:
|
||||
return new Vector3($this->x, $this->y, $this->z + 1);
|
||||
case 4:
|
||||
return new Vector3($this->x - 1, $this->y, $this->z);
|
||||
case 5:
|
||||
return new Vector3($this->x + 1, $this->y, $this->z);
|
||||
default:
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function distance($x = 0, $y = 0, $z = 0){
|
||||
if(($x instanceof Vector3) === true){
|
||||
return sqrt($this->distanceSquared($x->x, $x->y, $x->z));
|
||||
|
Loading…
x
Reference in New Issue
Block a user