Create Block with Plugin

Discussion in 'Plugin Development' started by bubblegumsoldier, May 28, 2012.

Thread Status:
Not open for further replies.
  1. Hi guys,
    maybe it's a silly question, but
    1. how do I create a block or a wall in front of a player?
    2. How do I create signs on which the is printed a String variable, that updates automatically?
     
  2. Offline

    r0306

    bubblegumsoldier
    1. If this is in a command executor, you need to cast the sender to a player first.
    This code creates a wall in front of the player (if I used the getLineOfSight() correctly)
    Code:
    Location pLoc = player.getLocation();
    List<Block> locs = player.getLineOfSight();
    for (Block b : locs) {
    if (b.getLocation().getY() == pLoc.getY() + 1) {
    b.setType(Material.STONE);
    }
    }
    2. You would use setLine()
    Code:
    Location loc = new Location(world, x, y, z);
    Block b = loc.getBlock().setType(Material.WALL_SIGN) // or SIGN depending if it's on a wall or not
    Sign s = (Sign) b.getState();
    s.setLine(0, "First Line");
    s.setLine(1, "Second Line");
    s.setLine(2, "and so on...");
    s.update();
    }
    }
    
     
  3. Offline

    Wundark

    r0306
    When setting a sign's lines you need to update the state of the Sign.
     
    r0306 likes this.
  4. Offline

    r0306

    Updated.
     
  5. thanks very much. I see what I can do...


    But with this you need to look exactly the right way. Is there a way to just create a wall with an angle that I can set in my script?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
Thread Status:
Not open for further replies.

Share This Page