Record Class Location
java.lang.Object
java.lang.Record
fr.fidorial.world.Location
- Record Components:
x- the X coordinatey- the Y coordinate, at the feet for an entityz- the Z coordinateyaw- the horizontal rotation in degrees,0facing south and growing clockwisepitch- the vertical rotation in degrees,-90looking straight up and90straight down
A precise position and orientation, independent of any world.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionLocation(double x, double y, double z, float yaw, float pitch) Creates an instance of aLocationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionblockPos()Returns the position of the block holding this location.chunk()Returns the position of the chunk holding this location.doubleComputes the distance to another location, ignoring orientation.doubledistanceSquared(Location other) Computes the squared distance to another location, ignoring orientation.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Locationof(double x, double y, double z) Returns a location at the given coordinates, facing south.floatpitch()Returns the value of thepitchrecord component.final StringtoString()Returns a string representation of this record class.withPosition(double x, double y, double z) Returns this location moved to other coordinates, keeping its orientation.withRotation(float yaw, float pitch) Returns this location with another orientation, keeping its coordinates.doublex()Returns the value of thexrecord component.doubley()Returns the value of theyrecord component.floatyaw()Returns the value of theyawrecord component.doublez()Returns the value of thezrecord component.
-
Constructor Details
-
Location
public Location(double x, double y, double z, float yaw, float pitch) Creates an instance of aLocationrecord class.
-
-
Method Details
-
of
Returns a location at the given coordinates, facing south.- Parameters:
x- the X coordinatey- the Y coordinatez- the Z coordinate- Returns:
- a location at the given coordinates, facing south
- Since:
- 0.1.0
-
chunk
Returns the position of the chunk holding this location.- Returns:
- the position of the chunk holding this location
- Since:
- 0.1.0
-
blockPos
Returns the position of the block holding this location.- Returns:
- the position of the block holding this location
- Since:
- 0.1.0
-
withPosition
Returns this location moved to other coordinates, keeping its orientation.- Parameters:
x- the new X coordinatey- the new Y coordinatez- the new Z coordinate- Returns:
- this location moved to other coordinates, keeping its orientation
- Since:
- 0.1.0
-
withRotation
Returns this location with another orientation, keeping its coordinates.- Parameters:
yaw- the new horizontal rotation in degreespitch- the new vertical rotation in degrees- Returns:
- this location with another orientation, keeping its coordinates
- Since:
- 0.1.0
-
distanceSquared
Computes the squared distance to another location, ignoring orientation.Cheaper than
distance(Location); prefer it to compare distances.- Parameters:
other- the other location- Returns:
- the squared distance in blocks
- Since:
- 0.1.0
-
distance
Computes the distance to another location, ignoring orientation.- Parameters:
other- the other location- Returns:
- the distance in blocks
- Since:
- 0.1.0
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
x
-
y
-
z
-
yaw
-
pitch
-