Solved Get which block a wall sign is at?

Discussion in 'Plugin Development' started by Bobfan, Dec 3, 2012.

  1. Offline

    Bobfan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    What method is used to find the block a wall sign is located on? I've tried using Sign s; but I don't know how to initialize it.
     
  2. Offline

    Tirelessly

    My BukkitDev Profile
    My Plugins (1)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    What's the context?
     
  3. Offline

    evilmidget38 Retired Staff

    My BukkitDev Profile
    My Plugins (4)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    First you need to do some sort of check to make sure your sign is a block. You can check the material, the id, whatever floats your boat. Then you can cast the Block's BlockState (Block.getState()) to a Sign.

    Example:
    Code (Text):
    1. Block b = someBlockOfYourChoice;
    2. if (b.getState() instanceof Sign) {
    3.     Sign s = (Sign) b.getState();
    4.     //Do what you want with your sign.
    5. }
     
  4. Offline

    Bobfan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thank you. If you don't check it and it isn't a sign, than it'll show an error
     

Share This Page