Redstone Powering

Discussion in 'Plugin Development' started by MC_Player, Dec 9, 2011.

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

    MC_Player

    Hi there,

    I'm building a plugin but now i'm quite stuck.
    How can I do something like if the block behind/before/right/left the current block is powered, then do something with the current block.
     
  2. Offline

    Slamakans

    Code:java
    1. Block block = wherever you get the block from;
    2.  
    3. Block northBlock = block.getRelative(-1, 0, 0);
    4. Block southBlock = block.getRelative(1, 0, 0);
    5. Block eastBlock = block.getRelative(0, 0, -1);
    6. Block westBlock = block.getRelative(0, 0, 1);
    7.  
    8. Block aboveBlock = block.getRelative(0, 1, 0);
    9. Block belowBlock = block.getRelative(0, -1, 0);
    10.  
    11. whateverBlockYouWantToCheck.isPowered();


    There are different types of .isPowered(), I have never used isPowered() so I haven't gotten into it though.

    Hope I helped ;)

    Btw: The method takes x, y, z and returns a block in case you didn't figure it out ^^
     
    Torrent likes this.
  3. Offline

    MC_Player

    Thank you :)
     
Thread Status:
Not open for further replies.

Share This Page