Package dev.yumi.mc.core.api.entrypoint
Entrypoints
Entrypoints are points of entry for your mod which translates to a key in mod manifests that are linked to a Java type.
Registering entrypoints
Since the goal of entrypoints is to give points of entry, instead of registering them through Java code like you would for an event, you need to register them in your mod manifest.
This takes the form of a yumi:entrypoints object whose keys are entrypoint keys like "yumi:init",
and whose values take either the form of an entrypoint string, an object with a value key,
or an array of the preceding types.
The entrypoint string may take the form of a fully-qualified class name (org.example.mod.ModInitializer for example),
and optionally a second part after a :: separator either pointing to an instance field (which must be static final),
or a method reference.
Mod manifests take different forms depending on your mod loader.
Fabric
Built-in entrypoint system
Fabric has a built-in entrypoint system (which this library inspired from), this means in your fabric.mod.json
you can use the regular Fabric entrypoints key:
"entrypoints": {
"yumi:init": [
"org.example.mod.ModInitializer"
]
}
This also comes with the advantage of being able to use Fabric's language provider if necessary.
Yumi-provided entrypoint system
Yumi also has its own entrypoint system which can be specified in a fabric.mod.json's custom block:
"custom": {
"yumi:entrypoints": {
"yumi:init": [
"org.example.mod.ModInitializer"
]
}
}
NeoForge
NeoForge does not have a built-in entrypoint system unlike Fabric, as it relies on classpath analysis and annotations instead.
The entrypoint system takes a similar form in a neoforge.mods.toml file, in a modproperties block:
[modproperties.modid."yumi:entrypoints"]
"yumi:init": "org.example.mod.ModInitializer"
Calling entrypoints
The advantage of entrypoints is you can define your own entrypoints for other mods to use, this is especially practical for APIs provided by mods and can lead to an organic load order that doesn't have to worry about loading before or after other mods.
You can call getEntrypoints(java.lang.String, java.lang.Class) to get a collection of
entrypoint containers,
or you can call the shortcut method
invokeEntrypoints(java.lang.String, java.lang.Class, java.util.function.BiConsumer)
for invocation.
-
ClassDescriptionRepresents the container of an entrypoint.Represents an exception that arises when obtaining entrypoints.A mod initializer.