public void itemAttributeModifier(ItemAttributeModifierEvent event) {
ItemStack stack = event.getItemStack();
Item item = stack.getItem();
if (item == Items.DIAMOND_SWORD) {
stack.addAttributeModifier(Attributes.ATTACK_DAMAGE, new AttributeModifier("damage", 1.0D, AttributeModifier.Operation.MULTIPLY_BASE), EquipmentSlotType.MAINHAND);
}
}
It continues to call the addAttributeModifier infinitely. In game, the tooltip ends up just overflowing with attribute modifiers.
Well, I'm not sure if I'm being stupid, but the ItemAttributeModifierEvent is obviously an event executed every tick, so it just adds the attribute modifier over and over again.
Sorry for late reply, but is there a way to specifically set the item's attack damage with this? I see that you can use addAttributeModifier but that is not as practical, especially for my case.
Would this change the damage value of the sword that is displayed in the tooltip as well? Like this:
I want to literally be able to change its attack damage value.
I want to be able to change how much damage the diamond sword does in my mod. I know that I need to use reflections to accomplish this, but I'm not sure exactly how, and I've been trying for hours. Can someone possibly tell me how to write a reflection that can do this? I'm aware that this is not a Java school but this is my last resort.
8 replies
Important Information
By using this site, you agree to our Terms of Use.