public interface IMod
Notice that, when a mod can be disabled (isDisableable()), the mod's
main method will still be initialized, but none of its initializing lifecycle
methods will be called. For this reason, you shouldn't statically initialize
any of your tiles, items or functionalities outside of the designated
initializing lifecycle methods.
For more information on how to create mods, check out the modding example and tutorial repository.
| Modifier and Type | Method and Description |
|---|---|
default java.lang.String[] |
getAuthors() |
default java.lang.String |
getContentLocation()
Returns the location that content is stored in, starting in any of the
root folder that are marked as source (meaning they will be at the root
of the compiled mod jar).
|
default java.lang.String |
getDescription() |
java.lang.String |
getDisplayName() |
java.lang.String |
getId() |
default ModConfig |
getModConfig()
Gets an optional
ModConfig instance that you can use to save and
load settings for your mod that the player will be able to change. |
default java.lang.Class<? extends Gui> |
getModGuiClass()
Gets a class that can be initialized by the mods gui to open a special
new gui where the mod can have its own information or settings.
|
java.lang.String |
getResourceLocation()
Returns the location that resources are stored in, starting in any of the
root folders that are marked as source (meaning they will be at the root
of the compiled mod jar).
|
default int |
getSortingPriority()
Gets the priority of how to sort the mod in the list of mods, meaning
this changes the order in which mods will be loaded.
|
java.lang.String |
getVersion() |
default void |
init(IGameInstance game,
IApiHandler apiHandler,
IEventHandler eventHandler)
This method is called as the main initialization phase.
|
default void |
initAssets(IGameInstance game,
IAssetManager assetManager,
IApiHandler apiHandler)
This method will not be called on the dedicated server, meaning this is
the place to load and initialize assets and rendering-related operatios
of any kind.
|
default boolean |
isCompatibleWithModVersion(java.lang.String version)
Return something other than the default on this method if you want a
client to be able to join a server (or vice versa) that has the same mod,
but with a different version, installed.
|
default boolean |
isDisableable()
Return true on this method if you want your mod to be able to be disabled
from the mods menu or the mod settings file.
|
default boolean |
isRequiredOnClient()
Return true on this method if you want the mod to be needed on the client
when trying to join a server.
|
default boolean |
isRequiredOnServer()
Return true on this method if you want the mod to be needed on the server
when trying to join it.
|
default void |
postInit(IGameInstance game,
IApiHandler apiHandler,
IEventHandler eventHandler)
This method is called after the initialization.
|
default void |
postInitAssets(IGameInstance game,
IAssetManager assetManager,
IApiHandler apiHandler)
This method will not be called on the dedicated server, meaning this is
the place to load and initialize assets and rendering-related operatios
of any kind.
|
default void |
postPostInit(IGameInstance game,
IApiHandler apiHandler,
IEventHandler eventHandler)
This method is called after post initialization.
|
default void |
preInit(IGameInstance game,
IApiHandler apiHandler,
IEventHandler eventHandler)
This method is called as pre initialization.
|
default void |
preInitAssets(IGameInstance game,
IAssetManager assetManager,
IApiHandler apiHandler)
This method will not be called on the dedicated server, meaning this is
the place to load and initialize assets and rendering-related operatios
of any kind.
|
default void |
prePreInit(IGameInstance game,
IApiHandler apiHandler,
IEventHandler eventHandler)
This method is called before pre initialization.
|
default DataSet |
receiveMessage(IMod sender,
java.lang.String messageIdentifier,
DataSet message)
This method is called when another loaded mod sends a message to this mod
using
IModLoader.sendMessage(IMod, String, String, DataSet). |
java.lang.String getDisplayName()
java.lang.String getId()
java.lang.String getVersion()
java.lang.String getResourceLocation()
For example, if your directory structure is /assets/mymod/assets.json, then this method should return assets/mymod, meaning there should be no leading or trailing slash.
default java.lang.String getContentLocation()
For example, if your directory structure is /assets/content/mymod/content.json, then this method should return
assets/content/mymod, meaning there should be no leading or
trailing slash.
default java.lang.String getDescription()
default java.lang.String[] getAuthors()
default int getSortingPriority()
mod1 with priority 1000 and mod2 with priority 2000, then the latter will be loaded first,
meaning all of its initialization lifecycle methods will be called before
mod1's.
Note that Rock Bottom has a sorting priority of Integer.MAX_VALUE.
default java.lang.Class<? extends Gui> getModGuiClass()
default ModConfig getModConfig()
ModConfig instance that you can use to save and
load settings for your mod that the player will be able to change. The
ModConfig class automatically picks a location for your settings
to be, along with automatically loading them from disk before this mod's
preInit(IGameInstance, IApiHandler, IEventHandler) phase. If you
want to change the settings in game, say, using the getModGuiClass(), you will still have to call IJsonSettings.save()
for them to be saved to file.
Keep in mind that the config returned does actually have to be cached as a class variable for loading and saving to properly function.
default boolean isDisableable()
default boolean isRequiredOnClient()
default boolean isRequiredOnServer()
default boolean isCompatibleWithModVersion(java.lang.String version)
version - The version that the client hasdefault DataSet receiveMessage(IMod sender, java.lang.String messageIdentifier, DataSet message)
IModLoader.sendMessage(IMod, String, String, DataSet). You
can process any type of message in this method, and return any type of
response back to the mod that originally sent the message. This way of
communication can be used for several things, like registering custom
content to different mods, notifying mods of certain requirements or
items, and so on. Messages like this can be sent at any time. Note that
sending a message to a mod that isn't installed will always yield an
empty response with the message simply being discarded.sender - The mod that sent the messagemessageIdentifier - A name for the message or type of message, can
be nullmessage - The message data that the mod sentdefault void prePreInit(IGameInstance game, IApiHandler apiHandler, IEventHandler eventHandler)
game - The game instanceapiHandler - The api handler instanceeventHandler - The event handler instancedefault void preInit(IGameInstance game, IApiHandler apiHandler, IEventHandler eventHandler)
Settings (or ServerSettings on the dedicated server), the
IAssetManager and the IRenderer.game - The game instanceapiHandler - The api handler instanceeventHandler - The event handler instancedefault void init(IGameInstance game, IApiHandler apiHandler, IEventHandler eventHandler)
GameContent,
meaning all Item, Tile, Biome and IEffect
instances along with all IWorldGenerator classes.game - The game instanceapiHandler - The api handler instanceeventHandler - The event handler instancedefault void postInit(IGameInstance game, IApiHandler apiHandler, IEventHandler eventHandler)
TileLayer objects and
their (final!) sorting, the loading of all of the IContent files
from the getContentLocation(), the IChatLog, the IGuiManager, the IInteractionManager, the IParticleManager, and lastly the IToaster.game - The game instanceapiHandler - The api handler instanceeventHandler - The event handler instancedefault void postPostInit(IGameInstance game, IApiHandler apiHandler, IEventHandler eventHandler)
Statistic instances and all of its Command instances.game - The game instanceapiHandler - The api handler instanceeventHandler - The event handler instancedefault void preInitAssets(IGameInstance game, IAssetManager assetManager, IApiHandler apiHandler)
IAssetManager initializes any assets, and especially before the ITextureStitcher stitches the textures into one.game - The game instanceassetManager - The asset manager instanceapiHandler - The api handler instancedefault void initAssets(IGameInstance game, IAssetManager assetManager, IApiHandler apiHandler)
IAssetManager
initializes all of the IAsset instances from the getResourceLocation(), stitches the textures together using the ITextureStitcher and also after the game loads its own ISpecialCursor objects.game - The game instanceassetManager - The asset manager instanceapiHandler - The api handler instancedefault void postInitAssets(IGameInstance game, IAssetManager assetManager, IApiHandler apiHandler)
IAssetManager gets locked,
meaning assets can still be added to it at this point.game - The game instanceassetManager - The asset manager instanceapiHandler - The api handler instance