diff --git a/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java b/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java index 5e150bf39d..6dc70d6d77 100644 --- a/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java +++ b/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java @@ -34,6 +34,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.material.Attachable; +import org.bukkit.material.Directional; import org.bukkit.material.MaterialData; import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; @@ -517,6 +518,23 @@ public String getAttribute(Attribute attribute) { // BLOCK ATTRIBUTES ///////////////// + // <--[tag] + // @attribute + // @returns dLocation + // @description + // Returns the relative location vector of where this block is facing. + // Only works for block types that have directionality (such as signs, chests, stairs, etc.). + // This can return for example "1,0,0" to mean the block is facing towards the positive X axis. + // You can use ]> to get the block directly in front of this block (based on its facing direction). + // --> + if (attribute.matches("block_facing")) { + if (getBlock().getBlockData() instanceof Directional) { + Vector facing = ((Directional) getBlock().getBlockData()).getFacing().getDirection(); + return new dLocation(getWorld(), facing.getX(), facing.getY(), facing.getZ()) + .getAttribute(attribute.fulfill(1)); + } + } + // <--[tag] // @attribute // @returns dLocation @@ -546,7 +564,7 @@ public String getAttribute(Attribute attribute) { // Returns the location of the block this location is on, // i.e. returns a location without decimals or direction. // --> - if (attribute.startsWith("block")) { + if (attribute.matches("block")) { return new dLocation(getWorld(), getBlockX(), getBlockY(), getBlockZ()) .getAttribute(attribute.fulfill(1)); }