Adding Behaviour - CleverNucleus/data-attributes GitHub Wiki

An adding behaviour simply describes how two sources of an attribute will add together. Implemented with Data Attributes are FLAT and DIMINISHING, as follows:

FLAT

The FLAT adding behaviour describes normal addition and functions as:

current value + adding value = resultant value

For example, you have an Iron Helmet that provides +2 armor and an Iron Chestplate that provides +6. When added together you get 8 armor:

2 + 6 = 8

DIMINISHING

The DIMINISHING adding behaviour describes a non-linear addition function as:

max value * ((current value + adding value) / (max value + adding value)) = resultant value

and for subtraction

adding value + current value - (adding value * current value / max value) = resultant value

For example, you have an Iron Helmet that provides +2 armor and an Iron Chestplate that provides +6. When added together you get 6.67 armor:

30 * ((2 + 6) / (30 + 6)) = 6.67

This of course uses the attribute's maximum value as a limit - for armor this is by default 30. By default all vanilla attributes have a FLAT stacking behaviour.