Prerequisites
Before setting up the Essential API, ensure you have:- A Minecraft mod project using Gradle
- Java Development Kit (JDK) 8 or higher
- Basic knowledge of Kotlin or Java
- Essential mod installed in your development environment
Setup steps
Add the Essential API repository
Add the Essential repository to your Gradle (Kotlin)
build.gradle or build.gradle.kts file:Gradle (Groovy)Add the Essential API dependency
Add the Essential API to your dependencies section:Gradle (Groovy)Gradle (Kotlin)Replace
$mcVersion with your Minecraft version (e.g., 1.20.1) and $mcPlatform with your mod loader (fabric, forge, or neoforge).The Essential API artifact name follows the pattern:
essential-<mc-version>-<platform>Add required dependencies
The Essential API requires several libraries. Add them to your dependencies:Gradle (Kotlin)
Configure Kotlin (if not already configured)
If your project doesn’t already use Kotlin, add the Kotlin plugin:Gradle (Kotlin)Gradle (Groovy)
Sync your project
Refresh your Gradle project to download the dependencies:Or use your IDE’s Gradle refresh function.
Using dependency injection
Essential provides a dependency injection system powered by Kodein. You can use it to get API instances:Development environment setup
Running with Essential
Ensure Essential is present in your development environment:- Download Essential from essential.gg
- Place the Essential jar in your
run/modsfolder - Launch your development environment
Testing your integration
Create a simple command to test your setup:/testapi in-game to verify everything works.
Platform-specific notes
Fabric
For Fabric mods, you may need to include Essential as a dependency in yourfabric.mod.json:
Forge
For Forge mods, add Essential as a dependency in yourmods.toml:
NeoForge
For NeoForge mods, add Essential as a dependency in yourneoforge.mods.toml:
Common issues
ClassNotFoundException: gg.essential.api.EssentialAPI
ClassNotFoundException: gg.essential.api.EssentialAPI
This means the Essential API is not on your classpath. Verify:
- You’ve added the repository correctly
- The dependency is specified with the correct version and platform
- You’ve refreshed Gradle dependencies
- Essential is installed in your development environment
NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
This means Kotlin runtime is missing. Add the Kotlin standard library to your dependencies:
RuntimeException: DI not initialised!
RuntimeException: DI not initialised!
This error occurs when trying to use dependency injection before Essential has loaded. Options:
- Use
EssentialAPI.getInstance()instead of DI - Ensure your code runs after Essential has initialized (e.g., in a late initialization phase)
- Check that Essential is actually loaded
Version conflicts with Essential's dependencies
Version conflicts with Essential's dependencies
If you encounter version conflicts with libraries that Essential bundles:
- Check Essential’s
build.gradle.ktsfor the exact versions it uses - Align your versions with Essential’s
- Use Gradle’s dependency resolution strategies if needed
Example project structure
Here’s a minimal example of abuild.gradle.kts for a Fabric mod using the Essential API:
Next steps
API overview
Learn about all available APIs and their features
Essential source code
Browse the full source code on GitHub