Class Declarations

java.lang.Object
com.trevlar.menukit.api.Declarations

public final class Declarations extends Object
Declarations freeze; state does not.

Every mod declares its panels, adapters, tooltip rules and menu chrome from its initializer, and so do the Kits built on MenuKit (SlotKit's slot groups, operations and channels; ConfigKit's settings), through this one freeze, so every Kit freezes at the same moment. Once every entrypoint has run (the first SERVER_STARTING on a server, CLIENT_STARTED on a client, both before any menu can open), MenuKit freezes them, and a later declaration throws, the way Minecraft's registries do. A late declaration used to half-work: listed on one side, unwired on the other, or taking effect only for screens built after it.

What stays legal is state: a panel shown or hidden, a value written, an index a library fills as menus are built.

  • Method Details

    • requireOpen

      public static void requireOpen(String what)
      Throws if declarations have frozen. A library built on MenuKit calls this at the top of each of its own declaring methods, so its declarations freeze with MenuKit's.
      Parameters:
      what - the call being made, for the message ("ScreenPanelAdapter(mymod:toolbar)")
    • frozen

      public static boolean frozen()
      Whether declarations have frozen.
    • freeze

      @Internal public static void freeze(String when)
      Freezes declarations. Called by MenuKit at client start and at the first server start.