getting block that is clicked does not work?

Discussion in 'Plugin Development' started by Schaakmatth, Jun 4, 2014.

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

    Schaakmatth

    the title say it little bit of code:
    Code:java
    1. @EventHandler
    2. public void bedrock(PlayerInteractEvent e) {
    3. Block block = e.getClickedBlock();
    4. Player p = e.getPlayer();
    5. if(e.getAction() == Action.LEFT_CLICK_BLOCK) {
    6. p.sendMessage("DEBUG");
    7. if(block.getType().equals(Material.BEDROCK)) {
    8. p.sendMessage("DEBUG");
    9. p.giveExpLevels( +1);

    this code does not work :(
     
  2. Offline

    Seadragon91

    Did you register the listener?
     
  3. Offline

    MOMOTHEREAL

    Put your block variable after the e.getAction() check.

    The server will fire this event, and you have to check if the event should look for a block before declaring one.
     
  4. Offline

    aFreshKiwi

    You cannot directly cast the event to a player like that.

    Use e.getEntity();
     
  5. Offline

    Schaakmatth

    Solved should you look at my other post? if you do that you are AMAZING! MOMOTHEREAL
     
Thread Status:
Not open for further replies.

Share This Page