Detect placed block

Discussion in 'Plugin Development' started by DJSanderrr, Dec 26, 2012.

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

    DJSanderrr

    Hey i am VERY noobie in Developing bukkit plugin's and started just a few days ago,
    But what i want to do is that if a dispenser "Releases Content",
    i detect the content, if it is Firework,
    It check's If there is a sign on the side, (<- This is the part I D K)
    and if there is a sign on the side, it ReFills

    This is my code: http://pastebin.com/9HCFfe3A

    Thanks in advance!!!
     
  2. Offline

    fireblast709

    check what blocks .getRelative(BlockFace.<side>, 1) (a method from the Block class) you get (so calling .getType() and comparing the Material)
     
  3. Offline

    DJSanderrr

    And what is the 1 for in .getRelative(BlockFace.<side>, 1)
     
  4. Offline

    fireblast709

    how many blocks from that block, in the direction of the blockface. So if you would use .getRelative(BlockFace.UP,1) you would get the block above it
     
  5. Offline

    DJSanderrr

    okay thank you so mutch, and if i want to get the text on the sign ?

    BTW also how to get the fire work that get dispensed!!! Need to know that

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  6. Offline

    YoFuzzy3

    To get the sign's text assuming you already have the block:
    Code:java
    1. Block block = // Your block
    2. if(block.getState() instanceof Sign){ // Check if it's a sign
    3. Sign sign = (Sign) block.getState() // Cast the block to Sign
    4. String line1 = sign.getLine(0); // The text on the first line of the sign
    5. String line2 = sign.getLine(1); // The text on the second line of the sign
    6. String line3 = sign.getLine(2); // The text on the third line of the sign
    7. String line4 = sign.getLine(3); // The text on the fourth line of the sign
    8. }
     
  7. Offline

    fireblast709

    You should be able to get the ItemStack that was dispensed with the BlockDispenseEvent
     
  8. Offline

    kingBS11

    Haha I just made a plugin exactly like this :p
     
  9. Offline

    DJSanderrr

    I tried that few times but it wont detect fireworks,
    Try'd with other materials and it worked fine..

    Thanks, going to try it tomorrow

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  10. Offline

    fireblast709

    Use the latest Bukkit/Craftbukkit, it detects fireworks perfectly fine with me. If that does not work, try it without the ignoreCancelled=true
     
  11. Offline

    DJSanderrr

    okay thank you i'll try it out!

    Too bad it din't work for me, BUT THE FIREWORK PART DID!!!:D

    BTW
    http://pastebin.com/tzRqSFf4 <--- code!

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

Share This Page