How to assign a variable to an if statement.

Discussion in 'Plugin Development' started by EpicBlargh, Oct 9, 2012.

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

    EpicBlargh

    Here's the code I'm trying to write this with.

    Code:
    if(event.getClickedBlock().getType() == Material.STONE_PLATE){
                if(event.getClickedBlock().getRelative(BlockFace.DOWN, 2).equals(Material.REDSTONE_WIRE)){
                                }
            }
    How would I do this? Any help is appreciated.
     
  2. Offline

    Dave_

    Can you please better describe what your trying to accomplish?

    Ill take a guess that you want to get the redstone wire as a block so you change it to on?
     
  3. Offline

    EpicBlargh

    Don't worry about the purpose of the code. I just want an easy way to call the block 2 blocks below the pressure plate.
     
  4. Offline

    Dave_

    Code:
        if(event.getClickedBlock().getType() == Material.STONE_PLATE){
                if(event.getClickedBlock().getRelative(BlockFace.DOWN, 2).equals(Material.REDSTONE_WIRE)){
                    Block redstone = event.getClickedBlock().getRelative(BlockFace.DOWN, 2);
                }
            }
    Something like that?
     
  5. Offline

    EpicBlargh

    I'm sorry, but could you please refrain from making me feel stupid?

    Thanks so much! :D

    It works now.
     
  6. Offline

    Dave_

    No problem lol
     
  7. Offline

    Courier

    The block will never equal Material.REDSTONE_WIRE. You need to get the block's type, and compare that.
     
  8. Offline

    Dave_

    I recognized that too, forgot to bring it up.
     
Thread Status:
Not open for further replies.

Share This Page