Spartan Weaponry

Spartan Weaponry

34M Downloads

Traits are added to melee weapons' tooltips unconditionally

KreloX opened this issue ยท 2 comments

commented

When I set up a RangedCallbackWeaponTrait without any other callbacks added and only calling setRanged, all weapons render the trait in their tooltips. The expected behavior would be only the longbows and heavy crossbows rendering it. Note that I encountered this on 1.18.2 and I don't know if it was already fixed on newer versions.

I would also suggest removing the setMelee, setThrowing,... methods in favor of just checking for the respective callbacks as the way it is now is very unintuitive.

commented

Thanks for this report as well and for contributing to making addon mods for this one! It's very appreciated.
I've made some changes to how Weapon Traits, especially one attached to WeaponMaterial classes operate. They now should not show up on weapons that they don't apply to now.
So traits marked as Ranged will only show up on Longbows and Heavy Crossbows, for example.

I've also made it so when checking if the trait is a Melee, Ranged, Throwing or Action trait, it checks to see if the callback for each of them is present, so you shouldn't need to manually set the setMelee(), setRanged(), setThrowing(), or setAction() methods anymore.
I can't remove those methods due to a risk of a breaking change, but I have made the setAction() method and it's respective field isAction deprecated, since neither do anything anymore. It is the only one that is required to have a callback.
The other ones can still be manually set since some of my traits don't need specialized classes e.g. the Armor Piercing trait since that it's presence is checked externally and doesn't need a callback for anything.

Those changes will be in the next release, provided they don't break anything. I'll test it with your addon mods soon.

commented

As I've mentioned before, I tested your addon mods with the new version of this one and there don't seem to be any issues that I could see.
Thanks for reporting these issues.
Closing issue