From ad38184dc2565cd83e5e0336e3921ab84a9c4ff5 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 11 Oct 2011 02:04:40 +0100 Subject: [PATCH] Added add/subtract by Vector methods to Location, thanks to erisdiscord By: Nathan Adams --- .../src/main/java/org/bukkit/Location.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/Location.java b/paper-api/src/main/java/org/bukkit/Location.java index 2659548ade..70a3f1eacb 100644 --- a/paper-api/src/main/java/org/bukkit/Location.java +++ b/paper-api/src/main/java/org/bukkit/Location.java @@ -231,6 +231,20 @@ public class Location implements Cloneable { z += vec.z; return this; } + + /** + * Adds the location by a vector. + * + * @see Vector + * @param vec Vector to use + * @return the same location + */ + public Location add(Vector vec) { + this.x += vec.getX(); + this.y += vec.getY(); + this.z += vec.getZ(); + return this; + } /** * Adds the location by another. Not world-aware. @@ -266,6 +280,20 @@ public class Location implements Cloneable { z -= vec.z; return this; } + + /** + * Subtracts the location by a vector. + * + * @see Vector + * @param vec The vector to use + * @return the same location + */ + public Location subtract(Vector vec) { + this.x -= vec.getX(); + this.y -= vec.getY(); + this.z -= vec.getZ(); + return this; + } /** * Subtracts the location by another. Not world-aware and