Cloneable, ConfigurationSerializablepublic class Location extends Object implements Cloneable, ConfigurationSerializable
| Constructor | Description | 
|---|---|
| Location(World world,
        double x,
        double y,
        double z) | Constructs a new Location with the given coordinates | 
| Location(World world,
        double x,
        double y,
        double z,
        float yaw,
        float pitch) | Constructs a new Location with the given coordinates and direction | 
| Modifier and Type | Method | Description | 
|---|---|---|
| Location | add(double x,
   double y,
   double z) | Adds the location by another. | 
| Location | add(Location vec) | Adds the location by another. | 
| Location | add(Location base,
   double x,
   double y,
   double z) | Takes the x/y/z from base and adds the specified x/y/z to it and returns self
 This mutates this object, clone first. | 
| Location | add(Vector vec) | Adds the location by a vector. | 
| void | checkFinite() | Check if each component of this Location is finite. | 
| Location | clone() | |
| boolean | createExplosion(float power) | Creates explosion at this location with given power
 Will break blocks and ignite blocks on fire. | 
| boolean | createExplosion(float power,
               boolean setFire) | Creates explosion at this location with given power and optionally
 setting blocks on fire. | 
| boolean | createExplosion(float power,
               boolean setFire,
               boolean breakBlocks) | Creates explosion at this location with given power and optionally
 setting blocks on fire. | 
| boolean | createExplosion(Entity source,
               float power) | Creates explosion at this location with given power, with the specified entity as the source. | 
| boolean | createExplosion(Entity source,
               float power,
               boolean setFire) | Creates explosion at this location with given power and optionally
 setting blocks on fire, with the specified entity as the source. | 
| boolean | createExplosion(Entity source,
               float power,
               boolean setFire,
               boolean breakBlocks) | Creates explosion at this location with given power and optionally
 setting blocks on fire, with the specified entity as the source. | 
| static Location | deserialize(Map<String,Object> args) | Required method for deserialization | 
| double | distance(Location o) | Get the distance between this location and another. | 
| double | distanceSquared(Location o) | Get the squared distance between this location and another. | 
| boolean | equals(Object obj) | |
| Block | getBlock() | Gets the block at the represented location | 
| int | getBlockX() | Gets the floored value of the X component, indicating the block that
 this location is contained with. | 
| int | getBlockY() | Gets the floored value of the Y component, indicating the block that
 this location is contained with. | 
| int | getBlockZ() | Gets the floored value of the Z component, indicating the block that
 this location is contained with. | 
| Chunk | getChunk() | Gets the chunk at the represented location | 
| Vector | getDirection() | Gets a unit-vector pointing in the direction that this Location is
 facing. | 
| Collection<Entity> | getNearbyEntities(double x,
                 double y,
                 double z) | Returns a list of entities within a bounding box centered around a Location. | 
| <T extends Entity> | getNearbyEntitiesByType(Class<? extends Entity> clazz,
                       double xRadius,
                       double yRadius,
                       double zRadius,
                       Predicate<T> predicate) | Gets all nearby entities of the specified type, within the specified radius (bounding box) | 
| <T extends Entity> | getNearbyEntitiesByType(Class<? extends T> clazz,
                       double radius) | Gets all nearby entities of the specified type, within the specified radius (bounding box) | 
| <T extends Entity> | getNearbyEntitiesByType(Class<? extends T> clazz,
                       double xzRadius,
                       double yRadius) | Gets all nearby entities of the specified type, within the specified radius, with x and x radius matching (bounding box) | 
| <T extends Entity> | getNearbyEntitiesByType(Class<? extends T> clazz,
                       double xRadius,
                       double yRadius,
                       double zRadius) | Gets all nearby entities of the specified type, within the specified radius (bounding box) | 
| <T extends Entity> | getNearbyEntitiesByType(Class<? extends T> clazz,
                       double xzRadius,
                       double yRadius,
                       Predicate<T> predicate) | Gets all nearby entities of the specified type, within the specified radius, with x and x radius matching (bounding box) | 
| <T extends Entity> | getNearbyEntitiesByType(Class<? extends T> clazz,
                       double radius,
                       Predicate<T> predicate) | Gets all nearby entities of the specified type, within the specified radius (bounding box) | 
| Collection<LivingEntity> | getNearbyLivingEntities(double radius) | Gets nearby players within the specified radius (bounding box) | 
| Collection<LivingEntity> | getNearbyLivingEntities(double xzRadius,
                       double yRadius) | Gets nearby players within the specified radius (bounding box) | 
| Collection<LivingEntity> | getNearbyLivingEntities(double xRadius,
                       double yRadius,
                       double zRadius) | Gets nearby players within the specified radius (bounding box) | 
| Collection<LivingEntity> | getNearbyLivingEntities(double xRadius,
                       double yRadius,
                       double zRadius,
                       Predicate<LivingEntity> predicate) | Gets nearby players within the specified radius (bounding box) | 
| Collection<LivingEntity> | getNearbyLivingEntities(double xzRadius,
                       double yRadius,
                       Predicate<LivingEntity> predicate) | Gets nearby players within the specified radius (bounding box) | 
| Collection<LivingEntity> | getNearbyLivingEntities(double radius,
                       Predicate<LivingEntity> predicate) | Gets nearby players within the specified radius (bounding box) | 
| Collection<Player> | getNearbyPlayers(double radius) | Gets nearby players within the specified radius (bounding box) | 
| Collection<Player> | getNearbyPlayers(double xzRadius,
                double yRadius) | Gets nearby players within the specified radius (bounding box) | 
| Collection<Player> | getNearbyPlayers(double xRadius,
                double yRadius,
                double zRadius) | Gets nearby players within the specified radius (bounding box) | 
| Collection<Player> | getNearbyPlayers(double xRadius,
                double yRadius,
                double zRadius,
                Predicate<Player> predicate) | Gets nearby players within the specified radius (bounding box) | 
| Collection<Player> | getNearbyPlayers(double xzRadius,
                double yRadius,
                Predicate<Player> predicate) | Gets nearby players within the specified radius (bounding box) | 
| Collection<Player> | getNearbyPlayers(double radius,
                Predicate<Player> predicate) | Gets nearby players within the specified radius (bounding box) | 
| float | getPitch() | Gets the pitch of this location, measured in degrees. | 
| World | getWorld() | Gets the world that this location resides in | 
| double | getX() | Gets the x-coordinate of this location | 
| double | getY() | Gets the y-coordinate of this location | 
| float | getYaw() | Gets the yaw of this location, measured in degrees. | 
| double | getZ() | Gets the z-coordinate of this location | 
| int | hashCode() | |
| boolean | isChunkLoaded() | |
| boolean | isGenerated() | Checks if a  Chunkhas been generated at this location. | 
| boolean | isWorldLoaded() | Checks if world in this location is present and loaded. | 
| double | length() | Gets the magnitude of the location, defined as sqrt(x^2+y^2+z^2). | 
| double | lengthSquared() | Gets the magnitude of the location squared. | 
| static int | locToBlock(double loc) | Safely converts a double (location coordinate) to an int (block
 coordinate) | 
| Location | multiply(double m) | Performs scalar multiplication, multiplying all components with a
 scalar. | 
| static float | normalizePitch(float pitch) | Normalizes the given pitch angle to a value between  +/-90degrees. | 
| static float | normalizeYaw(float yaw) | Normalizes the given yaw angle to a value between  +/-180degrees. | 
| Map<String,Object> | serialize() | Creates a Map representation of this class. | 
| Location | set(double x,
   double y,
   double z) | Sets the position of this Location and returns itself
 This mutates this object, clone first. | 
| Location | setDirection(Vector vector) | |
| void | setPitch(float pitch) | Sets the pitch of this location, measured in degrees. | 
| void | setWorld(World world) | Sets the world that this location resides in | 
| void | setX(double x) | Sets the x-coordinate of this location | 
| void | setY(double y) | Sets the y-coordinate of this location | 
| void | setYaw(float yaw) | Sets the yaw of this location, measured in degrees. | 
| void | setZ(double z) | Sets the z-coordinate of this location | 
| Location | subtract(double x,
        double y,
        double z) | Subtracts the location by another. | 
| Location | subtract(Location vec) | Subtracts the location by another. | 
| Location | subtract(Location base,
        double x,
        double y,
        double z) | Takes the x/y/z from base and subtracts the specified x/y/z to it and returns self
 This mutates this object, clone first. | 
| Location | subtract(Vector vec) | Subtracts the location by a vector. | 
| long | toBlockKey() | |
| Location | toBlockLocation() | |
| Location | toCenterLocation() | |
| Location | toHighestLocation() | Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ()) | 
| Location | toHighestLocation(HeightmapType heightmap) | Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap) | 
| String | toString() | |
| Vector | toVector() | Constructs a new  Vectorbased on this Location | 
| Location | zero() | Zero this location's components. | 
public Location(World world, double x, double y, double z)
world - The world in which this location residesx - The x-coordinate of this new locationy - The y-coordinate of this new locationz - The z-coordinate of this new locationpublic Location(World world, double x, double y, double z, float yaw, float pitch)
world - The world in which this location residesx - The x-coordinate of this new locationy - The y-coordinate of this new locationz - The z-coordinate of this new locationyaw - The absolute rotation on the x-plane, in degreespitch - The absolute rotation on the y-plane, in degreespublic void setWorld(@Nullable World world)
world - New world that this location resides inpublic boolean isWorldLoaded()
public World getWorld()
null if it is not setIllegalArgumentException - when world is unloadedisWorldLoaded()@NotNull public Chunk getChunk()
@NotNull public Block getBlock()
public void setX(double x)
x - X-coordinatepublic double getX()
public int getBlockX()
public void setY(double y)
y - y-coordinatepublic double getY()
public int getBlockY()
public void setZ(double z)
z - z-coordinatepublic double getZ()
public int getBlockZ()
public void setYaw(float yaw)
yaw - new rotation's yawpublic float getYaw()
public void setPitch(float pitch)
pitch - new incline's pitchpublic float getPitch()
@NotNull public Vector getDirection()
@NotNull public Location setDirection(@NotNull Vector vector)
vector - the direction vector@NotNull public Location add(@NotNull Location vec)
vec - The other locationIllegalArgumentException - for differing worldsVector@NotNull public Location add(@NotNull Vector vec)
vec - Vector to useVector@NotNull public Location add(double x, double y, double z)
x - X coordinatey - Y coordinatez - Z coordinateVector@NotNull public Location subtract(@NotNull Location vec)
vec - The other locationIllegalArgumentException - for differing worldsVector@NotNull public Location subtract(@NotNull Vector vec)
vec - The vector to useVector@NotNull public Location subtract(double x, double y, double z)
x - X coordinatey - Y coordinatez - Z coordinateVectorpublic double length()
Vectorpublic double lengthSquared()
Vectorpublic double distance(@NotNull Location o)
o - The other locationIllegalArgumentException - for differing worldsVectorpublic double distanceSquared(@NotNull Location o)
o - The other locationIllegalArgumentException - for differing worldsVector@NotNull public Location multiply(double m)
m - The factorVector@NotNull public Location zero()
Vectorpublic boolean isChunkLoaded()
public boolean isGenerated()
Chunk has been generated at this location.@NotNull public Location set(double x, double y, double z)
x - X coordinatey - Y coordinatez - Z coordinate@NotNull public Location add(@NotNull Location base, double x, double y, double z)
base - The base coordinate to modifyx - X coordinate to add to basey - Y coordinate to add to basez - Z coordinate to add to base@NotNull public Location subtract(@NotNull Location base, double x, double y, double z)
base - The base coordinate to modifyx - X coordinate to subtract from basey - Y coordinate to subtract from basez - Z coordinate to subtract from base@NotNull public Location toBlockLocation()
public long toBlockKey()
Block.getBlockKey(int, int, int)@NotNull public Location toCenterLocation()
@NotNull public Location toHighestLocation()
NullPointerException - if {getWorld()} is null@NotNull public Location toHighestLocation(@NotNull HeightmapType heightmap)
heightmap - The heightmap to use for finding the highest y location.NullPointerException - if {getWorld()} is nullUnsupportedOperationException - if World.getHighestBlockYAt(int, int, com.destroystokyo.paper.HeightmapType) does not support the specified heightmappublic boolean createExplosion(float power)
power - The power of explosion, where 4F is TNTpublic boolean createExplosion(float power,
                               boolean setFire)
power - The power of explosion, where 4F is TNTsetFire - Whether or not to set blocks on firepublic boolean createExplosion(float power,
                               boolean setFire,
                               boolean breakBlocks)
power - The power of explosion, where 4F is TNTsetFire - Whether or not to set blocks on firebreakBlocks - Whether or not to have blocks be destroyedpublic boolean createExplosion(@Nullable Entity source, float power)
source - The source entity of the explosionpower - The power of explosion, where 4F is TNTpublic boolean createExplosion(@Nullable Entity source, float power, boolean setFire)
source - The source entity of the explosionpower - The power of explosion, where 4F is TNTsetFire - Whether or not to set blocks on firepublic boolean createExplosion(@NotNull Entity source, float power, boolean setFire, boolean breakBlocks)
source - The source entity of the explosionpower - The power of explosion, where 4F is TNTsetFire - Whether or not to set blocks on firebreakBlocks - Whether or not to have blocks be destroyed@NotNull public Collection<Entity> getNearbyEntities(double x, double y, double z)
x - 1/2 the size of the box along x axisy - 1/2 the size of the box along y axisz - 1/2 the size of the box along z axis@NotNull public Collection<LivingEntity> getNearbyLivingEntities(double radius)
radius - X Radius@NotNull public Collection<LivingEntity> getNearbyLivingEntities(double xzRadius, double yRadius)
xzRadius - X/Z RadiusyRadius - Y Radius@NotNull public Collection<LivingEntity> getNearbyLivingEntities(double xRadius, double yRadius, double zRadius)
xRadius - X RadiusyRadius - Y RadiuszRadius - Z radius@NotNull public Collection<LivingEntity> getNearbyLivingEntities(double radius, @Nullable Predicate<LivingEntity> predicate)
radius - Radiuspredicate - a predicate used to filter results@NotNull public Collection<LivingEntity> getNearbyLivingEntities(double xzRadius, double yRadius, @Nullable Predicate<LivingEntity> predicate)
xzRadius - X/Z RadiusyRadius - Y Radiuspredicate - a predicate used to filter results@NotNull public Collection<LivingEntity> getNearbyLivingEntities(double xRadius, double yRadius, double zRadius, @Nullable Predicate<LivingEntity> predicate)
xRadius - X RadiusyRadius - Y RadiuszRadius - Z radiuspredicate - a predicate used to filter results@NotNull public Collection<Player> getNearbyPlayers(double radius)
radius - X/Y/Z Radius@NotNull public Collection<Player> getNearbyPlayers(double xzRadius, double yRadius)
xzRadius - X/Z RadiusyRadius - Y Radius@NotNull public Collection<Player> getNearbyPlayers(double xRadius, double yRadius, double zRadius)
xRadius - X RadiusyRadius - Y RadiuszRadius - Z Radius@NotNull public Collection<Player> getNearbyPlayers(double radius, @Nullable Predicate<Player> predicate)
radius - X/Y/Z Radiuspredicate - a predicate used to filter results@NotNull public Collection<Player> getNearbyPlayers(double xzRadius, double yRadius, @Nullable Predicate<Player> predicate)
xzRadius - X/Z RadiusyRadius - Y Radiuspredicate - a predicate used to filter results@NotNull public Collection<Player> getNearbyPlayers(double xRadius, double yRadius, double zRadius, @Nullable Predicate<Player> predicate)
xRadius - X RadiusyRadius - Y RadiuszRadius - Z Radiuspredicate - a predicate used to filter results@NotNull public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double radius)
T - the entity typeclazz - Type to filter byradius - X/Y/Z radius to search within@NotNull public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xzRadius, double yRadius)
T - the entity typeclazz - Type to filter byxzRadius - X/Z radius to search withinyRadius - Y radius to search within@NotNull public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xRadius, double yRadius, double zRadius)
T - the entity typeclazz - Type to filter byxRadius - X RadiusyRadius - Y RadiuszRadius - Z Radius@NotNull public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double radius, @Nullable Predicate<T> predicate)
T - the entity typeclazz - Type to filter byradius - X/Y/Z radius to search withinpredicate - a predicate used to filter results@NotNull public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xzRadius, double yRadius, @Nullable Predicate<T> predicate)
T - the entity typeclazz - Type to filter byxzRadius - X/Z radius to search withinyRadius - Y radius to search withinpredicate - a predicate used to filter results@NotNull public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends Entity> clazz, double xRadius, double yRadius, double zRadius, @Nullable Predicate<T> predicate)
T - the entity typeclazz - Type to filter byxRadius - X RadiusyRadius - Y RadiuszRadius - Z Radiuspredicate - a predicate used to filter results@NotNull public Vector toVector()
Vector based on this Locationpublic void checkFinite()
                 throws IllegalArgumentException
IllegalArgumentException - if any component is not finitepublic static int locToBlock(double loc)
loc - Precise coordinate@NotNull public Map<String,Object> serialize()
ConfigurationSerializable
 This class must provide a method to restore this class, as defined in
 the ConfigurationSerializable interface javadocs.
serialize in interface ConfigurationSerializable@NotNull public static Location deserialize(@NotNull Map<String,Object> args)
args - map to deserializeIllegalArgumentException - if the world don't existsConfigurationSerializablepublic static float normalizeYaw(float yaw)
+/-180
 degrees.yaw - the yaw in degreesgetYaw()public static float normalizePitch(float pitch)
+/-90
 degrees.pitch - the pitch in degreesgetPitch()Copyright © 2020. All rights reserved.