2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
Expand Location Manipulation API - Closes #1265
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
2018-07-25 07:38:37 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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
|
2020-07-23 01:35:44 +02:00
|
|
|
index af2ee43f2c5133668c18710f526a107d94a5d898..369ce9ff6c8bb97a64a8e229115564412e6e7654 100644
|
Expand Location Manipulation API - Closes #1265
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
2018-07-25 07:38:37 +02:00
|
|
|
--- a/src/main/java/org/bukkit/Location.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Location.java
|
2019-05-06 04:58:04 +02:00
|
|
|
@@ -546,6 +546,54 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
|
|
|
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
|
Expand Location Manipulation API - Closes #1265
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
2018-07-25 07:38:37 +02:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
Expand Location Manipulation API - Closes #1265
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
2018-07-25 07:38:37 +02:00
|
|
|
+ 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)
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
|
|
|
+ public Location add(@NotNull Location base, double x, double y, double z) {
|
Expand Location Manipulation API - Closes #1265
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
2018-07-25 07:38:37 +02:00
|
|
|
+ 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)
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
|
|
|
+ public Location subtract(@NotNull Location base, double x, double y, double z) {
|
Expand Location Manipulation API - Closes #1265
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
2018-07-25 07:38:37 +02:00
|
|
|
+ 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)
|
|
|
|
*/
|