CraftTweaker

CraftTweaker

151M Downloads

Global Attribute Modifiers disappear when item takes damage

averagemodenjoyer opened this issue ยท 1 comments

commented

Issue description

When an item takes damage, it's attributes revert back to default:

global_attributes_bug.mp4

Steps to reproduce

  1. Use the script below
  2. Equip a diamond sword
  3. Check damage value
  4. Break a block or hit an entity
  5. Check damage value again

Script used

https://gist.github.com/averagemodenjoyer/45ed48b3afde835ae863ac519cdc9951#file-gistfile1-txt

The crafttweaker.log file

https://gist.github.com/averagemodenjoyer/fbdef11796335aeb55a058b0d25c59cb#file-gistfile1-txt

Minecraft version

1.20.1

Modloader

Forge

Modloader version

47.3.0

CraftTweaker version

14.0.43

Other relevant information

Crafttweaker is the only mod used in this installation

The latest.log file

https://gist.github.com/averagemodenjoyer/00d71bccca145d6063059827b5a9ff7b#file-gistfile1-txt

commented

You will want to add a .anyDamage() call after the item, like so:

import crafttweaker.api.item.IItemStack;
import crafttweaker.api.entity.attribute.AttributeOperation;

<item:minecraft:diamond_sword>.anyDamage().addGlobalAttributeModifier(<attribute:minecraft:generic.attack_damage>, IItemStack.BASE_ATTACK_DAMAGE_UUID, "Extra Power", 6.5, AttributeOperation.ADDITION, [<constant:minecraft:equipmentslot:mainhand>]);
Comment