Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.46 KB

File metadata and controls

58 lines (44 loc) · 1.46 KB

Phantom Loader example mod

This example shows how a mod can be created using Phantom Loader.

Refer to the wiki for a full explanation.

Build scripts

Phantom Loader uses an annotation processor to generate code for specific mod loaders without requiring the mod developer to add code in the mod loader's module.

// Forge
implementation fg.deobf("curse.maven:phantom-loader-958545:5011993")
annotationProcessor fg.deobf("curse.maven:phantom-loader-958545:5011993")
annotationProcessor "io.github.phantomloader:processor-forge:${phantomVersion}"
// Fabricì
modImplementation "curse.maven:phantom-loader-958545:5011988"
annotationProcessor "curse.maven:phantom-loader-958545:5011988"
annotationProcessor "net.fabricmc:fabric-loader:${fabricVersion}"
annotationProcessor "io.github.phantomloader:processor-fabric:${phantomVersion}"

Methods annotated with @ModEntryPoint will be called from the generated classes for the respective loader.

public class ExampleMod {

    @ModEntryPoint
    public static void initialize() {
        // ...
    }
}

The above will generate the following:

// Forge
@Mod("example")
public class ForgeInitializer {

    public ForgeInitializer() {
        ExampleMod.initialize();
    }
}
// Fabric
public class FabricInitializer implements ModInitializer {

    @Override
    public void onInitialize() {
        ExampleMod.initialize();
    }
}