DrMod Icon

DrMod Documentation

A comprehensive .NET 8 library for analyzing, validating, and managing Minecraft mods across Forge, NeoForge, Fabric, and Quilt platforms.

Latest Version: 2.0.0

DrMod Library Overview

DrMod is a powerful .NET 8 library designed to simplify the analysis, validation, and management of Minecraft mods. It supports all major mod loaders including Forge, NeoForge, Fabric, and Quilt, providing developers and server administrators with comprehensive tools for mod ecosystem management.

Key Features

  • Multi-Platform Support: Works with Forge, NeoForge, Fabric, and Quilt mods
  • Comprehensive Validation: Detect conflicts, missing dependencies, and compatibility issues
  • Metadata Extraction: Parse mod metadata from JAR files and configuration files
  • Dependency Analysis: Build complete dependency trees and identify circular dependencies
  • Crash Report Analysis: Identify problematic mods from crash reports
  • Performance Optimized: Built for speed with async/await patterns

Installation

1Install via NuGet Package Manager

Use the Package Manager Console in Visual Studio:

Install-Package DrMod

2Install via .NET CLI

Use the command line interface:

dotnet add package DrMod

3Add PackageReference

Add directly to your .csproj file:

<PackageReference Include="DrMod" Version="2.0.0" />

Requirements

  • .NET 8.0 or later
  • Windows, macOS, or Linux
  • Visual Studio 2022 or VS Code (recommended)

Basic Usage

Creating an Analyzer

Start by creating a DrMod analyzer instance:

using DrMod;

var analyzer = new DrMod();

Quick Start

Get started with DrMod in just a few lines of code:

using DrMod;

var analyzer = new DrMod();

// Analyze a single mod
var metadata = analyzer.ReadModMetadata(@"C:\mods\example-mod.jar");
Console.WriteLine($"Mod: {metadata.name} v{metadata.modVersion}");

Async Usage

DrMod supports asynchronous operations for better performance:

using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var analyzer = new DrMod();
        // Use async methods for better performance
        var results = await analyzer.ValidateModsFolderAsync(@"C:\mods");
    }
}

API Reference with Examples

Java Detection Methods

GetRequiredJavaVersion(string modPath)

Returns: int

Get the required Java version for a mod (e.g., 8, 17, 21).

Example Usage

var javaVersion = analyzer.GetRequiredJavaVersion(@"C:\mods\jei.jar");
Console.WriteLine($"JEI requires Java {javaVersion}+");

FindRequiredJavaVersion(string modPath)

Returns: string

Find the path to a suitable JDK for the mod's requirements.

Example Usage

var jdkPath = analyzer.FindRequiredJavaVersion(@"C:\mods\jei.jar");
if (jdkPath != null)
    Console.WriteLine($"Found suitable JDK at: {jdkPath}");
else
    Console.WriteLine("No suitable JDK found for this mod's requirements.");

Performance & Resource Analysis Methods

GetModFileSize(string modPath)

Returns: long

Get the file size of a mod in bytes.

Example Usage

var fileSize = analyzer.GetModFileSize(@"C:\mods\jei.jar");
Console.WriteLine($"JEI file size: {fileSize / (1024 * 1024)} MB");

// Batch check sizes
var mods = Directory.GetFiles(@"C:\mods", "*.jar");
Console.WriteLine("Mod file sizes:");
foreach (var mod in mods)
{
    var size = analyzer.GetModFileSize(mod);
    var name = Path.GetFileNameWithoutExtension(mod);
    Console.WriteLine($"  {name}: {size / (1024 * 1024)} MB");
}

GetModsByMemoryUsage(string folderPath, bool sortDescending = true)

Returns: List<ModMetadata>

Get all mods in a folder sorted by estimated memory usage.

Example Usage

var modsByMemory = analyzer.GetModsByMemoryUsage(@"C:\mods", true);
Console.WriteLine("Mods sorted by memory usage (heaviest first):");

foreach (var mod in modsByMemory.Take(10))
{
    var perfInfo = analyzer.GetModPerformanceInfo(@"C:\mods\" + mod.modFileName);
    Console.WriteLine($"  {mod.name}: {perfInfo.EstimatedMemoryUsageMB} MB ({perfInfo.PerformanceCategory})");
}

DetectPerformanceImpactingMods(string folderPath)

Returns: List<string>

Detect mods that may have performance impact.

Example Usage

var heavyMods = analyzer.DetectPerformanceImpactingMods(@"C:\mods");

if (heavyMods.Count > 0)
{
    Console.WriteLine($"āš ļø Found {heavyMods.Count} performance-impacting mods:");
    foreach (var modId in heavyMods)
    {
        var mod = analyzer.GetModById(modId, @"C:\mods");
        Console.WriteLine($"  - {mod?.name ?? modId}");
    }
    Console.WriteLine("\nšŸ’” Consider reviewing these mods if experiencing performance issues.");
}

GetModPerformanceInfo(string modPath)

Returns: PerformanceInfo

Get detailed performance information for a mod.

Example Usage

var perfInfo = analyzer.GetModPerformanceInfo(@"C:\mods\create.jar");
Console.WriteLine($"=== Performance Analysis: {perfInfo.ModName} ===");
Console.WriteLine($"File Size: {perfInfo.FileSizeBytes / (1024 * 1024)} MB");
Console.WriteLine($"Estimated Memory: {perfInfo.EstimatedMemoryUsageMB} MB");
Console.WriteLine($"Performance Category: {perfInfo.PerformanceCategory}");

if (perfInfo.PerformanceWarnings.Count > 0)
{
    Console.WriteLine("Warnings:");
    foreach (var warning in perfInfo.PerformanceWarnings)
    {
        Console.WriteLine($"  āš ļø {warning}");
    }
}

Metadata & Validation Methods

ReadModMetadata(string filePath)

Returns: ModMetadata

Read metadata from a mod JAR file or metadata configuration file.

Example Usage

// Reading from a JAR file
var metadata = analyzer.ReadModMetadata(@"C:\mods\jei-1.20.1-15.2.0.27.jar");
if (metadata != null)
{
    Console.WriteLine($"Mod ID: {metadata.modId}");
    Console.WriteLine($"Name: {metadata.name}");
    Console.WriteLine($"Version: {metadata.modVersion}");
    Console.WriteLine($"Loader: {metadata.loader}");
}

// Reading from a metadata file directly
var fabricMeta = analyzer.ReadModMetadata(@"C:\fabric.mod.json");
var forgeMeta = analyzer.ReadModMetadata(@"C:\META-INF\mods.toml");

ReadAllModMetadataInFolder(string folderPath)

Returns: List<ModMetadata>

Read metadata for all mods in a folder.

Example Usage

var allMods = analyzer.ReadAllModMetadataInFolder(@"C:\Minecraft\mods");
Console.WriteLine($"Found {allMods.Count} mods:");

foreach (var mod in allMods)
{
    Console.WriteLine($"- {mod.name} ({mod.modId}) v{mod.modVersion} [{mod.loader}]");
}

// Filter by specific criteria
var forgeMods = allMods.Where(m => m.loader == "Forge").ToList();
var fabricMods = allMods.Where(m => m.loader == "Fabric").ToList();

ValidateMod(string modPath)

Returns: List<string>

Validate a single mod and return a list of validation errors.

Example Usage

var errors = analyzer.ValidateMod(@"C:\mods\examplemod.jar");

if (errors.Count == 0)
{
    Console.WriteLine("āœ… Mod is valid!");
}
else
{
    Console.WriteLine("āŒ Mod validation errors:");
    foreach (var error in errors)
    {
        Console.WriteLine($"  - {error}");
    }
}
āŒ Mod validation errors:
- Missing modId
- Missing Minecraft version
- Duplicate required dependency: forge

ValidateModsFolder(string folderPath)

Returns: List<string>

Validate all mods in a folder and detect folder-wide issues.

Example Usage

var folderErrors = analyzer.ValidateModsFolder(@"C:\Minecraft\mods");

if (folderErrors.Count == 0)
{
    Console.WriteLine("āœ… All mods in folder are valid!");
}
else
{
    Console.WriteLine($"āŒ Found {folderErrors.Count} issues:");
    foreach (var error in folderErrors)
    {
        Console.WriteLine($"  {error}");
    }
}
āŒ Found 3 issues:
[badmod.jar] Missing modId
Duplicate modId detected: jei
Multiple Minecraft versions detected in mods folder: 1.20.1, 1.19.4
[modA] is incompatible with [modB]

Mod Health & Corruption Detection

FindCorruptedMods(string folderPath)

Returns: List<string>

Find corrupted mod files that can't be read or have invalid metadata.

Example Usage

var corruptedMods = analyzer.FindCorruptedMods(@"C:\mods");

if (corruptedMods.Count > 0)
{
    Console.WriteLine($"šŸ”“ Found {corruptedMods.Count} corrupted mods:");
    foreach (var corruptedMod in corruptedMods)
    {
        Console.WriteLine($"  - {Path.GetFileName(corruptedMod)}");
    }
    Console.WriteLine("\nšŸ’” Consider re-downloading these mods.");
}
else
{
    Console.WriteLine("āœ… No corrupted mods detected!");
}

RepairMod(string modPath)

Returns: bool

Attempt to repair a corrupted mod.

Example Usage

var corruptedMods = analyzer.FindCorruptedMods(@"C:\mods");
foreach (var corruptedMod in corruptedMods)
{
    Console.WriteLine($"Attempting to repair: {Path.GetFileName(corruptedMod)}");
    bool repaired = analyzer.RepairMod(corruptedMod);
    
    if (repaired)
        Console.WriteLine("  āœ… Repair successful!");
    else
        Console.WriteLine("  āŒ Repair failed - consider re-downloading");
}

World/Save Compatibility

IsModSafeToRemove(string modId, string folderPath)

Returns: bool

Check if a mod is safe to remove (no other mods depend on it).

Example Usage

string modToRemove = "optifine";
bool isSafe = analyzer.IsModSafeToRemove(modToRemove, @"C:\mods");

if (isSafe)
{
    Console.WriteLine($"āœ… {modToRemove} is safe to remove - no dependencies");
}
else
{
    var dependents = analyzer.GetDependents(modToRemove, @"C:\mods");
    Console.WriteLine($"āš ļø {modToRemove} is required by {dependents.Count} other mods:");
    foreach (var dependent in dependents)
    {
        Console.WriteLine($"  - {dependent}");
    }
}

GetWorldRequiredMods(string worldPath)

Returns: List<string>

Get list of required mods for a world/save.

Example Usage

var requiredMods = analyzer.GetWorldRequiredMods(@"C:\Minecraft\saves\MyWorld");

Console.WriteLine($"World requires {requiredMods.Count} mods:");
foreach (var modId in requiredMods)
{
    Console.WriteLine($"  - {modId}");
}

// Check if current mods satisfy world requirements
var installedMods = analyzer.ReadAllModMetadataInFolder(@"C:\mods")
    .Select(m => m.modId).Where(id => !string.IsNullOrEmpty(id)).ToHashSet();

var missingMods = requiredMods.Where(mod => !installedMods.Contains(mod)).ToList();
if (missingMods.Count > 0)
{
    Console.WriteLine($"\nāŒ Missing {missingMods.Count} required mods for this world!");
}

CheckWorldCompatibility(string worldPath, string modsFolder)

Returns: WorldCompatibilityResult

Check compatibility between a world and current mod setup.

Example Usage

var compatibility = analyzer.CheckWorldCompatibility(@"C:\Minecraft\saves\MyWorld", @"C:\mods");

Console.WriteLine($"=== World Compatibility Report ===");
Console.WriteLine($"Compatible: {(compatibility.IsCompatible ? "āœ… YES" : "āŒ NO")}");
Console.WriteLine($"Minecraft Version: {compatibility.MinecraftVersion}");
Console.WriteLine($"Mod Loader: {compatibility.ModLoader}");

if (compatibility.MissingMods.Count > 0)
{
    Console.WriteLine($"\nMissing Mods ({compatibility.MissingMods.Count}):");
    foreach (var mod in compatibility.MissingMods)
    {
        Console.WriteLine($"  - {mod}");
    }
}

if (compatibility.Warnings.Count > 0)
{
    Console.WriteLine($"\nWarnings:");
    foreach (var warning in compatibility.Warnings)
    {
        Console.WriteLine($"  āš ļø {warning}");
    }
}

Modpack Management

ImportModPack(string modPackPath, string destinationPath)

Returns: bool

Import a modpack from .mrpack (Modrinth) or .zip (CurseForge) file.

Example Usage

// Import Modrinth modpack
bool success = analyzer.ImportModPack(@"C:\Downloads\mypack.mrpack", @"C:\mods");
if (success)
{
    Console.WriteLine("āœ… Modrinth modpack imported successfully!");
}

// Import CurseForge modpack
success = analyzer.ImportModPack(@"C:\Downloads\cursepack.zip", @"C:\mods");
if (success)
{
    Console.WriteLine("āœ… CurseForge modpack imported successfully!");
}
else
{
    Console.WriteLine("āŒ Failed to import modpack");
}

// Validate imported mods
var errors = analyzer.ValidateModsFolder(@"C:\mods");
Console.WriteLine($"Imported modpack validation: {(errors.Count == 0 ? "āœ… Success" : $"āŒ {errors.Count} issues")}");

DisableMod(string modPath)

Returns: bool

Disable a mod by renaming it to .disabled extension.

Example Usage

string modToDisable = @"C:\mods\problematic-mod.jar";
bool disabled = analyzer.DisableMod(modToDisable);

if (disabled)
{
    Console.WriteLine($"āœ… Mod disabled: {Path.GetFileName(modToDisable)}.disabled");
}
else
{
    Console.WriteLine($"āŒ Failed to disable mod (already disabled or file not found)");
}

// Batch disable performance-heavy mods
var heavyMods = analyzer.DetectPerformanceImpactingMods(@"C:\mods");
foreach (var modId in heavyMods)
{
    var modFile = Directory.GetFiles(@"C:\mods", "*.jar")
        .FirstOrDefault(f => analyzer.ReadModMetadata(f)?.modId == modId);
    
    if (modFile != null)
    {
        analyzer.DisableMod(modFile);
        Console.WriteLine($"Disabled heavy mod: {Path.GetFileName(modFile)}");
    }
}

EnableMod(string disabledModPath)

Returns: bool

Enable a disabled mod by removing the .disabled extension.

Example Usage

// Find all disabled mods
var disabledMods = Directory.GetFiles(@"C:\mods", "*.disabled");
Console.WriteLine($"Found {disabledMods.Length} disabled mods:");

foreach (var disabledMod in disabledMods)
{
    Console.WriteLine($"  - {Path.GetFileName(disabledMod)}");
    
    // Ask user or apply logic to determine which to enable
    bool shouldEnable = true; // Your logic here
    
    if (shouldEnable)
    {
        bool enabled = analyzer.EnableMod(disabledMod);
        if (enabled)
        {
            Console.WriteLine($"    āœ… Re-enabled!");
        }
        else
        {
            Console.WriteLine($"    āŒ Failed to enable (target file may already exist)");
        }
    }
}

Compatibility & Conflict Detection Methods

IsCompatible(string modPath, string mcVersion, string loader, string loaderVersion)

Returns: bool

Check if a mod is compatible with specific game/loader versions.

Example Usage

// Check compatibility with specific versions
bool isCompatible = analyzer.IsCompatible(
    @"C:\mods\jei.jar",
    mcVersion: "1.20.1",
    loader: "Forge",
    loaderVersion: "47.1.0"
);

Console.WriteLine($"JEI is compatible: {isCompatible}");

// Batch check multiple mods
var mods = Directory.GetFiles(@"C:\mods", "*.jar");
var targetMC = "1.20.1";
var targetLoader = "Forge";
var targetLoaderVer = "47.1.0";

foreach (var mod in mods)
{
    var compatible = analyzer.IsCompatible(mod, targetMC, targetLoader, targetLoaderVer);
    var modName = Path.GetFileNameWithoutExtension(mod);
    Console.WriteLine($"{modName}: {(compatible ? "āœ…" : "āŒ")}");
}

DetectConflicts(List<string> modPaths)

Returns: List<string>

Detect duplicate mod IDs in a list of mod files.

Example Usage

var modFiles = Directory.GetFiles(@"C:\mods", "*.jar").ToList();
var conflicts = analyzer.DetectConflicts(modFiles);

if (conflicts.Count > 0)
{
    Console.WriteLine("šŸ”“ Conflicting mods detected:");
    foreach (var conflict in conflicts)
    {
        Console.WriteLine($"  Duplicate mod ID: {conflict}");
        // Find which files have the same ID
        var conflictingFiles = modFiles.Where(f => 
        {
            var meta = analyzer.ReadModMetadata(f);
            return meta?.modId == conflict;
        });
        foreach (var file in conflictingFiles)
        {
            Console.WriteLine($"    - {Path.GetFileName(file)}");
        }
    }
}

DetectIncompatibilities(List<string> modPaths)

Returns: List<(string, string)>

Detect explicit incompatibilities between mods.

Example Usage

var modFiles = Directory.GetFiles(@"C:\mods", "*.jar").ToList();
var incompatibilities = analyzer.DetectIncompatibilities(modFiles);

if (incompatibilities.Count > 0)
{
    Console.WriteLine("āš ļø Incompatible mods detected:");
    foreach (var (modId, incompatibleWith) in incompatibilities)
    {
        Console.WriteLine($"  {modId} is incompatible with {incompatibleWith}");
    }
    Console.WriteLine("\nšŸ’” Consider removing one mod from each incompatible pair.");
}

Dependency Analysis Methods

GetRequiredDependencies(string modPath)

Returns: List<string>

Get required dependencies for a mod.

Example Usage

var requiredDeps = analyzer.GetRequiredDependencies(@"C:\mods\jei.jar");

Console.WriteLine("Required dependencies:");
foreach (var dep in requiredDeps)
{
    Console.WriteLine($"  - {dep}");
}
Required dependencies:
- forge
- minecraft

GetOptionalDependencies(string modPath)

Returns: List<string>

Get optional dependencies for a mod.

Example Usage

var optionalDeps = analyzer.GetOptionalDependencies(@"C:\mods\jei.jar");

Console.WriteLine("Optional dependencies:");
foreach (var dep in optionalDeps)
{
    Console.WriteLine($"  - {dep}");
}

GetIncompatibilities(string modPath)

Returns: List<string>

Get explicit incompatibilities for a mod.

Example Usage

var incompatibilities = analyzer.GetIncompatibilities(@"C:\mods\optifine.jar");

if (incompatibilities.Count > 0)
{
    Console.WriteLine("āš ļø This mod is incompatible with:");
    foreach (var inc in incompatibilities)
    {
        Console.WriteLine($"  - {inc}");
    }
}

GetAllDependencies(string modPath, bool includeOptional = false)

Returns: List<string>

Recursively get all (transitive) dependencies for a mod.

Example Usage

// Get only required dependencies (including transitive)
var allRequired = analyzer.GetAllDependencies(@"C:\mods\complexmod.jar", false);

// Get all dependencies including optional ones
var allDeps = analyzer.GetAllDependencies(@"C:\mods\complexmod.jar", true);

Console.WriteLine($"Total required dependencies: {allRequired.Count}");
Console.WriteLine($"Total dependencies (inc. optional): {allDeps.Count}");

Console.WriteLine("\nFull dependency tree:");
foreach (var dep in allDeps)
{
    Console.WriteLine($"  - {dep}");
}

GetDependents(string modId, string folderPath)

Returns: List<string>

Get all mods that depend on a given mod.

Example Usage

var dependents = analyzer.GetDependents("jei", @"C:\mods");

Console.WriteLine($"Mods that depend on JEI ({dependents.Count}):");
foreach (var dependent in dependents)
{
    Console.WriteLine($"  - {dependent}");
}

// Useful for understanding impact of removing a mod
if (dependents.Count > 0)
{
    Console.WriteLine($"\nāš ļø Removing JEI will affect {dependents.Count} other mods!");
}

GetModsWithMissingDependencies(string folderPath)

Returns: List<string>

Get mods that have missing required dependencies.

Example Usage

var modsWithMissingDeps = analyzer.GetModsWithMissingDependencies(@"C:\mods");

if (modsWithMissingDeps.Count > 0)
{
    Console.WriteLine($"šŸ”“ {modsWithMissingDeps.Count} mods have missing dependencies:");
    foreach (var modId in modsWithMissingDeps)
    {
        var modPath = Directory.GetFiles(@"C:\mods", "*.jar")
            .FirstOrDefault(f => analyzer.ReadModMetadata(f)?.modId == modId);
        if (modPath != null)
        {
            var requiredDeps = analyzer.GetRequiredDependencies(modPath);
            var availableMods = analyzer.ReadAllModMetadataInFolder(@"C:\mods")
                .Select(m => m.modId).ToHashSet();
            var missingDeps = requiredDeps.Where(dep => !availableMods.Contains(dep));
            Console.WriteLine($"  {modId}:");
            foreach (var missing in missingDeps)
            {
                Console.WriteLine($"    - Missing: {missing}");
            }
        }
    }
}

Mod Query & Summary Methods

GetModById(string modId, string folderPath)

Returns: ModMetadata

Get metadata for a mod by its ID.

Example Usage

var jeiMeta = analyzer.GetModById("jei", @"C:\mods");

if (jeiMeta != null)
{
    Console.WriteLine($"Found JEI: {jeiMeta.name} v{jeiMeta.modVersion}");
    Console.WriteLine($"Description: {jeiMeta.description}");
}
else
{
    Console.WriteLine("JEI not found in mods folder");
}

GetModVersion(string modPath)

Returns: string

Get the version of a mod.

Example Usage

var version = analyzer.GetModVersion(@"C:\mods\jei.jar");
Console.WriteLine($"JEI version: {version ?? "Unknown"}");

// Batch check versions
var mods = Directory.GetFiles(@"C:\mods", "*.jar");
Console.WriteLine("Mod versions:");
foreach (var mod in mods)
{
    var ver = analyzer.GetModVersion(mod);
    var name = Path.GetFileNameWithoutExtension(mod);
    Console.WriteLine($"  {name}: {ver ?? "Unknown"}");
}

GetModFileName(string modId, string folderPath)

Returns: string

Get the file name of a mod by its ID.

Example Usage

var fileName = analyzer.GetModFileName("jei", @"C:\mods");
if (fileName != null)
{
    Console.WriteLine($"JEI file: {fileName}");
    // You can now use this to get the full path
    var fullPath = Path.Combine(@"C:\mods", fileName);
    Console.WriteLine($"Full path: {fullPath}");
}

GetModSummary(string modPath)

Returns: string

Get a comprehensive summary string of all key metadata.

Example Usage

var summary = analyzer.GetModSummary(@"C:\mods\jei.jar");
Console.WriteLine("=== JEI Summary ===");
Console.WriteLine(summary);
=== JEI Summary ===
ID: jei
Name: Just Enough Items
Version: 15.2.0.27
Loader: Forge
LoaderVersion: 47.1.0
MCVersion: 1.20.1
Required: [forge, minecraft]
Optional: [waila, nei]
Incompatibilities: [toomanyitems]

GetModsByLoader(string loader, string folderPath)

Returns: List<ModMetadata>

Get all mods in a folder that use a specific loader.

Example Usage

var forgeMods = analyzer.GetModsByLoader("Forge", @"C:\mods");
var fabricMods = analyzer.GetModsByLoader("Fabric", @"C:\mods");

Console.WriteLine($"Forge mods ({forgeMods.Count}):");
foreach (var mod in forgeMods)
{
    Console.WriteLine($"  - {mod.name} ({mod.modId})");
}

Console.WriteLine($"\nFabric mods ({fabricMods.Count}):");
foreach (var mod in fabricMods)
{
    Console.WriteLine($"  - {mod.name} ({mod.modId})");
}

// Check for mixed loaders (potential issue)
if (forgeMods.Count > 0 && fabricMods.Count > 0)
{
    Console.WriteLine("\nāš ļø Warning: Mixed Forge and Fabric mods detected!");
}

GetModsByMinecraftVersion(string mcVersion, string folderPath)

Returns: List<ModMetadata>

Get all mods compatible with a specific Minecraft version.

Example Usage

var mods1201 = analyzer.GetModsByMinecraftVersion("1.20.1", @"C:\mods");
var mods1194 = analyzer.GetModsByMinecraftVersion("1.19.4", @"C:\mods");

Console.WriteLine($"Mods compatible with 1.20.1 ({mods1201.Count}):");
foreach (var mod in mods1201)
{
    Console.WriteLine($"  - {mod.name} ({mod.minecraftVersion})");
}

// Find mods that work with multiple versions
var modsWithWildcard = analyzer.GetModsByMinecraftVersion("1.20.x", @"C:\mods");
Console.WriteLine($"\nMods supporting 1.20.x ({modsWithWildcard.Count}):");
foreach (var mod in modsWithWildcard)
{
    Console.WriteLine($"  - {mod.name}");
}

Crash Report Analysis

ResolveCrashReport(string modsFolderPath, string crashReport)

Returns: object

Analyze a crash report to identify potentially problematic mods.

Example Usage

// Read crash report from file
var crashReport = File.ReadAllText(@"C:\crash-reports\crash-2023-12-01.txt");

// Analyze the crash
var result = analyzer.ResolveCrashReport(@"C:\mods", crashReport);

if (result is List<string> suspiciousMods)
{
    Console.WriteLine($"šŸ” Found {suspiciousMods.Count} potentially problematic mods:");
    foreach (var modId in suspiciousMods)
    {
        var modMeta = analyzer.GetModById(modId, @"C:\mods");
        if (modMeta != null)
        {
            Console.WriteLine($"  - {modMeta.name} ({modId}) v{modMeta.modVersion}");
        }
        else
        {
            Console.WriteLine($"  - {modId}");
        }
    }
    Console.WriteLine("\nšŸ’” Try removing these mods one by one to isolate the issue.");
    Console.WriteLine("šŸ’” Check for mod updates or compatibility issues.");
}
else
{
    Console.WriteLine("ā„¹ļø No obvious problematic mods identified in crash report.");
    Console.WriteLine("šŸ’” The crash might be caused by:");
    Console.WriteLine("   - Missing dependencies");
    Console.WriteLine("   - Incompatible mod versions");
    Console.WriteLine("   - Java/Minecraft version issues");
}

// Advanced: Combine with other analysis
var missingDeps = analyzer.GetModsWithMissingDependencies(@"C:\mods");
if (missingDeps.Count > 0)
{
    Console.WriteLine($"\nāš ļø Also check missing dependencies for {missingDeps.Count} mods");
}

Complete Example: Comprehensive Mod Folder Analysis

Here's a comprehensive example that uses multiple methods to analyze a mods folder:

using DrMod;

class Program
{
    static void Main()
    {
        var analyzer = new DrMod();
        var modsPath = @"C:\Minecraft\mods";
        
        Console.WriteLine("=== DrMod Analysis Report ===\n");
        
        // 1. Basic folder validation
        var errors = analyzer.ValidateModsFolder(modsPath);
        Console.WriteLine($"šŸ“‹ Validation: {(errors.Count == 0 ? "āœ… PASSED" : $"āŒ {errors.Count} ISSUES")}");
        
        if (errors.Count > 0)
        {
            foreach (var error in errors.Take(5)) // Show first 5 errors
            {
                Console.WriteLine($"   {error}");
            }
            if (errors.Count > 5) Console.WriteLine($"   ... and {errors.Count - 5} more");
        }
        
        // 2. Mod inventory
        var allMods = analyzer.ReadAllModMetadataInFolder(modsPath);
        Console.WriteLine($"\nšŸ“¦ Total mods: {allMods.Count}");
        
        var byLoader = allMods.GroupBy(m => m.loader).ToDictionary(g => g.Key, g => g.Count());
        foreach (var (loader, count) in byLoader)
        {
            Console.WriteLine($"   {loader}: {count} mods");
        }
        
        // 3. Performance analysis
        var heavyMods = analyzer.DetectPerformanceImpactingMods(modsPath);
        Console.WriteLine($"\n⚔ Performance: {(heavyMods.Count == 0 ? "āœ… OPTIMIZED" : $"āš ļø {heavyMods.Count} HEAVY MODS")}");
        
        if (heavyMods.Count > 0)
        {
            var modsByMemory = analyzer.GetModsByMemoryUsage(modsPath, true);
            Console.WriteLine("   Top memory users:");
            foreach (var mod in modsByMemory.Take(3))
            {
                var perfInfo = analyzer.GetModPerformanceInfo(Path.Combine(modsPath, mod.modFileName ?? ""));
                Console.WriteLine($"     {mod.name}: {perfInfo.EstimatedMemoryUsageMB} MB");
            }
        }
        
        // 4. Health check
        var corruptedMods = analyzer.FindCorruptedMods(modsPath);
        Console.WriteLine($"\nšŸ„ Health: {(corruptedMods.Count == 0 ? "āœ… HEALTHY" : $"šŸ”“ {corruptedMods.Count} CORRUPTED")}");
        
        // 5. Dependency analysis
        var missingDeps = analyzer.GetModsWithMissingDependencies(modsPath);
        Console.WriteLine($"\nšŸ”— Dependencies: {(missingDeps.Count == 0 ? "āœ… ALL SATISFIED" : $"āŒ {missingDeps.Count} MISSING")}");
        
        // 6. Conflict detection
        var conflicts = analyzer.DetectConflicts(Directory.GetFiles(modsPath, "*.jar").ToList());
        var incompatibilities = analyzer.DetectIncompatibilities(Directory.GetFiles(modsPath, "*.jar").ToList());
        
        Console.WriteLine($"\nāš”ļø Conflicts: {conflicts.Count} duplicates, {incompatibilities.Count} incompatibilities");
        
        // 7. Most depended-on mods
        Console.WriteLine("\n🌟 Most popular dependencies:");
        var dependencyCounts = new Dictionary<string, int>();
        
        foreach (var mod in allMods)
        {
            foreach (var dep in mod.requiredDependencies)
            {
                dependencyCounts[dep] = dependencyCounts.GetValueOrDefault(dep, 0) + 1;
            }
        }
        
        var topDeps = dependencyCounts.OrderByDescending(kvp => kvp.Value).Take(5);
        foreach (var (dep, count) in topDeps)
        {
            Console.WriteLine($"   {dep}: required by {count} mods");
        }
        
        // 8. World compatibility (if world path provided)
        var worldPath = @"C:\Minecraft\saves\MyWorld";
        if (Directory.Exists(worldPath))
        {
            var compatibility = analyzer.CheckWorldCompatibility(worldPath, modsPath);
            Console.WriteLine($"\nšŸŒ World Compatibility: {(compatibility.IsCompatible ? "āœ… COMPATIBLE" : "āŒ ISSUES")}");
            if (compatibility.MissingMods.Count > 0)
            {
                Console.WriteLine($"   Missing: {string.Join(", ", compatibility.MissingMods.Take(3))}");
            }
        }
        
        Console.WriteLine("\nāœ… Analysis complete!");
    }
}

License

DrMod is released under the MIT License. You are free to use, modify, and distribute this software in both commercial and non-commercial projects.

Ā© 2024 MatriX Development. All rights reserved.