Paper/patches/api/0129-Expand-Location-Manipulation-API.patch
Jason bc127ea819
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#6222)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
eec4aab0 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent
205213c6 SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron

CraftBukkit Changes:
b8c522d5 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent
f04a77dc SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron
d1dbcebc SPIGOT-6653: Canceling snow bucket placement removes snow from bucket
4f34a67b #891: Fix scheduler task ID overflow and duplication issues

Spigot Changes:
d03d7f12 BUILDTOOLS-604: Rebuild patches
2021-07-18 09:41:53 +02:00

67 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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
index a8d4f7972d07ddde171b4a1ec470a4c616e02b2e..36ed248f0716f2cc465c08ab851b7d83d4c7c0a7 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -546,6 +546,54 @@ public class Location implements Cloneable, ConfigurationSerializable {
public boolean isChunkLoaded() { return this.getWorld().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)
+ */
+ @NotNull
+ 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)
+ */
+ @NotNull
+ public Location add(@NotNull 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)
+ */
+ @NotNull
+ public Location subtract(@NotNull 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)
*/