Interface LevelScaling
- All Known Implementing Classes:
ConstantScaling,DiminishingScaling,ExponentialScaling,LinearScaling,SteppedScaling
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for calculating scaled values from enchantment levels.
Scaling formulas determine how enchantment effects grow with level. Common patterns include linear growth (like Sharpness), exponential growth, or diminishing returns for high-level enchantments.
Built-in Formulas:
linear(double, double)- Constant increment per level (Sharpness-style)exponential(double, double)- Percentage growth per leveldiminishing(double, double)- Approach a maximum asymptoticallyconstant(double)- Same value at all levelsstepped(java.util.Map)- Custom values at specific levels with interpolation
Custom Formulas:
LevelScaling custom = LevelScaling.of(level -> level * level * 0.5);
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondoublecalculate(int level) Calculates the scaled value for a given enchantment level.static @NotNull LevelScalingconstant(double value) Creates constant scaling: same value at all levels.static @NotNull LevelScalingdiminishing(double maxValue, double scalingFactor) Creates diminishing scaling: maxValue * (level / (level + factor)).static @NotNull LevelScalingexponential(double base, double multiplier) Creates exponential scaling: base * multiplier^(level - 1).static @NotNull LevelScalinglinear(double base, double increment) Creates linear scaling: base + (level - 1) * increment.static @NotNull LevelScalingCreates a scaling from a custom function.static @NotNull LevelScalingCreates stepped scaling with interpolation between defined levels.
-
Method Details
-
calculate
double calculate(int level) Calculates the scaled value for a given enchantment level.- Parameters:
level- the enchantment level (>= 1)- Returns:
- the calculated value
- Throws:
IllegalArgumentException- if level is invalid- Since:
- 0.1.0
-
of
Creates a scaling from a custom function.- Parameters:
formula- the formula function (level -> value)- Returns:
- a LevelScaling wrapping the function
- Since:
- 0.1.0
-
linear
Creates linear scaling: base + (level - 1) * increment.Example: Sharpness-style where each level adds constant damage.
- Parameters:
base- the value at level 1increment- the amount added per level- Returns:
- a linear scaling instance
- Since:
- 0.1.0
-
exponential
Creates exponential scaling: base * multiplier^(level - 1).Use with caution at high levels as values grow rapidly.
- Parameters:
base- the value at level 1multiplier- the growth factor per level (1.0 = no growth)- Returns:
- an exponential scaling instance
- Since:
- 0.1.0
-
diminishing
Creates diminishing scaling: maxValue * (level / (level + factor)).Values approach maxValue asymptotically. Higher factor means slower approach to the maximum.
- Parameters:
maxValue- the asymptotic maximum valuescalingFactor- controls how quickly values approach max- Returns:
- a diminishing scaling instance
- Since:
- 0.1.0
-
constant
Creates constant scaling: same value at all levels.- Parameters:
value- the constant value- Returns:
- a constant scaling instance
- Since:
- 0.1.0
-
stepped
Creates stepped scaling with interpolation between defined levels.Define exact values at specific levels. Values between steps are linearly interpolated. Values above the highest step use the max step value.
- Parameters:
steps- map of level -> value pairs (must include level 1)- Returns:
- a stepped scaling instance
- Since:
- 0.1.0
-