[Unsolved] Right Click not detected

Discussion in 'Plugin Development' started by Ghilliedrone, Jul 23, 2013.

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

    Ghilliedrone

    I'm trying to make a plugin where lighting strikes the area the player is looking at if they right click while holding a blaze rod. The right click is never detected so, the plugin doesn't work. Here's the code
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent event){
    3.  
    4. Player player = event.getPlayer();
    5. Block targetblock = player.getTargetBlock(null, 200);
    6. Location location = targetblock.getLocation();
    7. World world = player.getWorld();
    8.  
    9. if( event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getTypeId() == (369) ){
    10. player.getInventory().getItemInHand().setAmount(player.getInventory().getItemInHand().getAmount()-1);
    11. world.strikeLightning(location);
    12. world.createExplosion(location, 3);
    13. }
    14. }

    Any ideas?
     
  2. Offline

    krazytraynz

    Code:java
    1. if(event.getAction().equals(Action.RIGHT_CLICK_AIR)
    2.  

    Action.RIGHT_CLICK_BLOCK is only called if the Player right clicks a block within their reach.
     
  3. Offline

    Ghilliedrone

    That didn't work :( Action.RIGHT_CLICK_BLOCK didn't work either with blocks in my reach
     
  4. Offline

    krazytraynz

    Try putting this in your if statement.
    Code:
    player.getItemInHand().getType() == Material.BLAZE_ROD
     
  5. Offline

    Ghilliedrone

    Still nothing
     
Thread Status:
Not open for further replies.

Share This Page