Solved WallSign Direction

Discussion in 'Spigot Plugin Development' started by Lightcaster5, Feb 22, 2020.

  1. How do you set the direction of a sign? Specifically a wall sign.
    Heres what I have:
    Code (Java):
    Location location = new Location(world, x, y, z);
    Block block = world.getBlockAt(location);
    Sign sign = (Sign) block.getState().getData();
    // Somehow change the direction of the wall sign
    // sign#setData() doesn't work from what i've done
  2. Bump
  3. I did find something that I will most likely need and that is the Directional interface but everything I've tried with it hasn't worked. So... Again... Bump
  4. From what we can see in your code, you haven't updated the state. Try that
  5. I'm... asking how do I even set the state... updating comes after you set it if I'm not mistaking...
  6. BlockState#update is how you update the state. a quick peek in the javadocs or your ide would tell you
  7. Again, I know I need to update it but first I need to SET it. Im asking how do I SET it.
    Example of what you describe below:
    Code (Text):
    Sign is created at xyz
    Update sign rotation
    Example of what I need below:
    Code (Text):
    Sign is created at xyz
    Set the direction of the sign
    Update sign rotation
  8. Maybe ?
    Code (Text):
  9. Read above, Ive tried that and get casting errors
  10. I think you need to update the block after setType and before using it as a sign.
    #11 besuper, Feb 27, 2020
    Last edited: Feb 27, 2020
  11. block#getstate
  12. Code (Java):
    public static BlockFace getSignFacing(Block b, BlockFace face) {
    if(!(b.getState() instanceof org.bukkit.block.Sign))return null;
            org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
            if (sign.getBlockData() instanceof {
       signData = ( sign.getBlockData();
                return signData.getFacing();
            return null;

    public static BlockFace setSignFacing(Block b, , BlockFace face){
      if(!(b.getState() instanceof org.bukkit.block.Sign))return;
    org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
            if (sign.getBlockData() instanceof {
       signData = ( sign.getBlockData();
    This is code that I have used before and it worked fine
    Is only for wall signs
    • Winner Winner x 1
  13. There are a lot of things wrong with the code you provided. Take exactly what you put and paste it into your IDE and see how many errors you get when you are using the Spigot-1.8.8 API.

    EDIT: Thanks for the help though
  14. I did this with the 1.13 API, you'll have to adapt it
    • Winner Winner x 1
  15. You can't just... do that.....
    You do know with each version that comes out, new methods for classes are created and removed right?????
  16. I got it figured out, thanks for the help!
    Heres the code:
    Code (Java):
    public void setFacing(Block block, BlockFace facing) {
        if (block.getType() == Material.WALL_SIGN) {
            org.bukkit.material.Sign sign = (org.bukkit.material.Sign) block.getState().getData();
            block.setData(sign.getData(), true);