PlayerInteractEvent only gets called sometimes.

Discussion in 'Plugin Development' started by maxwell71, Jan 12, 2020.

  1. Offline

    maxwell71

    PHP:
    @EventHandler
        
    public void onHeal(PlayerInteractEvent e){
            
    Player p e.getPlayer();
            if(
    p.getItemInHand().getType() == Material.MUSHROOM_SOUP){
                if(
    e.getAction() == Action.RIGHT_CLICK_BLOCK|| e.getAction() == Action.RIGHT_CLICK_AIR){
                    
    p.setHealth(20);
                    
    p.setItemInHand(new ItemStack(Material.AIR));

                }
            }
    My error is that if(e.getAction == Action.RIGHT_CLICK_BLOCK does not work at all, even tho RIGHT CLICK AIR works fine.
     
  2. Offline

    Strahan

    Works fine for me. What MC version are you developing against?
     

Share This Page