Tweak dwarfish formula
Now boosts up to 20% at y=0
Formula constants are more visible
@@ -5,16 +5,19 @@ import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.tools.nbt.IModifierToolStack;
public class DwarfishModifier extends Modifier {
+ /** Baseline height where boost is 1 */
+ private static final int SEA_LEVEL = 64;
+ /** Max bonus per level when y = 0 */
+ private static final float BOOST_AT_0 = 0.2f;
+
public DwarfishModifier() {
super(0xed9f07);
}
@Override
public void onBreakSpeed(IModifierToolStack tool, int level, BreakSpeed event) {
- int y = event.getPos().getY();
- // formula means at level 1, we get a 33% boost at y=10, and no boost at or above level 75
- // by level 3, its a 100% boost at y=10
- float factor = Math.max(1f, (75 - y) * (level / 195f) + 1);
+ // essentially just the line slope formula from (0, level + 1) to (SEA_LEVEL, 1), with a scal
+ float factor = Math.max(1f, (SEA_LEVEL - event.getPos().getY()) * level * (BOOST_AT_0 / SEA_LEVEL) + 1);
if (factor > 1f) {
event.setNewSpeed(event.getNewSpeed() * factor);
}
