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 in fabric.mod.json.
  • Forge: server(() -> MyModServer::new) in a ForgeModEntrypoint.
  • Anywhere else: construct(String, Supplier) from dedicated server code.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    construct(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 void
    Runs while mods are constructed.
    default void
    Runs once registries are filled, on the main thread (Forge's dedicated server setup; right after construction on Fabric).
  • Method Details

    • construct

      static void construct(String modId, Supplier<? extends ServerModConstructor> factory)
      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 (Forge's dedicated server setup; right after construction on Fabric).