Jump to content

Recommended Posts

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?

Posted

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?

Posted

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).

Posted

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...
Posted
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.

Announcements



×
×
  • Create New...

Important Information

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