Skip to content

4: Getting started [Dev]

Emafire003 edited this page Feb 19, 2024 · 6 revisions

Valid for version 3.0.0 and upwards

Adding the mod dependency

If you want to use this mod in your project you can use the maven repository provided by Modrinth, like so.

Fabric/Quilt

Insert this into your build.gradle

repositories {
    maven {
        name = "Modrinth"
        url = "https://api.modrinth.com/maven"
        content {
            includeGroup "maven.modrinth"
        }
    }
}

dependencies {
    modImplementation "maven.modrinth:coloredglowlib:<version>"
}

Add +nocca to the version if you are already using CardinalComponentsAPI in your mod to have a smaller size file. The modules need by CGL are base,entity and scoreboard.

NOTE there currently is a f***ing annoying bug that I can't seem to fix, requiring you to add CardinalComponentsAPI to your project as well, and you can do that by adding these as dependencies:

repositories {
    maven {
        name = "Ladysnake Mods"
        url = 'https://maven.ladysnake.org/releases'
    }
}

dependencies {
    modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:5.4.0")
    modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:5.4.0")
    modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-scoreboard:5.4.0")
}

Introduction

The first thing you will wan't to do is get an instance of the API. This is possibile only after the server has started, otherwise you will get a null.

To get the API instance you can use:

ColoredGlowLibAPI cgl = ColoredGlowLibMod.getAPI();

or an alias like .getLib() or .getColoredGlowLib()

After this, most of the information is in the javadocs, so you can use those.

Example on how to get the instance:

private static ColoredGlowLibAPI coloredGlowLib;
    
public static void registerCGL(){
    ServerLifecycleEvents.SERVER_STARTED.register(server -> {
        coloredGlowLib = ColoredGlowLibMod.getColoredGlowLib();
    });
}

Then in your mod initializer:

#registerCGL()
Clone this wiki locally