Skip to content

Making an Addon

ENDERZOMBI102 edited this page Nov 8, 2022 · 8 revisions

Addons are an important part of LC, As an abstraction layer it is capable of loading external jars like a modloader, in this page, i'll show you how to create a simple addon.

Lets start by adding LC as a dependency to our gradle project

build.gradle.kts

plugins {
    java
}

repositories {
    mavenCentral()
    maven( url="https://libraries.minecraft.net" )
    maven( url="https://repsy.io/mvn/enderzombi102/mc" )
}

dependencies {
    // utilities
    implementation( "org.jetbrains:annotations:23.0.0" )

    // LC API
    compileOnly( "com.enderzombi102:loadercomplex-api:0.2.0" )
}

tasks.withType<Jar> {
    archiveExtension.set(".lc.jar")
    manifest.attributes(
        "LoaderComplex-AddonId" to "example-addon",
        "LoaderComplex-Version" to archiveVersion.get(),
        "LoaderComplex-Main" to "org.example.ExampleAddon"
    )
}

Next on, we need a class that implements the Addon interface
src/main/java/org/example/ExampleAddon.java

public class ExampleAddon implements Addon {
	public void init( @NotNull Loader loader ) {
		var logger = loader.getLogger("example-addon");
		logger.info("We did it bois, we got loaded!");
	}

	@Override
	public @NotNull String getAuthors() {
		return "ExampleDude";
	}

	@Override
	public @NotNull String getName() {
		return "Example Addon";
	}

	@Override
	public @NotNull Map<String, String> getLinks() {
		return new HashMap<>() {{
			put( "repo", "https://github.com/ExampleDude/ExampleAddon" );
		}};
	}

	@Override
	public @NotNull String getDescription() {
		return "An epic example addon!";
	}
} 

The main entrypoint is init(Loader loader), its where we would register our blocks, items and more.

Clone this wiki locally