Saving and Loading Widgets

The getWidgetsFile() method retrieves a File where widgets should be saved and loaded. It can be overridden to specify the file instance from which DynamicHUD will load and save your mod's widgets.

Version 3.0.0 onwards, DynamicHUD automates saving via DynamicHudConfigurator.setupSaveEvents, triggered on events like server stop or player disconnect.

The default file returned is:

String FILENAME = "widgets.nbt";

//Fabric "config" directory.
File FILE_DIRECTORY = FabricLoader.getInstance().getConfigDir().toFile();

// This becomes same for all mods integrating dynamic hud
File WIDGETS_FILE = new File(FILE_DIRECTORY, FILENAME);

//Here is where we return the file.
default File getWidgetsFile() {
    return WIDGETS_FILE;
}
MyIntegration.java
    @Override
    public File getWidgetsFile() {
        return new File(FILE_DIRECTORY, "mymod_widgets.nbt");
    }

Last updated

Was this helpful?