Skip to content

AtumMod class detailed

Bogdan T edited this page Jan 31, 2024 · 11 revisions

Lets dig dipper into the Main Class.

Methods:

  • getAPI() It is the same as AtumAPI.getInstance(), just shorter

  • getLogger() the logger created for the mod, which I highly recommend to use instead System.out.print.

  • getConfigManager() Access the configs feature

  • getDisplayManager() Access the display feature

  • getInputHandler() Access the input handler, that is more covenient to work with than similar forge event

  • getNetworkManager() Access the network feature, that simplifies the work with the packets

  • getDataFolder() Returns the File class with the following path - /config/[mod-name]

  • getName() abstract method, that you have to implement. Use the same value as you use in @Mod annotation of the main class

  • getModID() abstract method, that you have to implement. Use the same value as you use in @Mod annotation of the main class

  • getPackagePath() abstract method, that you have to implement. Use the path that will contain all the classes of your mod, for example for the atummodcore it is: "me.phoenixra.atumodcore"

  • isDebugEnabled() abstract method, that you have to implement. By default it is false. If you want to use special debug features and logs, enable it. What special debug features? It will be described in a different page

  • createAPI() This method can be ignored, unless you want to create your own implementation of AtumAPI and core atum mod. It is used once, when the core mod(by default it is AtumModCore) is created

Mod services

A mod service is the feature allowing you to use the FMLEvents outside the AtumMod class without creating a mess in a main class with many method calls.

Additionally, it helps to control the lifecycle of the service and autamatically registers the service in forge EVENT_BUS

It is a mandatory for every mod that uses AtumModCore, to add the following methods to the main class:

@Mod.EventHandler
public void construct(FMLConstructionEvent event) {
    notifyModServices(event);
}

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    notifyModServices(event);
}

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    notifyModServices(event);
}

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
    notifyModServices(event);
}

@Mod.EventHandler
public void loadComplete(FMLLoadCompleteEvent event) {
    notifyModServices(event);
}

@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event) {
    notifyModServices(event);
}

@Mod.EventHandler
public void serverStarted(FMLServerStartedEvent event) {
    notifyModServices(event);
}

Otherwise the mod features won't properly work.

To add new Mod service:

  • Make the class implement AtumModService class.

  • Then, in class constructor use AtumMod#provideModService(service object)

If you need to, you can remove the service or even clear all of them.

AtumMod#removeModService(service object)

AtumMod#clearAllModServices()

Clone this wiki locally