From bf8919735d6e0be46bed477c1e02ab174dcd1fd3 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 2 Jan 2011 05:29:51 -0500 Subject: [PATCH] Added notchToBlockFace convenience method By: durron597 --- .../org/bukkit/craftbukkit/CraftBlock.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index f67d14bfed..43ca3fbaa6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java @@ -149,4 +149,29 @@ public class CraftBlock implements Block { public String toString() { return "CraftBlock{" + "world=" + world + "x=" + x + "y=" + y + "z=" + z + "type=" + type + "data=" + data + '}'; } + + /** + * Notch uses a 0-5 to mean Down, Up, East, West, North, South + * in that order all over. This method is convience to convert for us. + * + * @return BlockFace the BlockFace represented by this number + */ + public static BlockFace notchToBlockFace(int notch) { + switch (notch) { + case 0: + return BlockFace.Down; + case 1: + return BlockFace.Up; + case 2: + return BlockFace.East; + case 3: + return BlockFace.West; + case 4: + return BlockFace.North; + case 5: + return BlockFace.South; + default: + return BlockFace.Self; + } + } }