Interface ServerModConstructor
public interface ServerModConstructor
A mod's dedicated server entry point, written once in common code. It's only constructed on a dedicated server;
what runs on both sides (including a client's integrated server) belongs in
ModConstructor.
Hooking it up:
- Fabric: list the class under the
"coolcatlib:server"entrypoint infabric.mod.json. - NeoForge:
server(() -> MyModServer::new)in aNeoForgeModEntrypoint. - Anywhere else:
construct(String, Supplier)from dedicated server code.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconstruct(String modId, Supplier<? extends ServerModConstructor> factory) Constructs a mod's dedicated server entry point:onConstructMod()runs right away,onServerSetup()once the loader is ready.default voidRuns while mods are constructed.default voidRuns once registries are filled, on the main thread (NeoForge's dedicated server setup; right after construction on Fabric).
-
Method Details
-
construct
Constructs a mod's dedicated server entry point:onConstructMod()runs right away,onServerSetup()once the loader is ready. Call it while mods are constructed, and only on a dedicated server.- Throws:
IllegalStateException- when this isn't a dedicated server
-
onConstructMod
default void onConstructMod()Runs while mods are constructed. -
onServerSetup
default void onServerSetup()Runs once registries are filled, on the main thread (NeoForge's dedicated server setup; right after construction on Fabric).
-