summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSenmori <thesenmori@gmail.com>2018-09-02 18:28:53 -0400
committermd_5 <git@md-5.net>2018-09-03 18:06:58 +1000
commitee5efeb0dc59dc8178d467f635ae03806d05d061 (patch)
treee8b8876ed45cd1236f33f43a76153341c8d61bae /src
parent3037eb3e7caa6941b343c31dc72255132ad78f50 (diff)
downloadcraftbukkit-ee5efeb0dc59dc8178d467f635ae03806d05d061.tar
craftbukkit-ee5efeb0dc59dc8178d467f635ae03806d05d061.tar.gz
craftbukkit-ee5efeb0dc59dc8178d467f635ae03806d05d061.tar.lz
craftbukkit-ee5efeb0dc59dc8178d467f635ae03806d05d061.tar.xz
craftbukkit-ee5efeb0dc59dc8178d467f635ae03806d05d061.zip
Add getFacing method to get the current cardinal direction an entity is facing.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 5f8a9e42..eb1bf55e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -13,9 +13,11 @@ import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
+import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -720,6 +722,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return PistonMoveReaction.getById(getHandle().getPushReaction().ordinal());
}
+ @Override
+ public BlockFace getFacing() {
+ // Use this method over getDirection because it handles boats and minecarts.
+ return CraftBlock.notchToBlockFace(getHandle().getAdjustedDirection());
+ }
+
protected NBTTagCompound save() {
NBTTagCompound nbttagcompound = new NBTTagCompound();