Fix overlord removing too much durabilty on broad tools
@@ -14,20 +14,20 @@ public class OverlordModifier extends Modifier {
}
/** Gets the durability boost per level */
- private int getBoost(ToolDefinition definition, StatsNBT stats, int level, float perLevel) {
- return (int)(stats.getDurability() * definition.getBaseStatDefinition().getDurabilityModifier() * perLevel * level);
+ private int getBoost(StatsNBT baseStats, int level, float perLevel) {
+ return (int)(baseStats.getDurability() * perLevel * level);
}
@Override
public void addVolatileData(ToolDefinition toolDefinition, StatsNBT baseStats, IModDataReadOnly persistentData, int level, ModDataNBT volatileData) {
volatileData.putBoolean(OverslimeModifier.KEY_OVERSLIME_FRIEND, true);
- // gains +15% of the durability per level
- OverslimeModifier.addCap(toolDefinition, volatileData, getBoost(toolDefinition, baseStats, level, 0.10f));
+ // gains +15% of the durability per level, note that base stats does not consider the durability modifier
+ OverslimeModifier.addCap(toolDefinition, volatileData, getBoost(baseStats, level, 0.10f * toolDefinition.getBaseStatDefinition().getDurabilityModifier()));
}
@Override
public void addToolStats(ToolDefinition toolDefinition, StatsNBT baseStats, IModDataReadOnly persistentData, IModDataReadOnly volatileData, int level, ModifierStatsBuilder builder) {
- // at most subtract 90% durability
- builder.addDurability(-getBoost(toolDefinition, baseStats, Math.min(level, 6), 0.15f));
+ // at most subtract 90% durability, note this runs before the tool durability modifier
+ builder.addDurability(-getBoost(baseStats, Math.min(level, 6), 0.15f));
}
}
