GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Position Class Reference

Public Member Functions

 __construct ($x=0, $y=0, $z=0, Level $level=null)
 
 asPosition ()
 
 add ($x, $y=0, $z=0)
 
 getLevel ()
 
 setLevel (Level $level=null)
 
 isValid ()
 
 getSide ($side, $step=1)
 
 __toString ()
 
 setComponents ($x, $y, $z)
 
 fromObjectAdd (Vector3 $pos, $x, $y, $z)
 
- Public Member Functions inherited from Vector3
 __construct ($x=0, $y=0, $z=0)
 
 getX ()
 
 getY ()
 
 getZ ()
 
 getFloorX ()
 
 getFloorY ()
 
 getFloorZ ()
 
 getRight ()
 
 getUp ()
 
 getForward ()
 
 getSouth ()
 
 getWest ()
 
 add ($x, $y=0, $z=0)
 
 subtract ($x=0, $y=0, $z=0)
 
 multiply ($number)
 
 divide ($number)
 
 ceil ()
 
 floor ()
 
 round ()
 
 abs ()
 
 getSide ($side, $step=1)
 
 asVector3 ()
 
 distance (Vector3 $pos)
 
 distanceSquared (Vector3 $pos)
 
 maxPlainDistance ($x=0, $z=0)
 
 length ()
 
 lengthSquared ()
 
 normalize ()
 
 dot (Vector3 $v)
 
 cross (Vector3 $v)
 
 equals (Vector3 $v)
 
 getIntermediateWithXValue (Vector3 $v, $x)
 
 getIntermediateWithYValue (Vector3 $v, $y)
 
 getIntermediateWithZValue (Vector3 $v, $z)
 
 setComponents ($x, $y, $z)
 
 fromObjectAdd (Vector3 $pos, $x, $y, $z)
 
 __toString ()
 

Static Public Member Functions

static fromObject (Vector3 $pos, Level $level=null)
 
- Static Public Member Functions inherited from Vector3
static getOppositeSide ($side)
 
static createRandomDirection (Random $random)
 

Data Fields

 $level = null
 
- Data Fields inherited from Vector3
const SIDE_DOWN = 0
 
const SIDE_UP = 1
 
const SIDE_NORTH = 2
 
const SIDE_SOUTH = 3
 
const SIDE_WEST = 4
 
const SIDE_EAST = 5
 
 $x
 
 $y
 
 $z
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $x = 0,
  $y = 0,
  $z = 0,
Level  $level = null 
)
Parameters
int$x
int$y
int$z
Level$level
39  {
40  $this->x = $x;
41  $this->y = $y;
42  $this->z = $z;
43  $this->level = $level;
44  }

Member Function Documentation

◆ __toString()

__toString ( )
Returns
string
140  {
141  return "Position(level=" . ($this->isValid() ? $this->getLevel()->getName() : "null") . ",x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")";
142  }

◆ add()

add (   $x,
  $y = 0,
  $z = 0 
)
Parameters
int | Vector3$x
int$y
int$z
Returns
Position
72  {
73  if($x instanceof Vector3){
74  return new Position($this->x + $x->x, $this->y + $x->y, $this->z + $x->z, $this->level);
75  }else{
76  return new Position($this->x + $x, $this->y + $y, $this->z + $z, $this->level);
77  }
78  }

◆ asPosition()

asPosition ( )

Return a Position instance

Returns
Position
61  : Position{
62  return new Position($this->x, $this->y, $this->z, $this->level);
63  }

◆ fromObject()

static fromObject ( Vector3  $pos,
Level  $level = null 
)
static
Parameters
Vector3$pos
Level | null$level
Returns
Position
52  {
53  return new Position($pos->x, $pos->y, $pos->z, $level);
54  }

◆ fromObjectAdd()

fromObjectAdd ( Vector3  $pos,
  $x,
  $y,
  $z 
)
Parameters
Vector3$pos
$x
$y
$z
Returns
$this
166  {
167  if($pos instanceof Position){
168  $this->level = $pos->level;
169  }
170  parent::fromObjectAdd($pos, $x, $y, $z);
171  return $this;
172  }

◆ getLevel()

getLevel ( )
Returns
Level
83  {
84  if($this->level !== null and $this->level->isClosed()){
85  MainLogger::getLogger()->debug("Position was holding a reference to an unloaded Level");
86  $this->level = null;
87  }
88 
89  return $this->level;
90  }

◆ getSide()

getSide (   $side,
  $step = 1 
)

Returns a side Vector

Parameters
int$side
int$step
Returns
Position
Exceptions
LevelException
129  {
130  if(!$this->isValid()){
131  throw new LevelException("Undefined Level reference");
132  }
133 
134  return Position::fromObject(parent::getSide($side, $step), $this->level);
135  }

◆ isValid()

isValid ( )

Checks if this object has a valid reference to a loaded Level

Returns
bool
115  {
116  return $this->getLevel() instanceof Level;
117  }

◆ setComponents()

setComponents (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
Position
151  {
152  $this->x = $x;
153  $this->y = $y;
154  $this->z = $z;
155  return $this;
156  }

◆ setLevel()

setLevel ( Level  $level = null)

Sets the target Level of the position.

Parameters
Level | null$level
Returns
$this
Exceptions
101  {
102  if($level !== null and $level->isClosed()){
103  throw new \InvalidArgumentException("Specified level has been unloaded and cannot be used");
104  }
105 
106  $this->level = $level;
107  return $this;
108  }

Field Documentation

◆ $level

$level = null

The documentation for this class was generated from the following file: