Jump to content

[1.10.2] Changing item-use cooldown


Recommended Posts

I want to prevent all animations that happen when the left mouse button is pressed. The problem that I can't find a way to prevent the up-and down movement of the item when the item "recharges". The feature was introduced in 1.9 (I think) and is indicated with a little sword below the crosshair.


Edit: solved by overriding Item::getAttributeModifiers

public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
   Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);
   multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", 1024, 0));
   return multimap;



Link to comment
Share on other sites

If you put the item in the off-hand and back in the main-hand the cooldown is back until you switch to a different item (or update the stack somehow else) :/ Is there an event that is thrown when switching items between hands? Also the tooltip of the item now shows 1014 as attackspeed.


My second approach is to set the SharedMonsterAttributes.ATTACK_SPEED of the player as high as possible when the item is held because it is used to calculate attack speed of the player (EntityPlayer::getCooledAttackStrength) and then set it back to 4 when a different item is held. This is really hackey and exactly what I wanted to prevent by using the new rendering system but it's better than nothing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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