Change direction of existing/new sign

Discussion in 'Plugin Development' started by darkhelmet, Jan 5, 2013.

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

    darkhelmet

    I've been searching the forums for some ideas on to set the facing direction of a sign. I have a plugin that changes a block to a sign (it could add a new sign too, not a big deal).

    I have a specific, known BlockFace direction I want it to face but nothing I try works, except for figuring out what the byte value for the directions would be.

    Code:

    Code:
    Block block = sign block in the world.
     
    // tried, kinda works, but I'd rather not convert blockface directions to byte values
    Sign s = (Sign)block.getState();
    s.setRawData( (byte value relating to directions) );
     
    // tried:
    org.bukkit.material.Sign test = (org.bukkit.material.Sign)block.getState().getData();
    test.setFacingDirection(b.getFacing());
    block.setData(test.getData(), true);
     
  2. Offline

    caseif

    Code:java
    1. byte north = 0x2;
    2. byte south = 0x3;
    3. byte west = 0x4;
    4. byte east = 0x5;
    5. block.setData(north); // or whichever direction you want it to face

    Additionally, with the test variable, you're attempting to cast a byte to a sign item (as in, the type found in an inventory), which will never work.
     
    gomeow likes this.
  3. Offline

    fireblast709

    you might need to teleport the sign
     
Thread Status:
Not open for further replies.

Share This Page