PocketMine-MP
5.23.3 git-fbaa125d0ce21ffef98fc1630881a92bedfbaa73
Loading...
Searching...
No Matches
Location.php
1
<?php
2
3
/*
4
*
5
* ____ _ _ __ __ _ __ __ ____
6
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* @author PocketMine Team
17
* @link http://www.pocketmine.net/
18
*
19
*
20
*/
21
22
declare(strict_types=1);
23
24
namespace
pocketmine\entity
;
25
26
use
pocketmine\math\Vector3
;
27
use
pocketmine\world\Position
;
28
use
pocketmine\world\World
;
29
30
class
Location
extends
Position
{
31
32
public
float
$yaw;
33
public
float
$pitch;
34
35
public
function
__construct(
float
$x,
float
$y,
float
$z, ?
World
$world,
float
$yaw,
float
$pitch){
36
$this->yaw = $yaw;
37
$this->pitch = $pitch;
38
parent::__construct($x, $y, $z, $world);
39
}
40
44
public
static
function
fromObject
(
Vector3
$pos, ?
World
$world,
float
$yaw = 0.0,
float
$pitch = 0.0){
45
return
new
Location
($pos->x, $pos->y, $pos->z, $world ?? (($pos instanceof
Position
) ? $pos->world :
null
), $yaw, $pitch);
46
}
47
51
public
function
asLocation
() :
Location
{
52
return new
Location
($this->x, $this->y, $this->z, $this->world, $this->yaw, $this->pitch);
53
}
54
55
public
function
getYaw() : float{
56
return $this->yaw;
57
}
58
59
public
function
getPitch() : float{
60
return $this->pitch;
61
}
62
63
public
function
__toString(){
64
return
"Location (world="
. ($this->isValid() ? $this->getWorld()->getDisplayName() :
"null"
) .
", x=$this->x, y=$this->y, z=$this->z, yaw=$this->yaw, pitch=$this->pitch)"
;
65
}
66
67
public
function
equals
(Vector3 $v) : bool{
68
if($v instanceof Location){
69
return
parent::equals($v) && $v->yaw == $this->yaw && $v->pitch == $this->pitch;
70
}
71
return
parent::equals($v);
72
}
73
}
pocketmine\entity\Location
Definition
Location.php:30
pocketmine\entity\Location\asLocation
asLocation()
Definition
Location.php:51
pocketmine\entity\Location\fromObject
static fromObject(Vector3 $pos, ?World $world, float $yaw=0.0, float $pitch=0.0)
Definition
Location.php:44
pocketmine\math\Vector3
Definition
Vector3.php:36
pocketmine\world\Position
Definition
Position.php:30
pocketmine\world\World
Definition
World.php:147
pocketmine\entity
Definition
Ageable.php:24
pocketmine\utils\equals
equals(self $other)
Definition
EnumTrait.php:106
src
entity
Location.php
Generated by
1.12.0