#How to add/modify damage for items

9 messages · Page 1 of 1 (latest)

pseudo rover
#
modifyTier(tier => ...) Same syntax as custom tool tier, see Custom Tiers
attackDamageBaseline(damage) You only want to modify this if you are creating a custom weapon such as Spear, Battleaxe, etc.
attackDamageBonus(damage)
speedBaseline(speed) Same as attackDamageBaseline, only modify for custom weapon types
speed(speed)```
using this information from the wiki, I was unable to add damage to any existing items (for example, diamond ones), items with damage like an iron sword are always created.
earnest crownBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

pseudo rover
#
    event.create("sword_n", "sword")
        .attackDamageBaseline(200.0)
        .texture("example:example")
})```
delicate kernel
#

I'll spread the gospel

#
let ItemAttrEvent = Java.loadClass("net.neoforged.neoforge.event.ItemAttributeModifierEvent");

const attackBonuses = {
  'minecraft:stone_sword': 5,
  // Add more items here:
  // 'modid:item_id': bonusDamage
};

NativeEvents.onEvent(ItemAttrEvent, event => {
  let itemId = event.itemStack.id;
  let bonus = attackBonuses[itemId];
  if (bonus == null) return;

  event.addModifier("minecraft:generic.attack_damage", {
    id: itemId + "_attack_mod",
    amount: bonus,
    operation: "add_value"
  }, "mainhand");
});

ItemEvents.modification(event => {
  for (let itemId in attackBonuses) {
    event.modify(itemId, item => {
      item.setDamage(item.get("damage") * 3);
      item.setMaxDamage(item.get("max_damage") * 3);
    });
  }
});
compact aspen
#

Also you should put this in #1048591172165189632 if you haven't already

delicate kernel
#

i did not write this shit

#

i asked the same question and this was just the answer that worked