mirror of
https://github.com/PaperMC/Paper.git
synced 2026-11-24 18:09:41 -05:00
added playSound methods to the World interface and a utility method to Location
By: sunkid <sunkid@iminurnetz.com>
This commit is contained in:
1 parent
b91a8f0389
commit
e8e27a86f4
3 files changed
+66
-1
No files matched your search
@@ -298,4 +298,19 @@ public class Location implements Cloneable {
|
||||
public static int locToBlock(double loc) {
|
||||
return (int) Math.floor(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the distance between two locations in a world.
|
||||
*
|
||||
* @param loc the Location to calculate the distance to
|
||||
* @return the distance between this location and the parameter
|
||||
* @throws IllegalArgumentException if the location parameter is null or represents a location in a different world
|
||||
*/
|
||||
public double distanceTo(Location loc) throws IllegalArgumentException {
|
||||
if (loc == null || loc.getWorld() != getWorld()) {
|
||||
throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
|
||||
}
|
||||
|
||||
return toVector().distance(loc.toVector());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user