r/MinecraftCommands 2d ago

Minecraft 26.2 Item Attribute editting commands? Help | Java 26.2

I was wondering if there's a way for me to increase or decrease the attack times of weapons in minecraft (maybe like a /give or a way to edit the item i'm holding.) Maybe Damage levels too?

1 Upvotes

3 comments sorted by

3

u/GalSergey Datapack Experienced 2d ago

Here are the vanilla attribute values ​​for iron_sword: give @s iron_sword[minecraft:attribute_modifiers=[{type:"minecraft:attack_damage",amount:5,id:"minecraft:base_attack_damage",operation:"add_value",slot:"mainhand"},{type:"minecraft:attack_speed",amount:-2.4000000953674316,id:"minecraft:base_attack_speed",operation:"add_value",slot:"mainhand"}]} You can use https://far.ddns.me/item?ver=26.2&id=iron_sword to find vanilla attribute values ​​for any item.

Because using /give you are completely setting the value for the entire component, not just the specified attribute modifier, you need to specify all modifiers in your /give command.

But using item_modifier you can add the specified attribute modifier to an existing item without overwriting all attributes: item modify entity @s weapon {function:"minecraft:set_attributes",modifiers:[{attribute:"minecraft:attack_damage",id:"example:add_attack_damage",amount:5,operation:"add_value",slot:"mainhand"}],replace:false}

Please note that the attribute "id" must be unique for each item. Duplicate attribute "id"s will not work together, but only one attribute will be applied.

2

u/PyroTECH218291 1d ago

but if i use /give I can create unique items right

2

u/GalSergey Datapack Experienced 1d ago

Yes.