Skip to content

Creating an extension (Legacy)

Qboi edited this page May 23, 2023 · 1 revision

On this page you can learn how to make an extension.

Add dependency

In your build.gradle add the following code in the dependencies {...} section:

compileOnly fg.deobf(group: "com.ultreon.mods", name: "advanced-debug", version: "1.1.0", classifier: "api", changing: true)
runtimeOnly fg.deobf(group: "com.ultreon.mods", name: "advanced-debug", version: "1.1.0", changing: true)

It also needs a repository, so add the following code in the repositories {...} section:

maven {
    name "AdvancedDebugMaven"
    url "https://github.com/Ultreon/advanced-debug/raw/main/.maven_repo/"
}

The line with the compileOnly part is for the API, so you don't have any other classes that isn't needed for the extension.
Then the line with the runtimeOnly part makes it so you can test your code from the runClient run config or launch.

Create the extension class.

We start with a simple class;

@AdvDebugExt(modId = Main.MOD_ID) // We expect that 'Main.MOD_ID' refers to the id of the compatibilty mod.
public class AdvancedDebugExtension implements IAdvDebugExt {

}

Here you have the basic class. The part with @AdvDebugExt(...) is an annotation, and is used for the Advanced Debug mod to find out it's an extension class.
And it also implements IAdvDebugExt, this is for the methods it needs to have. These methods are initPages and initFormatters.
So now, we implement these methods:

@AdvDebugExt(modId = Main.MOD_ID) // We expect that 'Main.MOD_ID' refers to the id of the compatibilty mod.
public class AdvancedDebugExtension implements IAdvDebugExt {
    @Override
    public void initPages(IInitPagesEvent evt) {
        // Register pages here.
    }

    @Override
    public void initFormatters(IFormatterRegistry registry) {
        // Initialize a init class for the formatters.
    }
}

Further information

For creating a debug page click here.
For creating a formatter click here.

Download @ CurseForge and Modrinth.

Clone this wiki locally