Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Just wanted to check that there is no method like onItemUse() or onItemRightClick() for the left mouse click which would give me a remote world. I want to replace the breaking behavior for left mouse click for my Item. Currently I am subscribing to MouseEvents and messaging to the server from the client thread. Does 1.8 offer any new ways to do this?

  • Author

I think I abandoned using this event a while back because there was no PlayerInteractEvent.Action.LEFT_CLICK_AIR and I couldn't find a way to stop the break sound and animation on Action.LEFT_CLICK_BLOCK. Is there a way to do this?

 

Is there an event fired when left clicking on air which will give me a remote world?

  • Author

Sweet! :)

 

Now if I could only stop that break sound and animation on Action.LEFT_CLICK_BLOCK.

You may be able to prevent the sound using

event.useBlock = Result.DENY;

 

But you will have to actually intercept the MouseEvent and cancel that if you want to prevent the arm swing animation, and then you'd have to call your Item methods manually (which involves sending packets to the server, since MouseEvent is client side only).

  • Author

Actually, I'm no longer getting the arm swing animation. Its the block break animation that I am still getting - the little puff of dust.

 

No luck with event.useBlock = Result.DENY.

  • 1 year later...
On 11.6.2015 at 3:23 AM, coolAlias said:

You may be able to prevent the sound using


event.useBlock = Result.DENY;
 

This does not work on this type of event because it is not implemented.

I do have subscriped the following method in my item class:

 

@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onEvent(PlayerInteractEvent.LeftClickEmpty event) {
    //This is always called when the player attacks

    if (getItemIsHoldinHand().equals(ItemHoldInHand.NONE)) {
        //Do nothing if it is not hold
        return;
    }

    //Check if the attack can be handled
    if (this instanceof AttackItem) { //interface with the onAttack method
        ((AttackItem) this).attackClicked(event.getEntityPlayer(), event.getWorld(),
                event.getEntityLiving(),event.getEntity());
        try{
            event.setCanceled(true);
        }catch(IllegalArgumentException illegalArgument){
            LOGGER.log(Level.INFO, "Could not cancel event will try to set other parameters");
            event.setResult(Event.Result.DENY);
            event.setPhase(EventPriority.LOWEST);
            
        }
    }


Overriding following method in your CustomItem

 

@Override
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {
    return true; //Handled to do not a swing
}

 

Will just stop doing a swing, when clicking a Block (mining it) but will do a swing when in LeftClick.Empty....

I will try more

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.