【bug】Cannot modify weapon damage
blood789 opened this issue · 5 comments
Minecraft Version
1.18.2
KubeJS Version
kubejs-forge-1802.5.1-build.363.jar
Rhino Version
rhino-forge-1801.1.9-build.135.jar
Architectury Version
architectury-4.3.53.jar
Forge/Fabric Version
FORGE-40.1.0
Describe your issue
I Cannot modify weapon damage, I write as this.
onEvent('item.modification', event => {
event.modify('minecraft:diamond_sword', item => {
item.tier = tierOptions => {
tierOptions.attackDamageBonus = 20
}
})
})
BUT it doesn't work. I found some posts on the Internet, and it also mentioned that the function of modifying weapon attributes is invalid. Do I write in a wrong way, or is there a bug?
Can you give some example ? Thanks
Crash report/logs
No response
I can add to this issue that my script goes like this:
onEvent('item.modification', event => {
event.modify('minecraft:diamond_sword', sword => {
sword.setMaxDamage(9999);
sword.setFireResistant(true);
sword.setTier(tier => {
tier.setSpeed(1.6);
tier.setAttackDamageBonus(99.0);
tier.setLevel(5);
tier.setEnchantmentValue(99);
});
});
});
As discussed with MaxNeedsSnacks previously, setMaxDamage and setFireResistant do work as intended, but the entire tier consumer does not. I've checked the source code and I think this is the right way to write it in 1.18.2, however it is not working
The problem is probably still the same: Mojang being Mojang.
The sword constructor calculates the damage, stores it into a variable and also stores it into the AttributeModifiers. Changing the tier of the sword, changes the tier value but it does not change/reset the AttributeModifiers for the damage and the internal variable in the sword class. Same for attack speed.
Hmm I see. I just want to add a precision in case that sword.setMaxDamage(9999);
is meant to modify the durability of the tool and it does
I can add to this issue that my script goes like this:
onEvent('item.modification', event => { event.modify('minecraft:diamond_sword', sword => { sword.setMaxDamage(9999); sword.setFireResistant(true); sword.setTier(tier => { tier.setSpeed(1.6); tier.setAttackDamageBonus(99.0); tier.setLevel(5); tier.setEnchantmentValue(99); }); }); });
As discussed with MaxNeedsSnacks previously, setMaxDamage and setFireResistant do work as intended, but the entire tier consumer does not. I've checked the source code and I think this is the right way to write it in 1.18.2, however it is not working
I try you method and write as the same as you, but I can not change the attack damage.
The attack damage of diamond_sword is still 7.......
MaxDamage is use to modify the durability of the tool and weapon, and this can change Correctly.
But attack damage and the EnchantmentValue and tool level ...maybe BUG.
Should have been fixed by #386