Solved Place blocks?

Discussion in 'Plugin Development' started by DoggyCode™, Jul 23, 2015.

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

    DoggyCode™

    Ok, my question is simple.. Can you make your plugin place a block? How to place a custom block at a specific location?
     
  2. Offline

    Asc_Nicholas

    I personally have not done this but I'm sure this is possible.

    You should have to use a medium of some sort (player location, player line of sight etc) to get a location. Once you've gotten that location you need to get the type of material which currently occupies that location (air, dirt, water, etc) and then set that the type of that block to something else (.setType(Material.X)

    I hope that wasn't too confusing, if you need me to clarify something let me know
     
  3. Offline

    DoggyCode™

    @Asc_Nicholas No, I completely understand what you mean, and that works. But when I say "custom block" I mean like a sign, with written text on it, in which your method won't work.
     
  4. 1. Set the block to sign:
    Code:
    block.setType(Material.SIGN_POST);
    2. Cast it to Sign:
    Code:
    Sign s = (Sign) block.getState();
    3. Edit the text of the sign:
    Code:
    s.setLine(0, "This is the first line");
    s.setLine(3, "This is the last line");
    4. Update the sign:
    Code:
    s.update();
     
    Asc_Nicholas and DoggyCode™ like this.
  5. Offline

    DoggyCode™

    @FisheyLP That worked excellent. Cheers!
     
Thread Status:
Not open for further replies.

Share This Page