Interface UiBackend


public interface UiBackend
A backend's entry point: the class BackendDescriptor.entryClassName() names, with a public no-argument constructor. A backend draws this API's screens with one era of Minecraft's GUI classes; the library's runtime picks one per game (BackendRegistry.select(UiPlatform, int)).

Only the backend BackendRegistry selects for the running game is loaded and started; the others stay unloaded, so their Minecraft references never resolve. Implemented by the library's backends; mods use MultiversionUi.

Lifecycle: the runtime constructs the backend and calls start(ScreenFactory, int) once, when the first mod registers a menu, then registerModConfigScreen(ScreenFactory) for each registered menu. menuScreen(ScreenFactory, Object) and applyRestoredOptions() may be called at any time after that. Every call is wrapped in Failsafe, so anything a backend throws turns the menus off instead of crashing the game.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    For platforms where a mod changes options.txt after the game read it (Forge without Mixin, TODO.md §3.1): makes the running game re-read and apply it, as a menu's GameBridge.reloadOptions() does.
    default Object
    menu as this version's vanilla screen, returning to parent (also a vanilla screen) when closed, without showing it.
    default void
    Makes menu the mod list's config screen of the mod whose container is the loader's active one (Forge and NeoForge 1.13+, where MultiversionUi.register(String, Text, ScreenFactory) runs in that mod's constructor).
    default void
    start(ScreenFactory optionsMenu)
    Hooks the Options screen so that its button opens optionsMenu: on Forge and NeoForge by registering the backend's event listener, on Fabric by handing it to the backend's mixins (which only apply for the selected backend).
    default void
    start(ScreenFactory optionsMenu, int dataVersion)
  • Method Details

    • start

      default void start(ScreenFactory optionsMenu)
      Hooks the Options screen so that its button opens optionsMenu: on Forge and NeoForge by registering the backend's event listener, on Fabric by handing it to the backend's mixins (which only apply for the selected backend). optionsMenu is the library's: the one registered mod's menu, or a list of every registered mod's. Called once, while the game initializes, when the first mod registers its menu, through start(ScreenFactory, int).
      Parameters:
      optionsMenu - what the Options screen's button opens
    • start

      default void start(ScreenFactory optionsMenu, int dataVersion)
      Calls start(ScreenFactory). dataVersion is the running game's DataVersion, the one the backend was selected for: a backend serving releases whose API differs overrides this method instead, to tell them apart (TODO.md 0.6).
      Parameters:
      optionsMenu - what the Options screen's button opens
      dataVersion - the running game's DataVersion (e.g. 3465 for 1.20.1)
    • registerModConfigScreen

      default void registerModConfigScreen(ScreenFactory menu)
      Makes menu the mod list's config screen of the mod whose container is the loader's active one (Forge and NeoForge 1.13+, where MultiversionUi.register(String, Text, ScreenFactory) runs in that mod's constructor). Called after start(ScreenFactory), once per registered menu. Does nothing by default: Fabric's Mod Menu and legacy Forge's mod list ask for the screen themselves (menuScreen(ScreenFactory, Object)).
      Parameters:
      menu - the registering mod's guarded menu
    • applyRestoredOptions

      default void applyRestoredOptions()
      For platforms where a mod changes options.txt after the game read it (Forge without Mixin, TODO.md §3.1): makes the running game re-read and apply it, as a menu's GameBridge.reloadOptions() does. Any thread; the backend moves to the main thread itself. Does nothing by default. MultiversionUi.reloadGameOptions() calls it.