JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q55965F

A TypeScript library to detect running Minecraft instances on Windows, including version, mod loader, login type, and LAN ports.

Package Exports

  • minecraft-detector
  • minecraft-detector/index.js
  • minecraft-detector/index.ts

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (minecraft-detector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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

# 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

import MinecraftDetector from 'minecraft-detector';

async function main() {
    const instances = await MinecraftDetector.detectAll();
    console.log(instances);
}

main();

MinecraftInstance Structure

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

interface ModLoaderInfo {
    loader: 'Vanilla' | 'Forge' | 'Fabric' | 'Quilt';
    loaderVersion?: string;
}

LoginInfo Structure

interface LoginInfo {
    username?: string;
    uuid?: string;
    loginType?: 'offline' | 'msa' | 'other';
}

API

MinecraftDetector.detectAll(mcDir?: string): Promise<MinecraftInstance[]>

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