Wiki 9Minecraft Wiki 9Minecraft

Check Mod Loading Status in Your Code

Java EditionModGuides 4FAQ 10Related mods 48
DownloadMoff’s AddonAPI-DynLoad Mod

Get the files on 9Minecraft

Contents (4)
  1. Use the Mixin Plugin Template
  2. Implement Runtime Checks
  3. Avoid Crashes
  4. Organize by Dependency

Use the Mixin Plugin Template

The mod includes a template Mixin plugin that provides a clean way to check if a mod is loaded at runtime. This is useful for conditional code execution within your addon's logic.

Implement Runtime Checks

Inside your module or event handler, use the provided utility to query mod status:

`java

if (isModLoaded("target_mod_id")) {

// Execute code only if the mod is present

registerCrossModFeature();

}

`

Avoid Crashes

Never directly reference classes from optional mods. Always check mod presence first. If you need to use another mod's API, wrap it in a conditional check or move it to a separate module that only loads when that mod is active.

Organize by Dependency

Create separate modules for each optional mod integration. This keeps your code clean and ensures the game starts safely even if multiple mods are missing.

More guides for this mod