Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
36f34f01c0
Upstream has released updates that appears 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: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
67 Zeilen
2.4 KiB
Diff
67 Zeilen
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 ac3c8eef58872c2de840a4b7ba7d77c2e597aee0..f87ecd0a753b0f730ee33c0dd699b7388e8c6697 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)
|
|
*/
|