Is there the event on a Item when you press Left Click ?? I know there is for RightClick, (PlayerItemEvent) but not on left click :S Thanks
PLAYER_ANIMATION is triggered when the player swings their arm (so for both left and right click). I'm not sure if that's any help. If you want to detect left clicking on a block then BLOCK_DAMAGED can be used.
Thank you very much for your info. Exactly what I want is to know the Event triggered when I left click with an item(Ex. Sword) on a Player / Entity Thanks
Yes I know Entity_damaged event , but how I know who dealed that damage ? There is no method that gives me that information I think. :s thanks
Check if it's an EntityDamageByEntityEvent, if not return, if so then continue. The EntityDamageByEntityEvent holds a getDamager() function (or method). Example: PHP: if(!(event instanceof EntityDamageByEntityEvent)){ return;}EntityDamgeByEntityEvent edbeEvent = (EntityDamageByEntityEvent)event;Entity damager = edbeEvent.getDamager();
Excerpt from one of my plugins: Code: public void onBlockDamage(BlockDamageEvent event){ if(event.getDamageLevel().getLevel()!=0){ return; //This is needed because otherwise the leftclick will fire every single moment when you damage the block. } BlockPosition pos = new BlockPosition(event.getBlock()); //Do your left-click stuff here. }
That function doesn't work for all the blocks... I found the simple but full working solution (that's working right now too) Code: public void onBlockDamage(BlockDamageEvent event) { BlockPosition pos = new BlockPosition(event.getBlock()); //Do your left-click stuff here. } Hope this helps... EDIT by Moderator: merged posts, please use the edit button instead of double posting.