Jump to content

Recommended Posts

Posted

Hi!

 

I'm trying to get an integer or double value from the current held item attack attribute, i've just found the way to get the base value from an entity using getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() but i need the value of every held item.

 

Any ideas?

 

Many thanks.

Posted

You can get a specific modifier by passing it the correct UUID - luckily, Item uses a static one for weapon damage:

AttributeModifier itemDamage = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.attackDamage).getModifier(itemDamageUUID);

Of course, with modded weapons, there is no guarantee the modder would use that, though they typically should. Not much you can do about those kinds of cases.

 

EDIT: Forgot to mention that the Item field is private, so I made a local public static copy (you could also use Reflection if you want):

/** Copy of Item#field_111210_e which is the UUID used to store weapon damage modifiers */
public static final UUID itemDamageUUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");

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.

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