forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocation.js
More file actions
58 lines (58 loc) · 1.5 KB
/
Location.js
File metadata and controls
58 lines (58 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Vector } from "./Vector";
/**
* @beta
* Contains a location description that is useful for entities
* and other items. X, Y, and Z can contain decimal fractions.
* For integer-based locations useful for blocks, see {@link
* BlockLocation}.
*/
export class Location {
/**
* @remarks
* Creates a new instance of an abstract location.
* @param x
* X position of the location.
* @param y
* Y position of the location.
* @param z
* Z position of the location.
*/
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
;
/**
* @remarks
* Compares this Location and another Location to one another.
* @param other
* Other location to compare this Location to.
* @returns
* True if the two locations are equal.
*/
equals(other) {
if (this.x === other.x && this.y === other.y && this.z === other.z)
return true;
else
return false;
}
;
/**
* @remarks
* Determines whether or not two Locations are considered to be
* near each other.
* @param other
* Other Location to compare this Location to.
* @param epsilon
* Maximum distance that the Locations can be from each other
* to be considered nearby.
* @returns
* True if the two Locations are within epsilon distance of
* each other.
*/
isNear(other, epsilon) {
return Vector.distance(this, other) <= epsilon;
}
;
}