signs

Discussion in 'Plugin Development' started by MrTheNewGuy, Aug 14, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    MrTheNewGuy

    hello,

    does someone know how to get the location of the block where the sign is on.(on the side)

    thanks.
     
  2. Offline

    tr4st

    Do you use an Event for this?
    Code:java
    1. Block getBlockBelow = event.getPlayer().getWorld().getBlockAt(
    2. event.getPlayer().getLocation().getBlockX(),
    3. event.getPlayer().getLocation().getBlockY() -1,
    4. event.getPlayer().getLocation().getBlockZ());

    In this case getBlockBelow.getType() will tell you which kind of Block under your Block is.
    This could be used for e.g. in a BlockBreakEvent or something where you interact with the Block above the requested one.
     
  3. Offline

    MrTheNewGuy

    thanks

    but how do i get a sign that is on the side of a block and not on top of a block

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  4. Offline

    tr4st

    On top would be Material.SIGN_POST and on a wall would be Material.WALL_SIGN ;)
    Code:java
    1. Block getBlockBelow = event.getPlayer().getWorld().getBlockAt(
    2. event.getPlayer().getLocation().getBlockX(),
    3. event.getPlayer().getLocation().getBlockY() -1,
    4. event.getPlayer().getLocation().getBlockZ());
    5. if (getBlockBelow.getType() == Material.WALL_SIGN) {
    6. // Your code here.
    7. }
     
Thread Status:
Not open for further replies.

Share This Page