Overview
Stage 2 is the final loader stage that discovers, downloads, updates, and loads Essential and other compatible mods. It provides chain-loading capabilities, Jar-in-Jar (JiJ) dependency extraction, runtime mod remapping, and Mixin integration.Core Components
EssentialLoaderBase
Abstract base class implementing the core loading logic for all platforms. Package:gg.essential.loader.stage2
Game directory for mod storage and configuration
Minecraft version (e.g., “1.8.9”, “1.20.1”)
Key Methods
load()
Main entry point that discovers and loads all Essential-compatible mods.-
Mod Discovery
- Scans classpath for
essential-loader.propertiesfiles - Loads mod metadata (ID, version, branch, pinned files)
- Adds Essential mod entry if not explicitly declared
- Scans classpath for
-
Version Resolution
- Checks local mod files and validates checksums
- Fetches latest versions from API if needed
- Applies pinned version constraints
- Handles update prompts based on auto-update mode
-
Download & Update
- Downloads missing mods
- Updates existing mods (via diff or full download)
- Validates checksums after download
-
Classpath Integration
- Extracts Jar-in-Jar dependencies
- Adds mod JARs to platform class loader
- Registers mods with platform loader
-
Mixin Loading
- Registers Mixin configurations
- Chain-loads Mixins for early class transformations
initialize()
Initializes loaded mods by calling their initialization entrypoints.- Calls
gg.essential.api.tweaker.EssentialTweaker.initialize(File)on each mod - Only runs if mod classes are successfully added to classpath
addToClasspath()
Platform-specific method to add mod JAR to the class loader.Path to JAR file to add to classpath
Mod Configuration
essential-loader.properties (Discovery)
Embedded in container JARs to declare Essential-compatible mods.Publisher’s slug identifier
Publisher’s UUID
Mod’s slug identifier
Mod’s UUID
Human-readable mod name
Default update branch
Path to pinned mod JAR (resource path or URL)
MD5 checksum of pinned JAR
Version string of pinned JAR
Version ID for API queries
User Configuration
Runtime configuration stored in the mod’s data directory.Chain-Loading System
Mod Discovery
Stage 2 discovers mods by scanning foressential-loader.properties files on the classpath.
Version Resolution
For each discovered mod:- Check for local JAR file and metadata
- Validate checksum to ensure integrity
- Check for pinned version in container JAR
- Fetch latest version from API
- Apply auto-update logic based on mode
- Download/update if necessary
Update Strategies
Diff Patching
Efficient UpdatesDownloads binary diff and patches existing JAR. Requires matching checksum.
Full Download
Fallback MethodDownloads complete JAR file when diff is unavailable or patching fails.
Jar-in-Jar Extraction
Purpose
Essential mods can bundle dependencies as Jar-in-Jar to avoid version conflicts.Extraction Process
Platform Implementations
LaunchWrapper Platform
Class:gg.essential.loader.stage2.Loader
LaunchWrapper uses a sophisticated chain-loading system with relaunch support.
Key Features
- Jar Discovery: Scans LaunchWrapper sources for
essential.mod.json - Version Resolution: Deduplicates and selects latest versions
- Relaunch: Relaunches game with proper classpath order
- MixinExtras: Extracts and prioritizes MixinExtras versions
essential.mod.json Format
Schema version for future compatibility
Mod identifier (format:
publisher:mod)Mod version string
Array of dependency specifications:
file: Path to JAR (resource or absolute)builtin: Built-in dependency name (e.g., “essential”)class: Class name that provides dependencies
Fabric Platform
Class:gg.essential.loader.stage2.EssentialLoader
Fabric integration with mod container registration and JiJ handling.
Key Features
- JarInJarDependenciesHandler: Integrates with Fabric’s JiJ system
- RuntimeModRemapper: Remaps mods to dev mappings in dev environment
- Fake Mod Registration: Registers Essential as Fabric mod for Mod Menu
- Mixin Chain-Loading: Reflects into Mixin internals if needed
Fabric JiJ Integration
ModLauncher Platform
Class:gg.essential.loader.stage2.EssentialLoader (dummy) + ActualEssentialLoader
ModLauncher integration via transformation service and mod locator.
Key Features
- Delayed Loading: Waits for MC version from ModLauncher
- Mod Locator: Registers mods via
EssentialModLocator - Descriptor Rewriting: Handles module descriptor transformations
- Self-Renaming: Renames Essential to avoid Forge conflicts
Mixin Integration
Configuration Loading
Stage 2 registers Mixin configurations from loaded mods.Chain-Loading
Ensures Mixins are loaded even if third-party mods load MC classes early.API Endpoints
Version Metadata
/v1/{publisher}:{mod}/versions/{branch}/platforms/{gameVersion}
Fetch latest mod version metadataResponse:
Download URL
/v1/{publisher}:{mod}/versions/{version}/platforms/{gameVersion}/download
Fetch download URL for specific versionResponse:
Diff Download
/v1/{publisher}:{mod}/versions/{oldVersion}/diff/{newVersion}/platforms/{gameVersion}
Fetch binary diff for updatingResponse:
Changelog
/v1/{publisher}:{mod}/versions/{versionId}/changelog
Fetch changelog for update promptResponse:
Stage 2 Version Requirements
Manifest Attribute
Mods can require minimum Stage 2 versions.Upgrade Flow
When a mod requires newer Stage 2:- Stage 2 detects requirement from manifest
- Configures Stage 1 to upgrade on next boot
- Shows restart prompt to user
- Game restarts with newer Stage 2
Error Handling
Mod does not support game version
Mod does not support game version
Warning: “Essential does not support the following game version: ”Behavior: Mod is skipped, loader continues with other mods
Checksum mismatch after download
Checksum mismatch after download
Error: “Downloaded mod file checksum did not match”Behavior: Downloaded file deleted, existing version used if available
Failed to add mod to classpath
Failed to add mod to classpath
Error: “Failed to add Essential jar to parent ClassLoader”Behavior: Loader attempts fallback methods, throws exception if all fail
JiJ dependencies need restart
JiJ dependencies need restart
UI: Restart prompt showing updated modsBehavior: Game exits cleanly, user must restart manually
Development & Testing
System Properties
Mod ID Format
See Also
- Stage 0 API - Bootstrap entrypoints
- Stage 1 API - Configuration and Stage 2 loading
- Integration Guides - Platform-specific integration