Solved Make sign face the player or snap to block behind it.

Discussion in 'Plugin Development' started by woutwoot, Feb 17, 2013.

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

    woutwoot

    My plugin places a sign in the world, that's working fine.
    My question is, how do I make the sign face the player, or make it attach to the block behind it?

    This is my code:
    Code:
    Block signblock = owner.getWorld().getBlockAt(x, y, z);
            signblock.setType(Material.SIGN_POST);
       
            Sign sign = (Sign) owner.getWorld().getBlockAt(x, y, z).getState();
            sign.setLine(0, "---Text---");
            sign.setLine(1, owner.getName());
            sign.setLine(2, "Text");
            sign.setLine(3, "------");
            sign.update();
    Aditional info: I use this after the player right clicked the block above it.
     
  2. Offline

    dfitz360

    Block tblock = signblock.getRelative(BlockFace.NORTH);
    if(tblock.getType!=Material.AIR) {
    tblock.setData((byte)??); //find out the values by placing the signs on block and reading the data. usefull tool http://dev.bukkit.org/server-mods/superredstone-sonic-screwdriver/ and set it to /sonic 1. this will give the data values. just do all the direction of blockface(north, south, east, west)
     
  3. Offline

    woutwoot

    Thanks, will try :)

    Thanks for all the help but it's not working as it should, it's not snapping to the block behind it, it doesn't rotate, only when 2 signs are placed next to each other, and then it's rotating wrong and not snapping :(
    Isn't there a simpler way of achieving this?

    EDIT: Nevermind, got it myself. Not Perfect code, but works ...
    Code:
            Block tblock = signblock.getRelative(BlockFace.NORTH);
            if((tblock.getType()!=Material.AIR) && (tblock.getTypeId() != 68)){
                signblock.setData((byte)3);
                return;
            }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page