# minecraft-detector **Repository Path**: al01/minecraft-detector ## Basic Information - **Project Name**: minecraft-detector - **Description**: A TypeScript library to detect running Minecraft instances on Windows, including version, mod loader, login type, and LAN ports. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-30 - **Last Updated**: 2025-12-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Minecraft Detector A TypeScript library to detect running Minecraft instances on Windows, including version, mod loader, login type, and LAN ports. ## Features - Detects all running Minecraft processes. - Parses Minecraft version (supports `--version`, `--assetIndex`, or logs fallback). - Detects mod loader type (Vanilla, Forge, Fabric, Quilt) and loader version. - Parses login info and determines login type (`offline`, `msa`, `other`). - Detects LAN ports in use by Minecraft instances. ## Installation ```bash # Using bun bun add minecraft-detector # Using npm npm install minecraft-detector # Using yarn yarn add minecraft-detector # Using pnpm pnpm add minecraft-detector ``` > Note: This library is designed for Windows and uses PowerShell to detect running processes. ## Usage ```ts import MinecraftDetector from 'minecraft-detector'; async function main() { const instances = await MinecraftDetector.detectAll(); console.log(instances); } main(); ``` ### MinecraftInstance Structure ```ts interface MinecraftInstance { pid: number; java: string; version?: string; loader: 'Vanilla' | 'Forge' | 'Fabric' | 'Quilt'; loaderVersion?: string; username?: string; uuid?: string; loginType?: 'offline' | 'msa' | 'other'; lanPorts: number[]; } ``` ### ModLoaderInfo Structure ```ts interface ModLoaderInfo { loader: 'Vanilla' | 'Forge' | 'Fabric' | 'Quilt'; loaderVersion?: string; } ``` ### LoginInfo Structure ```ts interface LoginInfo { username?: string; uuid?: string; loginType?: 'offline' | 'msa' | 'other'; } ``` ## API ### `MinecraftDetector.detectAll(mcDir?: string): Promise` Detects all running Minecraft instances. - `mcDir` (optional): Path to the Minecraft directory (default: `%USERPROFILE%\\.minecraft`). - Returns a promise that resolves to an array of `MinecraftInstance` objects. ### `MinecraftDetector.parseVersion(cmd: string, mcDir?: string): string | undefined` Parses the Minecraft version from the command line or logs. ### `MinecraftDetector.parseModLoader(cmd: string, mcDir?: string): ModLoaderInfo` Parses the mod loader type and version from the command line or libraries folder. ### `MinecraftDetector.parseLoginInfo(cmd: string): LoginInfo` Parses login information from the command line and determines login type. ## Notes - Only tested on Windows. - Uses PowerShell to query running processes and TCP connections. - Handles Forge, Fabric, and Quilt mod loaders. - Determines login type based on `--accessToken` JWT structure. ## License MIT