Paper/Spigot-API-Patches/0007-Entity-Origin-API.patch
Shane Freeder 76169471d8
API
2019-12-10 23:59:19 +00:00

71 lines
2.4 KiB
Diff

From 417c860ef8f5168eafc0268f4a21f74ebdd06f8e Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Mon, 29 Feb 2016 17:50:31 -0600
Subject: [PATCH] Entity Origin API
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index d708d62b..8cfcc3a5 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -599,4 +599,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
@Override
Spigot spigot();
// Spigot end
+
+ // Paper start
+ /**
+ * Gets the location where this entity originates from.
+ * <p>
+ * This value can be null if the entity hasn't yet been added to the world.
+ *
+ * @return Location where entity originates or null if not yet added
+ */
+ @Nullable
+ Location getOrigin();
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
index 64f9d3fd..14cb0d77 100644
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
@@ -54,4 +54,15 @@ public interface FallingBlock extends Entity {
* @param hurtEntities whether entities will be damaged by this block.
*/
void setHurtEntities(boolean hurtEntities);
+
+ /**
+ * Gets the source block location of the FallingBlock
+ *
+ * @return the source block location the FallingBlock was spawned from
+ * @deprecated replaced by {@link Entity#getOrigin()}
+ */
+ @Deprecated
+ default org.bukkit.Location getSourceLoc() {
+ return this.getOrigin();
+ }
}
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
index 5a878932..3022b4a2 100644
--- a/src/main/java/org/bukkit/entity/TNTPrimed.java
+++ b/src/main/java/org/bukkit/entity/TNTPrimed.java
@@ -39,4 +39,15 @@ public interface TNTPrimed extends Explosive {
*/
@Nullable
public Entity getSource();
+
+ /**
+ * Gets the source block location of the TNTPrimed
+ *
+ * @return the source block location the TNTPrimed was spawned from
+ * @deprecated replaced by {@link Entity#getOrigin()}
+ */
+ @Deprecated
+ default org.bukkit.Location getSourceLoc() {
+ return this.getOrigin();
+ }
}
--
2.24.0