Checking If Specific Block Was Clicked

Discussion in 'Plugin Development' started by KuroRyuuNA, Nov 1, 2014.

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

    KuroRyuuNA

    Hello Ladies and Gentlemen! I am currently developing a Bookshelf plugin that changes the GUI of a Bookshelf. I know how to do all but one part... and that is check if the the block, Bookshelf, was clicked.

    Here is what's in my EventHandler so far...
    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event){
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK){
             
                 
                }
            }
    If you know what I should add, feel free to show me, that would help a lot :) Thanks!
     
  2. Offline

    Monkey_Swag

  3. Offline

    KuroRyuuNA

    I was actually looking at that before I made the post Monkey_Swag. Whenever I add:

    Code:
    if (event.getClickedBlock() == Material.BOOKSHELF){
                   
                }
    It says, "Incompatible operand types Block and Material"
     
  4. KuroRyuuNA
    getClickedBlock() returns a Block and you're trying to compare it to a Material. Get the block type with Block#getType(), then compare that to Material.BOOKSHELF.
     
    xTrollxDudex and Monkey_Swag like this.
  5. Offline

    KuroRyuuNA

    I am sorry, I don't understand. Do you mind showing me an example on how I would implement that?
     
  6. Offline

    Gater12

    KuroRyuuNA
    He did. e#getClickedBlock() returns a Block object. Block object has the method getType() which returns a Material enum.
     
    KuroRyuuNA and xTrollxDudex like this.
  7. Offline

    KuroRyuuNA

    Thanks. With your help, I figured it out. Much appreciated!
     
Thread Status:
Not open for further replies.

Share This Page