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 TypeMethodDescriptiondefault voidFor platforms where a mod changesoptions.txtafter the game read it (Forge without Mixin, TODO.md §3.1): makes the running game re-read and apply it, as a menu'sGameBridge.reloadOptions()does.default ObjectmenuScreen(ScreenFactory menu, Object parent) menuas this version's vanilla screen, returning toparent(also a vanilla screen) when closed, without showing it.default voidMakesmenuthe mod list's config screen of the mod whose container is the loader's active one (Forge and NeoForge 1.13+, whereMultiversionUi.register(String, Text, ScreenFactory)runs in that mod's constructor).default voidstart(ScreenFactory optionsMenu) Hooks the Options screen so that its button opensoptionsMenu: 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 voidstart(ScreenFactory optionsMenu, int dataVersion) Callsstart(ScreenFactory).
-
Method Details
-
start
Hooks the Options screen so that its button opensoptionsMenu: 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).optionsMenuis 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, throughstart(ScreenFactory, int).- Parameters:
optionsMenu- what the Options screen's button opens
-
start
Callsstart(ScreenFactory).dataVersionis 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 opensdataVersion- the running game's DataVersion (e.g. 3465 for 1.20.1)
-
registerModConfigScreen
Makesmenuthe mod list's config screen of the mod whose container is the loader's active one (Forge and NeoForge 1.13+, whereMultiversionUi.register(String, Text, ScreenFactory)runs in that mod's constructor). Called afterstart(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 changesoptions.txtafter the game read it (Forge without Mixin, TODO.md §3.1): makes the running game re-read and apply it, as a menu'sGameBridge.reloadOptions()does. Any thread; the backend moves to the main thread itself. Does nothing by default.MultiversionUi.reloadGameOptions()calls it.
-