Signs and setFacingDirection()

Discussion in 'Spigot Plugin Development' started by spookyFalco, May 25, 2016.

  1. I am having in issue in a plugin I am working on, and honestly I am quite embarrassed that I cant figure this out. I've read thread after thread but I still cant figure this out. All I want to do is rotate a sign. Here is the code I'm using.

    Code (Text):
            Location newLoc = LocationUtils.offset(location, xOffset, 0, zOffset);
           
            world.getBlockAt(newLoc).setType(Material.WALL_SIGN);
            Block signBlock = newLoc.getBlock();
            BlockState signState = signBlock.getState();
            Sign sign = new Sign();
            sign.setFacingDirection(blockDirection);
            signState.setData(sign);
            signState.update();
    NOTE I am using org.bukkit.material.Sign
     
    • Like Like x 1
  2. I read the thread and changed my code to this, but it still isnt working. Any ideas?
    Code (Text):
            Location newLoc = LocationUtils.offset(location, xOffset, 0, zOffset);
           
            world.getBlockAt(newLoc).setType(Material.WALL_SIGN);
            Block signBlock = newLoc.getBlock();
            BlockState signState = signBlock.getState();
            signState.setRawData((byte) 2);
            signState.update();
     
  3. Try this:
    Code (Text):
            Location newLoc = LocationUtils.offset(location, xOffset, 0, zOffset);
       
            world.getBlockAt(newLoc).setType(Material.WALL_SIGN);
            Block signBlock = newLoc.getBlock();
            Sign sign = (Sign) signblock.getState();
            sign.setRawData((byte) 2);
            sign.update();
    EDIT: Also note that #setRawData() is depreciated, so you might want to look into #setData()
     
  4. I had to change the code a little becase org.bukkit.material.Sign does not have the meathods update() or setRawData()
    I used this code and still nothing

    Code (Text):
            Location newLoc = LocationUtils.offset(location, xOffset, 0, zOffset);
             
            world.getBlockAt(newLoc).setType(Material.WALL_SIGN);
            Block signBlock = newLoc.getBlock();
            Sign sign = (Sign) signBlock.getState();
            sign.setData((byte) 2);
     
  5. That would be because it's org.bukkit.block.Sign and not org.bukkit.Material.Sign
     
    • Agree Agree x 1
  6. Ahh I see what you're talking about now. Well yeah you don't need the #update(); method.

    As far as the code goes...

    Code (Text):
       Location newLoc = LocationUtils.offset(location, xOffset, 0, zOffset);
             
    world.getBlockAt(newLoc).setType(Material.WALL_SIGN);
    world.getBlockAt(newLoc).setData((byte)2);