CleverNucleus / data-attributes

Minecraft Fabric mod that overhauls the entity attributes system and exposes it with datapacks.
MIT License
12 stars 15 forks source link

[Request] Multiply based Attribute Functions #23

Closed demisys closed 1 year ago

demisys commented 2 years ago

Not sure if there's a better way to do this in the mod already, but I made a fork for my personal use with PlayerEx to re-balance attack damage and attack speed gain when levelling strength/dexterity. https://github.com/demisys/Data-Attributes/tree/multiply.function

I added FunctionBehaviour to attributes that determines if it's added to other attributes (as it currently does) with ADD, or multiples the attribute (for example +1% attack damage per strength level instead of +0.25 attack damage per strength level) with MULTIPLY.

The way I got it working is by making an intermediate melee_damage attribute that has "functionBehaviour": "MULTIPLY" defined. Then the PlayereEx strength attribute increases melee_damage by 0.01, and melee_damage increases generic.attack_damage by 1.0. I did a similar thing with attack_speed.

With my custom datapack and .jar build, level 50 strength will give +50% melee damage applied after Sharpness/Strength/RelicEx bonuses, instead of adding on a flat +12.5 attack damage. I'm still testing out the exact % gain per level for good balance, but so far it makes slow and high damage weapons not fall behind as much in dps compared to fast weapons.

data/playerex/attributes/overrides/melee_damage.json

{
  "fallbackValue": 0.0,
  "minValue": -10.0,
  "maxValue": 10.0,
  "incrementValue": 0.01,
  "translationKey": "attribute.name.generic.attack_damage",
  "stackingBehaviour": "FLAT",
  "functionBehaviour": "MULTIPLY"
}

functions.json

    "playerex:strength": {
      "playerex:melee_damage": 0.01,
      "minecraft:generic.armor": 0.5,
      "playerex:health_regeneration": 0.01
    },
    "playerex:melee_damage": {
      "minecraft:generic.attack_damage": 1.0
    },

Let me know if this is something that's good for the mod and if I should make a PR.

CleverNucleus commented 2 years ago

Hi there, I just wanted to let you know that I have read this, and I'm putting a pin here for later but I will come back to it. I've been thinking about your post for a few days now and would like to consider what you have written for a bit longer before taking any action. Thanks.

CleverNucleus commented 1 year ago

As of Data Attributes 1.3.0 for 1.18.2 and 1.4.0 for 1.19.2, multiply-type functions are now a feature. The implementation differs slightly to how you have proposed, but offers essentially the same functionality.

Documentation to come.