Place Sign

Discussion in 'Plugin Development' started by confuserr, Aug 14, 2012.

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

    confuserr

    I can't work out how to place a sign on a block. It sets the block at the given location to a sign, but theres a big gap, almost like it sets it on to an air block, I'm assuming it has something to do with the facing of the sign?

    How do I set the sign with the correct facing?

    Code:
    Vector vec = player.getLocation().toVector(); // get player's location vector
    Vector dir = player.getLocation().getDirection(); // get player's facing
    vec = vec.add(dir.multiply(1)); // add player's direction * 1 to the location (getting ~1 block in front of player)
    Location location = vec.setY(vec.getY()+1).toLocation(player.getWorld()); // convert back to location
                    
    // Set the pressure plate
    location.getBlock().setType(Material.STONE_PLATE);
                    
    // Set the block above
    location.add(0,3, 0);
    location.getBlock().setType(Material.GOLD_BLOCK);
                    
    // Set the sign on to the gold block
    // Need help here
    Location signLoc = ... ?
     signLoc.getBlock().setType(Material.WALL_SIGN);
    
     
  2. Offline

    tr4st

    Sign.setFacingDirection() could probably solve the facing direction problem.
    And you should create a new Block to safe the location of the current Block in.
    You could get it with getBlockAt(location).
     
  3. Offline

    confuserr

Thread Status:
Not open for further replies.

Share This Page