Integrating DynamicHUD

Now that we have access to DynamicHUD in our mod, we will integrate DynamicHUD.

Step 1: Create a new Class

First, you need to create a new class that implements the DynamicHudIntegration interface. This class will serve as the bridge between your mod and DynamicHUD. Let’s call this class MyIntegration. Here’s a minimal example to get you started:

package your.mod.package;

import com.tanishisherewith.dynamichud.integration.DynamicHudIntegration;
import com.tanishisherewith.dynamichud.integration.DynamicHudConfigurator;

public class MyIntegration implements DynamicHudIntegration {
    @Override
    public DynamicHudConfigurator configure(DynamicHudConfigurator configurator) {
        return configurator; // Configure your HUD here, see the Configurator page
    }

    @Override
    public void init() {
        // Initialize your widgets or DynamicValueRegistry here
    }
}

What’s Happening Here?

  • The configure method is your entry point to set up the HUD using the DynamicHudConfigurator. You’ll customize widgets, renderers, and screens here (more on that in the Configurator page).

  • The init() method is for initializing your widgets or registering values in the DynamicValueRegistry.

Step 2: Update the fabric.mod.json File

Next, you need to update the fabric.mod.json file in your mod. This file is used by Fabric to load your mod, and it needs to know about your new MyIntegration class. Add the following to the entrypoints section:

"entrypoints": {
    "dynamicHud": [
        "path.to.your.integration.MyIntegration"
    ]
}

Replace "path.to.your.integration.MyIntegration" with the actual path to your MyIntegration class.

With this, DynamicHUD will be able to communicate with your mod.

Marking as Utility

If your mod provides widgets but doesn’t display a HUD, set markAsUtility :

configurator.markAsUtility = true;

This skips rendering but allows widget registration for other mods. An example of this is used in the [DefaultIntegrationImpl.java]

Last updated

Was this helpful?