From cae33c7e3cae94d0cd096fd5c0c8314505f4cef8 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 25 Jul 2018 01:38:37 -0400 Subject: [PATCH] Expand Location Manipulation API - Closes #1265 Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z); --- ...126-Expand-Location-Manipulation-API.patch | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Spigot-API-Patches/0126-Expand-Location-Manipulation-API.patch diff --git a/Spigot-API-Patches/0126-Expand-Location-Manipulation-API.patch b/Spigot-API-Patches/0126-Expand-Location-Manipulation-API.patch new file mode 100644 index 000000000..8d0ca3989 --- /dev/null +++ b/Spigot-API-Patches/0126-Expand-Location-Manipulation-API.patch @@ -0,0 +1,66 @@ +From d3916598abd6d23f6b2e332cd987d20e80ad30f1 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 25 Jul 2018 01:36:07 -0400 +Subject: [PATCH] Expand Location Manipulation API + +Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z); + +diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java +index d0d86e1a..253f0c2d 100644 +--- a/src/main/java/org/bukkit/Location.java ++++ b/src/main/java/org/bukkit/Location.java +@@ -503,6 +503,51 @@ public class Location implements Cloneable, ConfigurationSerializable { + public boolean isChunkLoaded() { return world.isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper + + // Paper start ++ ++ /** ++ * Sets the position of this Location and returns itself ++ * ++ * This mutates this object, clone first. ++ * @param x X coordinate ++ * @param y Y coordinate ++ * @param z Z coordinate ++ * @return self (not cloned) ++ */ ++ public Location set(double x, double y, double z) { ++ this.x = x; ++ this.y = y; ++ this.z = z; ++ return this; ++ } ++ ++ /** ++ * 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. ++ * @param base The base coordinate to modify ++ * @param x X coordinate to add to base ++ * @param y Y coordinate to add to base ++ * @param z Z coordinate to add to base ++ * @return self (not cloned) ++ */ ++ public Location add(Location base, double x, double y, double z) { ++ return this.set(base.x + x, base.y + y, base.z + 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. ++ * @param base The base coordinate to modify ++ * @param x X coordinate to subtract from base ++ * @param y Y coordinate to subtract from base ++ * @param z Z coordinate to subtract from base ++ * @return self (not cloned) ++ */ ++ public Location subtract(Location base, double x, double y, double z) { ++ return this.set(base.x - x, base.y - y, base.z - z); ++ } ++ + /** + * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z) + */ +-- +2.18.0 +