Jump to content

[1.12.2] How to alter Item attributes (attack damage, etc)


Recommended Posts

Posted

I can't for the life of me figure this out:

 

I essentially want to alter the base attack damage on items as such: Example: Wooden sword is in players hand, upon some event, the base attack of 4 (as shown on the grey text in the default vanilla item lore) increases to 4.5, or 5, or whatever. WITHOUT changing the other attributes, such as attack speed (currently i found a way to somehow change the attack damage, but only by resetting all the NBT tags of the item, which removes the attack speed) Also this changes the way the text is shown on the item, it changes it from teh default grey text to the blue ones.

 

Anyway, whats the correct way to do this, here is what i currently tried:

 

Object[] dmg = (upgradeItem.getAttributeModifiers(EntityEquipmentSlot.MAINHAND).get((SharedMonsterAttributes.ATTACK_DAMAGE).getName())).toArray();
NBTTagCompound attackBoost = new NBTTagCompound();
			attackBoost.setInteger("generic.attackDamage", 10);
			upgradeItem.setTagCompound(attackBoost);
			upgradeItem.addAttributeModifier((SharedMonsterAttributes.ATTACK_DAMAGE).getName(),
			 new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier",
					 ((AttributeModifier) dmg[0]).getAmount()+0.5D, 0),
			 EntityEquipmentSlot.MAINHAND);

 

 

Idk what im doing with this so sorry if its horribly screwed up, ive been trying to make this work for over 12h and my brains fried... 

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.