@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface Mod
FMLEvent
at pre-defined times during the loading of the game, based on where you have applied the Mod.EventHandler
annotation.
This is a simple example of a Mod. It has the modId of "MyModId", the name of "My example mod", it is version 1.0, and depends on FML being loaded.
package mymod;
// Declare that this is a mod with modId "MyModId", name "My example mod", version "1.0" and dependency on FML.
{@literal @}Mod(modId="MyModId",name="My example mod",version="1.0",dependencies="required-after:FML")
public class MyMod {
// Populate this field with the instance of the mod created by FML
{@literal @}Instance("MyModId")
public MyMod instance;
// Mark this method for receiving an {@link FMLEvent} (in this case, it's the {@link FMLPreInitializationEvent})
{@literal @}EventHandler public void preInit(FMLPreInitializationEvent event)
{
// Do stuff in pre-init phase (read config, create blocks and items, register them)
}
}
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
modid
The unique mod identifier for this mod.
|
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
acceptableRemoteVersions
A replacement for the no-longer-existing "versionRange" of NetworkMod.
|
java.lang.String |
acceptableSaveVersions
A version range specifying compatible save version information.
|
java.lang.String |
acceptedMinecraftVersions
The acceptable range of minecraft versions that this mod will load and run in
The default ("empty string") indicates that the currently RUNNING minecraft version is acceptable.
|
boolean |
canBeDeactivated
If your mod doesn't have a runtime persistent effect on the state of the game, and can be disabled without side effects
(minimap mods, graphical tweak mods) then you can set true here and receive the FMLDeactivationEvent to perform deactivation
tasks.
|
java.lang.String |
certificateFingerprint
Specifying this field allows for a mod to expect a signed jar with a fingerprint matching this value.
|
boolean |
clientSideOnly
If true, this mod will not be loaded on the Dedicated Server environment.
|
Mod.CustomProperty[] |
customProperties
A list of custom properties for this mod.
|
java.lang.String |
dependencies
A dependency string for this mod, which specifies which mod(s) it depends on in order to run.
|
java.lang.String |
guiFactory
An optional GUI factory for this mod.
|
java.lang.String |
modLanguage
The language the mod is authored in.
|
java.lang.String |
modLanguageAdapter
The language adapter to be used to load this mod.
|
java.lang.String |
name
A user friendly name for the mod
|
boolean |
serverSideOnly
If true, this mod will not be loaded on the Client environment.
|
java.lang.String |
updateJSON
An optional URL to a JSON file that will be checked once per launch to determine if there is an updated
version of this mod and notify the end user.
|
boolean |
useMetadata
Whether to use the mcmod.info metadata by default for this mod.
|
java.lang.String |
version
A version string for this mod.
|
public abstract java.lang.String modid
public abstract java.lang.String version
dependencies()
simple for other mods.public abstract java.lang.String dependencies
VersionRange.createFromVersionSpec(java.lang.String)
Then a ";".
If a "required" mod is missing, or a mod exists with a version outside the specified range,
the game will not start and an error screen will tell the player which versions are required.
Example:
Our example mod:
* depends on Forge and uses new features that were introduced in Forge version 14.21.1.2395
"required:forge@[14.21.1.2395,);"
* is a dedicated addon to mod1 and has to have its event handlers run after mod1's are run,
"required-after:mod1;"
* has optional integration with mod2 which depends on features introduced in mod2 version 4.7.0,
"after:mod2@[4.7.0,);"
* depends on a client-side-only rendering library called rendermod
"required-client:rendermod;"
The full dependencies string is all of those combined:
"required:forge@[14.21.1.2395,);required-after:mod1;after:mod2@[4.7.0,);required-client:rendermod;"
This will stop the game and display an error message if any of these is true:
The installed forge is too old,
mod1 is missing,
an old version of mod2 is present,
rendermod is missing on the client.public abstract boolean useMetadata
public abstract boolean clientSideOnly
public abstract boolean serverSideOnly
public abstract java.lang.String acceptedMinecraftVersions
public abstract java.lang.String acceptableRemoteVersions
NetworkCheckHandler
annotation on a method in this class.public abstract java.lang.String acceptableSaveVersions
SaveInspectionHandler
instead.public abstract java.lang.String certificateFingerprint
FMLFingerprintViolationEvent
event firing prior to any other event on the mod.public abstract java.lang.String modLanguage
public abstract java.lang.String modLanguageAdapter
ILanguageAdapter
just like the Java and Scala adapters.
A class with an invalid constructor or that doesn't implement ILanguageAdapter
will throw an exception and
halt loading.public abstract boolean canBeDeactivated
public abstract java.lang.String guiFactory
IModGuiFactory
that will be instantiated
on the client side, and will have certain configuration/options guis requested from it.IModGuiFactory
public abstract java.lang.String updateJSON
public abstract Mod.CustomProperty[] customProperties