From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Byteflux 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 b46653655d1da3ffe54d91b038ec360cd77f0c44..573d959a0a534b72338566eea0a9eca4124dba92 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -595,4 +595,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent @Override Spigot spigot(); // Spigot end + + // Paper start + /** + * Gets the location where this entity originates from. + *

+ * 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 64f9d3fd870d65afd2ee9a85625b149163eee144..14cb0d770561151570ab4399ca5facff43076819 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 a23cfdf66877f0a61eae700de084c76e6ee7b431..0813bd913c8fdb2001963ce3e82c07c2af105418 100644 --- a/src/main/java/org/bukkit/entity/TNTPrimed.java +++ b/src/main/java/org/bukkit/entity/TNTPrimed.java @@ -53,4 +53,15 @@ public interface TNTPrimed extends Explosive { * @param source the source of this primed TNT */ public void setSource(@Nullable Entity source); + + /** + * 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(); + } }